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