2023-07-27 08:31:52 +03:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-07-18 06:12:10 +03:00
|
|
|
<template>
|
2023-01-06 02:41:14 +02:00
|
|
|
<MkModalWindow
|
2022-09-05 12:34:59 +03:00
|
|
|
ref="dialog"
|
2020-10-17 14:12:00 +03:00
|
|
|
:width="400"
|
|
|
|
:height="450"
|
2023-05-19 07:58:09 +03:00
|
|
|
:withOkButton="true"
|
|
|
|
:okButtonDisabled="false"
|
|
|
|
:canClose="false"
|
2022-09-05 12:34:59 +03:00
|
|
|
@close="dialog.close()"
|
2020-10-17 14:12:00 +03:00
|
|
|
@closed="$emit('closed')"
|
|
|
|
@ok="ok()"
|
|
|
|
>
|
2023-04-01 08:01:57 +03:00
|
|
|
<template #header>{{ title || i18n.ts.generateAccessToken }}</template>
|
2023-01-05 12:50:52 +02:00
|
|
|
|
2023-05-19 07:58:09 +03:00
|
|
|
<MkSpacer :marginMin="20" :marginMax="28">
|
2023-01-06 06:40:17 +02:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 14:04:56 +02:00
|
|
|
<div v-if="information">
|
2023-01-05 12:50:52 +02:00
|
|
|
<MkInfo warn>{{ information }}</MkInfo>
|
|
|
|
</div>
|
2023-01-05 14:04:56 +02:00
|
|
|
<div>
|
2023-01-05 12:50:52 +02:00
|
|
|
<MkInput v-model="name">
|
2023-04-01 08:01:57 +03:00
|
|
|
<template #label>{{ i18n.ts.name }}</template>
|
2023-01-05 12:50:52 +02:00
|
|
|
</MkInput>
|
|
|
|
</div>
|
2023-04-01 08:01:57 +03:00
|
|
|
<div><b>{{ i18n.ts.permission }}</b></div>
|
2023-01-06 02:41:14 +02:00
|
|
|
<div class="_buttons">
|
2023-01-05 12:50:52 +02:00
|
|
|
<MkButton inline @click="disableAll">{{ i18n.ts.disableAll }}</MkButton>
|
|
|
|
<MkButton inline @click="enableAll">{{ i18n.ts.enableAll }}</MkButton>
|
|
|
|
</div>
|
2023-09-24 05:04:08 +03:00
|
|
|
<div class="_gaps_s">
|
|
|
|
<MkSwitch v-for="kind in (initialPermissions || Misskey.permissions)" :key="kind" v-model="permissions[kind]">{{ i18n.t(`_permissions.${kind}`) }}</MkSwitch>
|
|
|
|
</div>
|
2023-01-05 12:50:52 +02:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
2023-01-06 02:41:14 +02:00
|
|
|
</MkModalWindow>
|
2020-07-18 06:12:10 +03:00
|
|
|
</template>
|
|
|
|
|
2022-09-05 12:34:59 +03:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2023-09-04 07:33:38 +03:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-01-07 08:09:46 +02:00
|
|
|
import MkInput from './MkInput.vue';
|
2023-01-07 07:59:54 +02:00
|
|
|
import MkSwitch from './MkSwitch.vue';
|
2022-09-06 12:21:49 +03:00
|
|
|
import MkButton from './MkButton.vue';
|
|
|
|
import MkInfo from './MkInfo.vue';
|
2023-01-06 02:41:14 +02:00
|
|
|
import MkModalWindow from '@/components/MkModalWindow.vue';
|
2023-09-19 10:37:43 +03:00
|
|
|
import { i18n } from '@/i18n.js';
|
2020-07-18 06:12:10 +03:00
|
|
|
|
2022-09-05 12:34:59 +03: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 06:12:10 +03:00
|
|
|
|
2022-09-05 12:34:59 +03:00
|
|
|
const emit = defineEmits<{
|
|
|
|
(ev: 'closed'): void;
|
|
|
|
(ev: 'done', result: { name: string | null, permissions: string[] }): void;
|
|
|
|
}>();
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2023-01-06 02:41:14 +02:00
|
|
|
const dialog = $shallowRef<InstanceType<typeof MkModalWindow>>();
|
2022-09-05 12:34:59 +03:00
|
|
|
let name = $ref(props.initialName);
|
|
|
|
let permissions = $ref({});
|
2020-07-18 06:12:10 +03:00
|
|
|
|
2022-09-05 12:34:59 +03:00
|
|
|
if (props.initialPermissions) {
|
|
|
|
for (const kind of props.initialPermissions) {
|
|
|
|
permissions[kind] = true;
|
|
|
|
}
|
|
|
|
} else {
|
2023-09-04 07:33:38 +03:00
|
|
|
for (const kind of Misskey.permissions) {
|
2022-09-05 12:34:59 +03:00
|
|
|
permissions[kind] = false;
|
|
|
|
}
|
|
|
|
}
|
2020-07-18 06:12:10 +03:00
|
|
|
|
2022-09-05 12:34:59 +03:00
|
|
|
function ok(): void {
|
|
|
|
emit('done', {
|
|
|
|
name: name,
|
|
|
|
permissions: Object.keys(permissions).filter(p => permissions[p]),
|
|
|
|
});
|
|
|
|
dialog.close();
|
|
|
|
}
|
2020-07-18 06:12:10 +03:00
|
|
|
|
2022-09-05 12:34:59 +03:00
|
|
|
function disableAll(): void {
|
|
|
|
for (const p in permissions) {
|
|
|
|
permissions[p] = false;
|
|
|
|
}
|
|
|
|
}
|
2020-07-18 06:12:10 +03:00
|
|
|
|
2022-09-05 12:34:59 +03:00
|
|
|
function enableAll(): void {
|
|
|
|
for (const p in permissions) {
|
|
|
|
permissions[p] = true;
|
2020-07-18 06:12:10 +03:00
|
|
|
}
|
2022-09-05 12:34:59 +03:00
|
|
|
}
|
2020-07-18 06:12:10 +03:00
|
|
|
</script>
|