2020-07-18 03:12:10 +00: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 05:28:32 +00:00
|
|
|
<div>
|
|
|
|
<mk-info warn v-if="information">{{ information }}</mk-info>
|
|
|
|
</div>
|
2020-07-18 03:12:10 +00:00
|
|
|
<div>
|
|
|
|
<mk-input v-model="name">{{ $t('name') }}</mk-input>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<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 05:28:32 +00:00
|
|
|
<mk-switch v-for="kind in (initialPermissions || kinds)" :key="kind" v-model="permissions[kind]">{{ $t(`_permissions.${kind}`) }}</mk-switch>
|
2020-07-18 03:12:10 +00: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 05:28:32 +00:00
|
|
|
import MkInfo from './ui/info.vue';
|
2020-07-18 03:12:10 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
|
|
|
XWindow,
|
|
|
|
MkInput,
|
|
|
|
MkTextarea,
|
|
|
|
MkSwitch,
|
|
|
|
MkButton,
|
2020-07-18 05:28:32 +00:00
|
|
|
MkInfo,
|
2020-07-18 03:12:10 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null
|
2020-07-18 05:28:32 +00: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 03:12:10 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2020-07-18 05:28:32 +00:00
|
|
|
name: this.initialName,
|
2020-07-18 03:12:10 +00:00
|
|
|
permissions: {},
|
|
|
|
kinds
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-07-18 05:28:32 +00: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 03:12:10 +00: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>
|