2020-07-18 12:12:10 +09:00
|
|
|
<template>
|
|
|
|
<x-window ref="window" :width="400" :height="450" :no-padding="true" @closed="() => { $emit('closed'); destroyDom(); }" :with-ok-button="true" :ok-button-disabled="false" @ok="ok()" :can-close="false">
|
|
|
|
<template #header>{{ title || $t('generateAccessToken') }}</template>
|
|
|
|
<div class="ugkkpisj">
|
2020-07-18 14:28:32 +09:00
|
|
|
<div>
|
|
|
|
<mk-info warn v-if="information">{{ information }}</mk-info>
|
|
|
|
</div>
|
2020-07-18 12:12:10 +09:00
|
|
|
<div>
|
2020-07-25 01:56:52 +09:00
|
|
|
<mk-input v-model="name">{{ $t('name') }}</mk-input>
|
2020-07-18 12:12:10 +09:00
|
|
|
</div>
|
|
|
|
<div>
|
2020-07-25 01:56:52 +09:00
|
|
|
<div style="margin-bottom: 16px;"><b>{{ $t('permission') }}</b></div>
|
|
|
|
<mk-button inline @click="disableAll">{{ $t('disableAll') }}</mk-button>
|
|
|
|
<mk-button inline @click="enableAll">{{ $t('enableAll') }}</mk-button>
|
2020-07-18 14:28:32 +09:00
|
|
|
<mk-switch v-for="kind in (initialPermissions || kinds)" :key="kind" v-model="permissions[kind]">{{ $t(`_permissions.${kind}`) }}</mk-switch>
|
2020-07-18 12:12:10 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</x-window>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { kinds } from '../../misc/api-permissions';
|
|
|
|
import XWindow from './window.vue';
|
|
|
|
import MkInput from './ui/input.vue';
|
|
|
|
import MkTextarea from './ui/textarea.vue';
|
|
|
|
import MkSwitch from './ui/switch.vue';
|
|
|
|
import MkButton from './ui/button.vue';
|
2020-07-18 14:28:32 +09:00
|
|
|
import MkInfo from './ui/info.vue';
|
2020-07-18 12:12:10 +09:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
|
|
|
XWindow,
|
|
|
|
MkInput,
|
|
|
|
MkTextarea,
|
|
|
|
MkSwitch,
|
|
|
|
MkButton,
|
2020-07-18 14:28:32 +09:00
|
|
|
MkInfo,
|
2020-07-18 12:12:10 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null
|
2020-07-18 14:28:32 +09:00
|
|
|
},
|
|
|
|
information: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
initialName: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
initialPermissions: {
|
|
|
|
type: Array,
|
|
|
|
required: false,
|
|
|
|
default: null
|
2020-07-18 12:12:10 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2020-07-18 14:28:32 +09:00
|
|
|
name: this.initialName,
|
2020-07-18 12:12:10 +09:00
|
|
|
permissions: {},
|
|
|
|
kinds
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-07-18 14:28:32 +09:00
|
|
|
if (this.initialPermissions) {
|
|
|
|
for (const kind of this.initialPermissions) {
|
|
|
|
Vue.set(this.permissions, kind, true);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (const kind of this.kinds) {
|
|
|
|
Vue.set(this.permissions, kind, false);
|
|
|
|
}
|
2020-07-18 12:12:10 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
ok() {
|
|
|
|
this.$emit('ok', {
|
|
|
|
name: this.name,
|
|
|
|
permissions: Object.keys(this.permissions).filter(p => this.permissions[p])
|
|
|
|
});
|
|
|
|
this.$refs.window.close();
|
|
|
|
},
|
|
|
|
|
|
|
|
disableAll() {
|
|
|
|
for (const p in this.permissions) {
|
|
|
|
this.permissions[p] = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
enableAll() {
|
|
|
|
for (const p in this.permissions) {
|
|
|
|
this.permissions[p] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.ugkkpisj {
|
|
|
|
> div {
|
|
|
|
padding: 24px;
|
|
|
|
border-top: solid 1px var(--divider);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|