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"
|
2024-01-05 03:52:24 +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-09-24 02:04:08 +00:00
|
|
|
<div class="_gaps_s">
|
2023-12-27 06:08:59 +00:00
|
|
|
<MkSwitch v-for="kind in Object.keys(permissions)" :key="kind" v-model="permissions[kind]">{{ i18n.t(`_permissions.${kind}`) }}</MkSwitch>
|
2023-09-24 02:04:08 +00:00
|
|
|
</div>
|
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>
|
2023-12-07 05:42:09 +00:00
|
|
|
import { shallowRef, ref } from 'vue';
|
2023-09-04 04:33:38 +00:00
|
|
|
import * as Misskey 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-09-19 07:37:43 +00:00
|
|
|
import { i18n } from '@/i18n.js';
|
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;
|
2023-12-27 06:08:59 +00:00
|
|
|
initialPermissions?: (typeof Misskey.permissions)[number][] | null;
|
2022-09-05 09:34:59 +00:00
|
|
|
}>(), {
|
|
|
|
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-12-27 06:08:59 +00:00
|
|
|
const defaultPermissions = Misskey.permissions.filter(p => !p.startsWith('read:admin') && !p.startsWith('write:admin'));
|
2023-12-07 05:42:09 +00:00
|
|
|
const dialog = shallowRef<InstanceType<typeof MkModalWindow>>();
|
|
|
|
const name = ref(props.initialName);
|
2023-12-27 06:08:59 +00:00
|
|
|
const permissions = ref(<Record<(typeof Misskey.permissions)[number], boolean>>{});
|
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) {
|
2023-12-07 05:42:09 +00:00
|
|
|
permissions.value[kind] = true;
|
2022-09-05 09:34:59 +00:00
|
|
|
}
|
|
|
|
} else {
|
2023-12-27 06:08:59 +00:00
|
|
|
for (const kind of defaultPermissions) {
|
2023-12-07 05:42:09 +00:00
|
|
|
permissions.value[kind] = false;
|
2022-09-05 09:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-18 03:12:10 +00:00
|
|
|
|
2022-09-05 09:34:59 +00:00
|
|
|
function ok(): void {
|
|
|
|
emit('done', {
|
2023-12-07 05:42:09 +00:00
|
|
|
name: name.value,
|
|
|
|
permissions: Object.keys(permissions.value).filter(p => permissions.value[p]),
|
2022-09-05 09:34:59 +00:00
|
|
|
});
|
2024-01-05 03:52:24 +00:00
|
|
|
dialog.value?.close();
|
2022-09-05 09:34:59 +00:00
|
|
|
}
|
2020-07-18 03:12:10 +00:00
|
|
|
|
2022-09-05 09:34:59 +00:00
|
|
|
function disableAll(): void {
|
2023-12-07 05:42:09 +00:00
|
|
|
for (const p in permissions.value) {
|
|
|
|
permissions.value[p] = false;
|
2022-09-05 09:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-18 03:12:10 +00:00
|
|
|
|
2022-09-05 09:34:59 +00:00
|
|
|
function enableAll(): void {
|
2023-12-07 05:42:09 +00:00
|
|
|
for (const p in permissions.value) {
|
|
|
|
permissions.value[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>
|