2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-01-12 12:02:26 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><XHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-05-29 08:13:12 +00:00
|
|
|
<MkSpacer :contentMax="700">
|
2023-01-12 12:02:26 +00:00
|
|
|
<div class="_gaps">
|
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts._role.baseRole }}</template>
|
2023-01-19 01:39:23 +00:00
|
|
|
<div class="_gaps_s">
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkInput v-model="baseRoleQ" type="search">
|
|
|
|
<template #prefix><i class="ti ti-search"></i></template>
|
|
|
|
</MkInput>
|
|
|
|
|
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.rateLimitFactor, 'rateLimitFactor'])">
|
2023-01-15 07:52:12 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.rateLimitFactor }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ Math.floor(policies.rateLimitFactor * 100) }}%</template>
|
2023-05-29 08:13:12 +00:00
|
|
|
<MkRange :modelValue="policies.rateLimitFactor * 100" :min="30" :max="300" :step="10" :textConverter="(v) => `${v}%`" @update:modelValue="v => policies.rateLimitFactor = (v / 100)">
|
2023-01-15 07:52:12 +00:00
|
|
|
<template #caption>{{ i18n.ts._role._options.descriptionOfRateLimitFactor }}</template>
|
|
|
|
</MkRange>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.gtlAvailable, 'gtlAvailable'])">
|
2023-01-12 12:02:26 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.gtlAvailable }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.gtlAvailable ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.gtlAvailable">
|
2023-01-12 12:02:26 +00:00
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.ltlAvailable, 'ltlAvailable'])">
|
2023-01-12 12:02:26 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.ltlAvailable }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.ltlAvailable ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.ltlAvailable">
|
2023-01-12 12:02:26 +00:00
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.canPublicNote, 'canPublicNote'])">
|
2023-01-12 12:02:26 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.canPublicNote }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.canPublicNote ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.canPublicNote">
|
2023-01-12 12:02:26 +00:00
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.canInvite, 'canInvite'])">
|
2023-01-13 05:22:53 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.canInvite }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.canInvite ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.canInvite">
|
2023-01-13 05:22:53 +00:00
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-07-15 00:57:58 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.inviteLimit, 'inviteLimit'])">
|
|
|
|
<template #label>{{ i18n.ts._role._options.inviteLimit }}</template>
|
|
|
|
<template #suffix>{{ policies.inviteLimit }}</template>
|
|
|
|
<MkInput v-model="policies.inviteLimit" type="number">
|
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
2023-07-27 05:31:52 +00:00
|
|
|
|
2023-07-15 00:57:58 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.inviteLimitCycle, 'inviteLimitCycle'])">
|
|
|
|
<template #label>{{ i18n.ts._role._options.inviteLimitCycle }}</template>
|
|
|
|
<template #suffix>{{ policies.inviteLimitCycle + i18n.ts._time.minute }}</template>
|
|
|
|
<MkInput v-model="policies.inviteLimitCycle" type="number">
|
|
|
|
<template #suffix>{{ i18n.ts._time.minute }}</template>
|
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.inviteExpirationTime, 'inviteExpirationTime'])">
|
|
|
|
<template #label>{{ i18n.ts._role._options.inviteExpirationTime }}</template>
|
|
|
|
<template #suffix>{{ policies.inviteExpirationTime + i18n.ts._time.minute }}</template>
|
|
|
|
<MkInput v-model="policies.inviteExpirationTime" type="number">
|
|
|
|
<template #suffix>{{ i18n.ts._time.minute }}</template>
|
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-10-30 06:33:15 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.canManageAvatarDecorations, 'canManageAvatarDecorations'])">
|
|
|
|
<template #label>{{ i18n.ts._role._options.canManageAvatarDecorations }}</template>
|
|
|
|
<template #suffix>{{ policies.canManageAvatarDecorations ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.canManageAvatarDecorations">
|
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.canManageCustomEmojis, 'canManageCustomEmojis'])">
|
2023-01-13 05:58:27 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.canManageCustomEmojis }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.canManageCustomEmojis ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.canManageCustomEmojis">
|
2023-01-13 05:58:27 +00:00
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.canSearchNotes, 'canSearchNotes'])">
|
2023-03-13 08:52:24 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.canSearchNotes }}</template>
|
|
|
|
<template #suffix>{{ policies.canSearchNotes ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.canSearchNotes">
|
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-09-29 22:54:11 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.canUseTranslator, 'canSearchNotes'])">
|
|
|
|
<template #label>{{ i18n.ts._role._options.canUseTranslator }}</template>
|
|
|
|
<template #suffix>{{ policies.canUseTranslator ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.canUseTranslator">
|
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.driveCapacity, 'driveCapacityMb'])">
|
2023-01-12 12:02:26 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.driveCapacity }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.driveCapacityMb }}MB</template>
|
|
|
|
<MkInput v-model="policies.driveCapacityMb" type="number">
|
2023-01-12 12:02:26 +00:00
|
|
|
<template #suffix>MB</template>
|
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-05-05 05:18:06 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.alwaysMarkNsfw, 'alwaysMarkNsfw'])">
|
|
|
|
<template #label>{{ i18n.ts._role._options.alwaysMarkNsfw }}</template>
|
|
|
|
<template #suffix>{{ policies.alwaysMarkNsfw ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.alwaysMarkNsfw">
|
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.pinMax, 'pinLimit'])">
|
2023-01-14 09:04:56 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.pinMax }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.pinLimit }}</template>
|
|
|
|
<MkInput v-model="policies.pinLimit" type="number">
|
2023-01-14 09:04:56 +00:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.antennaMax, 'antennaLimit'])">
|
2023-01-12 12:02:26 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.antennaMax }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.antennaLimit }}</template>
|
|
|
|
<MkInput v-model="policies.antennaLimit" type="number">
|
2023-01-12 12:02:26 +00:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
2023-01-13 23:04:38 +00:00
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.wordMuteMax, 'wordMuteLimit'])">
|
2023-01-13 23:04:38 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.wordMuteMax }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.wordMuteLimit }}</template>
|
|
|
|
<MkInput v-model="policies.wordMuteLimit" type="number">
|
2023-01-13 23:04:38 +00:00
|
|
|
<template #suffix>chars</template>
|
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.webhookMax, 'webhookLimit'])">
|
2023-01-14 01:48:11 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.webhookMax }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.webhookLimit }}</template>
|
|
|
|
<MkInput v-model="policies.webhookLimit" type="number">
|
2023-01-14 01:48:11 +00:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.clipMax, 'clipLimit'])">
|
2023-01-14 07:14:24 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.clipMax }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.clipLimit }}</template>
|
|
|
|
<MkInput v-model="policies.clipLimit" type="number">
|
2023-01-14 07:14:24 +00:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.noteEachClipsMax, 'noteEachClipsLimit'])">
|
2023-01-14 07:14:24 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.noteEachClipsMax }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.noteEachClipsLimit }}</template>
|
|
|
|
<MkInput v-model="policies.noteEachClipsLimit" type="number">
|
2023-01-14 07:14:24 +00:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.userListMax, 'userListLimit'])">
|
2023-01-14 08:38:16 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.userListMax }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.userListLimit }}</template>
|
|
|
|
<MkInput v-model="policies.userListLimit" type="number">
|
2023-01-14 08:38:16 +00:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.userEachUserListsMax, 'userEachUserListsLimit'])">
|
2023-01-14 08:38:16 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.userEachUserListsMax }}</template>
|
2023-01-15 11:52:53 +00:00
|
|
|
<template #suffix>{{ policies.userEachUserListsLimit }}</template>
|
|
|
|
<MkInput v-model="policies.userEachUserListsLimit" type="number">
|
2023-01-14 08:38:16 +00:00
|
|
|
</MkInput>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
<MkFolder v-if="matchQuery([i18n.ts._role._options.canHideAds, 'canHideAds'])">
|
2023-01-16 02:21:04 +00:00
|
|
|
<template #label>{{ i18n.ts._role._options.canHideAds }}</template>
|
|
|
|
<template #suffix>{{ policies.canHideAds ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
|
|
<MkSwitch v-model="policies.canHideAds">
|
|
|
|
<template #label>{{ i18n.ts.enable }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkFolder>
|
|
|
|
|
2023-01-12 12:02:26 +00:00
|
|
|
<MkButton primary rounded @click="updateBaseRole">{{ i18n.ts.save }}</MkButton>
|
|
|
|
</div>
|
|
|
|
</MkFolder>
|
2023-03-04 08:36:11 +00:00
|
|
|
<MkButton primary rounded @click="create"><i class="ti ti-plus"></i> {{ i18n.ts._role.new }}</MkButton>
|
2023-01-12 12:02:26 +00:00
|
|
|
<div class="_gaps_s">
|
2023-03-04 08:36:11 +00:00
|
|
|
<MkFoldableSection>
|
2023-11-23 23:36:55 +00:00
|
|
|
<template #header>{{ i18n.ts._role.manualRoles }}</template>
|
2023-03-04 08:36:11 +00:00
|
|
|
<div class="_gaps_s">
|
2023-05-29 08:13:12 +00:00
|
|
|
<MkRolePreview v-for="role in roles.filter(x => x.target === 'manual')" :key="role.id" :role="role" :forModeration="true"/>
|
2023-03-04 08:36:11 +00:00
|
|
|
</div>
|
|
|
|
</MkFoldableSection>
|
|
|
|
<MkFoldableSection>
|
2023-11-23 23:36:55 +00:00
|
|
|
<template #header>{{ i18n.ts._role.conditionalRoles }}</template>
|
2023-03-04 08:36:11 +00:00
|
|
|
<div class="_gaps_s">
|
2023-05-29 08:13:12 +00:00
|
|
|
<MkRolePreview v-for="role in roles.filter(x => x.target === 'conditional')" :key="role.id" :role="role" :forModeration="true"/>
|
2023-03-04 08:36:11 +00:00
|
|
|
</div>
|
|
|
|
</MkFoldableSection>
|
2023-01-12 12:02:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-03-13 11:02:53 +00:00
|
|
|
import { computed, reactive, ref } from 'vue';
|
2023-01-12 12:02:26 +00:00
|
|
|
import XHeader from './_header_.vue';
|
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-01-15 07:52:12 +00:00
|
|
|
import MkRange from '@/components/MkRange.vue';
|
2023-01-12 12:02:26 +00:00
|
|
|
import MkRolePreview from '@/components/MkRolePreview.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import { instance } from '@/instance.js';
|
|
|
|
import { useRouter } from '@/router.js';
|
2023-03-04 08:36:11 +00:00
|
|
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
2023-03-13 08:52:24 +00:00
|
|
|
import { ROLE_POLICIES } from '@/const';
|
2023-01-15 11:52:53 +00:00
|
|
|
|
2023-01-12 12:02:26 +00:00
|
|
|
const router = useRouter();
|
2023-03-13 11:02:53 +00:00
|
|
|
const baseRoleQ = ref('');
|
2023-01-12 12:02:26 +00:00
|
|
|
|
|
|
|
const roles = await os.api('admin/roles/list');
|
|
|
|
|
2023-01-15 11:52:53 +00:00
|
|
|
const policies = reactive<Record<typeof ROLE_POLICIES[number], any>>({});
|
|
|
|
for (const ROLE_POLICY of ROLE_POLICIES) {
|
|
|
|
policies[ROLE_POLICY] = instance.policies[ROLE_POLICY];
|
|
|
|
}
|
2023-01-12 12:02:26 +00:00
|
|
|
|
2023-03-13 11:02:53 +00:00
|
|
|
function matchQuery(keywords: string[]): boolean {
|
|
|
|
if (baseRoleQ.value.trim().length === 0) return true;
|
|
|
|
return keywords.some(keyword => keyword.toLowerCase().includes(baseRoleQ.value.toLowerCase()));
|
|
|
|
}
|
|
|
|
|
2023-01-12 12:02:26 +00:00
|
|
|
async function updateBaseRole() {
|
2023-01-15 11:52:53 +00:00
|
|
|
await os.apiWithDialog('admin/roles/update-default-policies', {
|
|
|
|
policies,
|
2023-01-12 12:02:26 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
router.push('/admin/roles/new');
|
|
|
|
}
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const headerActions = computed(() => []);
|
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
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: i18n.ts.roles,
|
|
|
|
icon: 'ti ti-badges',
|
|
|
|
})));
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
|
|
|
|
</style>
|