2020-07-18 12:12:10 +09:00
|
|
|
<template>
|
2023-01-06 09:41:14 +09:00
|
|
|
<MkModalWindow
|
2022-09-05 18:34:59 +09:00
|
|
|
ref="dialog"
|
2020-10-17 20:12:00 +09:00
|
|
|
:width="400"
|
|
|
|
:height="450"
|
|
|
|
:with-ok-button="true"
|
|
|
|
:ok-button-disabled="false"
|
|
|
|
:can-close="false"
|
2022-09-05 18:34:59 +09:00
|
|
|
@close="dialog.close()"
|
2020-10-17 20:12:00 +09:00
|
|
|
@closed="$emit('closed')"
|
|
|
|
@ok="ok()"
|
|
|
|
>
|
2020-12-26 10:47:36 +09:00
|
|
|
<template #header>{{ title || $ts.generateAccessToken }}</template>
|
2023-01-05 19:50:52 +09:00
|
|
|
|
|
|
|
<MkSpacer :margin-min="20" :margin-max="28">
|
2023-01-06 13:40:17 +09:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 21:04:56 +09:00
|
|
|
<div v-if="information">
|
2023-01-05 19:50:52 +09:00
|
|
|
<MkInfo warn>{{ information }}</MkInfo>
|
|
|
|
</div>
|
2023-01-05 21:04:56 +09:00
|
|
|
<div>
|
2023-01-05 19:50:52 +09:00
|
|
|
<MkInput v-model="name">
|
|
|
|
<template #label>{{ $ts.name }}</template>
|
|
|
|
</MkInput>
|
|
|
|
</div>
|
2023-01-05 21:04:56 +09:00
|
|
|
<div><b>{{ $ts.permission }}</b></div>
|
2023-01-06 09:41:14 +09:00
|
|
|
<div class="_buttons">
|
2023-01-05 19:50:52 +09:00
|
|
|
<MkButton inline @click="disableAll">{{ i18n.ts.disableAll }}</MkButton>
|
|
|
|
<MkButton inline @click="enableAll">{{ i18n.ts.enableAll }}</MkButton>
|
|
|
|
</div>
|
2023-01-05 21:04:56 +09:00
|
|
|
<MkSwitch v-for="kind in (initialPermissions || kinds)" :key="kind" v-model="permissions[kind]">{{ $t(`_permissions.${kind}`) }}</MkSwitch>
|
2023-01-05 19:50:52 +09:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
2023-01-06 09:41:14 +09:00
|
|
|
</MkModalWindow>
|
2020-07-18 12:12:10 +09:00
|
|
|
</template>
|
|
|
|
|
2022-09-05 18:34:59 +09:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
|
|
|
import { permissions as kinds } from 'misskey-js';
|
2021-09-30 00:50:45 +09:00
|
|
|
import MkInput from './form/input.vue';
|
2023-01-07 14:59:54 +09:00
|
|
|
import MkSwitch from './MkSwitch.vue';
|
2022-09-06 18:21:49 +09:00
|
|
|
import MkButton from './MkButton.vue';
|
|
|
|
import MkInfo from './MkInfo.vue';
|
2023-01-06 09:41:14 +09:00
|
|
|
import MkModalWindow from '@/components/MkModalWindow.vue';
|
2023-01-05 19:50:52 +09:00
|
|
|
import { i18n } from '@/i18n';
|
2020-07-18 12:12:10 +09:00
|
|
|
|
2022-09-05 18:34:59 +09:00
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
title?: string | null;
|
|
|
|
information?: string | null;
|
|
|
|
initialName?: string | null;
|
|
|
|
initialPermissions?: string[] | null;
|
|
|
|
}>(), {
|
|
|
|
title: null,
|
|
|
|
information: null,
|
|
|
|
initialName: null,
|
|
|
|
initialPermissions: null,
|
|
|
|
});
|
2020-07-18 12:12:10 +09:00
|
|
|
|
2022-09-05 18:34:59 +09:00
|
|
|
const emit = defineEmits<{
|
|
|
|
(ev: 'closed'): void;
|
|
|
|
(ev: 'done', result: { name: string | null, permissions: string[] }): void;
|
|
|
|
}>();
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2023-01-06 09:41:14 +09:00
|
|
|
const dialog = $shallowRef<InstanceType<typeof MkModalWindow>>();
|
2022-09-05 18:34:59 +09:00
|
|
|
let name = $ref(props.initialName);
|
|
|
|
let permissions = $ref({});
|
2020-07-18 12:12:10 +09:00
|
|
|
|
2022-09-05 18:34:59 +09:00
|
|
|
if (props.initialPermissions) {
|
|
|
|
for (const kind of props.initialPermissions) {
|
|
|
|
permissions[kind] = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (const kind of kinds) {
|
|
|
|
permissions[kind] = false;
|
|
|
|
}
|
|
|
|
}
|
2020-07-18 12:12:10 +09:00
|
|
|
|
2022-09-05 18:34:59 +09:00
|
|
|
function ok(): void {
|
|
|
|
emit('done', {
|
|
|
|
name: name,
|
|
|
|
permissions: Object.keys(permissions).filter(p => permissions[p]),
|
|
|
|
});
|
|
|
|
dialog.close();
|
|
|
|
}
|
2020-07-18 12:12:10 +09:00
|
|
|
|
2022-09-05 18:34:59 +09:00
|
|
|
function disableAll(): void {
|
|
|
|
for (const p in permissions) {
|
|
|
|
permissions[p] = false;
|
|
|
|
}
|
|
|
|
}
|
2020-07-18 12:12:10 +09:00
|
|
|
|
2022-09-05 18:34:59 +09:00
|
|
|
function enableAll(): void {
|
|
|
|
for (const p in permissions) {
|
|
|
|
permissions[p] = true;
|
2020-07-18 12:12:10 +09:00
|
|
|
}
|
2022-09-05 18:34:59 +09:00
|
|
|
}
|
2020-07-18 12:12:10 +09:00
|
|
|
</script>
|