2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
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"
|
2023-05-19 04:58:09 +00:00
|
|
|
:withOkButton="true"
|
|
|
|
:okButtonDisabled="false"
|
|
|
|
:canClose="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()"
|
|
|
|
>
|
2023-04-01 05:01:57 +00:00
|
|
|
<template #header>{{ title || i18n.ts.generateAccessToken }}</template>
|
2023-01-05 10:50:52 +00:00
|
|
|
|
2023-05-19 04:58:09 +00:00
|
|
|
<MkSpacer :marginMin="20" :marginMax="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">
|
2023-04-01 05:01:57 +00:00
|
|
|
<template #label>{{ i18n.ts.name }}</template>
|
2023-01-05 10:50:52 +00:00
|
|
|
</MkInput>
|
|
|
|
</div>
|
2023-04-01 05:01:57 +00:00
|
|
|
<div><b>{{ i18n.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-04-01 05:01:57 +00:00
|
|
|
<MkSwitch v-for="kind in (initialPermissions || kinds)" :key="kind" v-model="permissions[kind]">{{ i18n.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';
|
2023-01-07 06:09:46 +00:00
|
|
|
import MkInput from './MkInput.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>
|