2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
2024-02-13 15:50:11 +00:00
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
2023-07-27 05:31:52 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-01-12 12:02:26 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<MkStickyContainer>
|
2023-03-02 11:47:24 +00:00
|
|
|
<template #header><XHeader :tabs="headerTabs"/></template>
|
2023-05-19 11:52:15 +00:00
|
|
|
<MkSpacer :contentMax="600" :marginMin="16" :marginMax="32">
|
2023-03-02 11:47:24 +00:00
|
|
|
<XEditor v-if="data" v-model="data"/>
|
2023-01-12 12:02:26 +00:00
|
|
|
</MkSpacer>
|
2023-03-02 11:47:24 +00:00
|
|
|
<template #footer>
|
|
|
|
<div :class="$style.footer">
|
2023-05-19 11:52:15 +00:00
|
|
|
<MkSpacer :contentMax="600" :marginMin="16" :marginMax="16">
|
2023-03-02 11:47:24 +00:00
|
|
|
<MkButton primary rounded @click="save"><i class="ti ti-check"></i> {{ i18n.ts.save }}</MkButton>
|
|
|
|
</MkSpacer>
|
|
|
|
</div>
|
|
|
|
</template>
|
2023-01-12 12:02:26 +00:00
|
|
|
</MkStickyContainer>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-12-07 05:42:09 +00:00
|
|
|
import { computed, ref } from 'vue';
|
2023-12-26 05:19:35 +00:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-03-02 11:47:24 +00:00
|
|
|
import { v4 as uuid } from 'uuid';
|
2023-01-12 12:02:26 +00:00
|
|
|
import XHeader from './_header_.vue';
|
|
|
|
import XEditor from './roles.editor.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import * as os from '@/os.js';
|
2024-01-04 09:32:46 +00:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
2023-03-02 11:47:24 +00:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-12-24 07:16:58 +00:00
|
|
|
import { rolesCache } from '@/cache.js';
|
2024-01-30 12:07:34 +00:00
|
|
|
import { useRouter } from '@/router/supplier.js';
|
2023-01-12 12:02:26 +00:00
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
id?: string;
|
|
|
|
}>();
|
|
|
|
|
2023-12-26 05:19:35 +00:00
|
|
|
const role = ref<Misskey.entities.Role | null>(null);
|
|
|
|
const data = ref<any>(null);
|
2023-01-12 12:02:26 +00:00
|
|
|
|
|
|
|
if (props.id) {
|
2024-01-04 09:32:46 +00:00
|
|
|
role.value = await misskeyApi('admin/roles/show', {
|
2023-01-12 12:02:26 +00:00
|
|
|
roleId: props.id,
|
|
|
|
});
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
data.value = role.value;
|
2023-03-02 11:47:24 +00:00
|
|
|
} else {
|
2023-12-07 05:42:09 +00:00
|
|
|
data.value = {
|
2023-03-02 11:47:24 +00:00
|
|
|
name: 'New Role',
|
|
|
|
description: '',
|
2023-03-05 01:48:04 +00:00
|
|
|
isAdministrator: false,
|
|
|
|
isModerator: false,
|
2023-03-02 11:47:24 +00:00
|
|
|
color: null,
|
|
|
|
iconUrl: null,
|
|
|
|
target: 'manual',
|
|
|
|
condFormula: { id: uuid(), type: 'isRemote' },
|
|
|
|
isPublic: false,
|
2023-04-20 11:02:50 +00:00
|
|
|
isExplorable: false,
|
2023-03-02 11:47:24 +00:00
|
|
|
asBadge: false,
|
|
|
|
canEditMembersByModerator: false,
|
2023-03-12 07:38:08 +00:00
|
|
|
displayOrder: 0,
|
2023-03-02 11:47:24 +00:00
|
|
|
policies: {},
|
|
|
|
};
|
2023-01-12 12:02:26 +00:00
|
|
|
}
|
|
|
|
|
2023-03-02 11:47:24 +00:00
|
|
|
async function save() {
|
2023-03-24 07:54:37 +00:00
|
|
|
rolesCache.delete();
|
2023-12-07 05:42:09 +00:00
|
|
|
if (role.value) {
|
2023-03-02 11:47:24 +00:00
|
|
|
os.apiWithDialog('admin/roles/update', {
|
2023-12-07 05:42:09 +00:00
|
|
|
roleId: role.value.id,
|
|
|
|
...data.value,
|
2023-03-02 11:47:24 +00:00
|
|
|
});
|
2023-12-07 05:42:09 +00:00
|
|
|
router.push('/admin/roles/' + role.value.id);
|
2023-03-02 11:47:24 +00:00
|
|
|
} else {
|
|
|
|
const created = await os.apiWithDialog('admin/roles/create', {
|
2023-12-07 05:42:09 +00:00
|
|
|
...data.value,
|
2023-03-02 11:47:24 +00:00
|
|
|
});
|
|
|
|
router.push('/admin/roles/' + created.id);
|
|
|
|
}
|
2023-01-12 12:02:26 +00:00
|
|
|
}
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const headerTabs = computed(() => []);
|
2023-01-12 12:02:26 +00:00
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
definePageMetadata(computed(() => role.value ? {
|
|
|
|
title: i18n.ts._role.edit + ': ' + role.value.name,
|
2023-01-12 12:02:26 +00:00
|
|
|
icon: 'ti ti-badge',
|
|
|
|
} : {
|
|
|
|
title: i18n.ts._role.new,
|
|
|
|
icon: 'ti ti-badge',
|
|
|
|
}));
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
2023-03-02 11:47:24 +00:00
|
|
|
.footer {
|
|
|
|
-webkit-backdrop-filter: var(--blur, blur(15px));
|
|
|
|
backdrop-filter: var(--blur, blur(15px));
|
|
|
|
}
|
2023-01-12 12:02:26 +00:00
|
|
|
</style>
|