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