Sharkey/packages/frontend/src/pages/admin/moderation.vue

157 lines
5.6 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
2023-03-13 09:37:22 +01:00
<template>
<div>
<MkStickyContainer>
<template #header><XHeader :tabs="headerTabs"/></template>
2023-05-19 13:52:15 +02:00
<MkSpacer :contentMax="700" :marginMin="16" :marginMax="32">
2023-03-13 09:37:22 +01:00
<FormSuspense :p="init">
<div class="_gaps_m">
2023-05-01 10:09:07 +02:00
<MkSwitch v-model="enableRegistration">
<template #label>{{ i18n.ts.enableRegistration }}</template>
</MkSwitch>
<MkSwitch v-model="emailRequiredForSignup">
<template #label>{{ i18n.ts.emailRequiredForSignup }}</template>
</MkSwitch>
2023-10-18 02:41:36 +02:00
<MkSwitch v-model="approvalRequiredForSignup">
2023-10-18 03:00:48 +02:00
<template #label>{{ i18n.ts.approvalRequiredForSignup }}</template>
2023-10-18 02:41:36 +02:00
</MkSwitch>
2023-05-01 10:09:07 +02:00
<FormLink to="/admin/server-rules">{{ i18n.ts.serverRules }}</FormLink>
<MkInput v-model="tosUrl" type="url">
2024-06-21 15:48:54 +02:00
<template #prefix><i class="ti ti-link"></i></template>
2023-05-01 10:09:07 +02:00
<template #label>{{ i18n.ts.tosUrl }}</template>
</MkInput>
<MkInput v-model="privacyPolicyUrl" type="url">
2024-06-21 15:48:54 +02:00
<template #prefix><i class="ti ti-link"></i></template>
<template #label>{{ i18n.ts.privacyPolicyUrl }}</template>
</MkInput>
<MkTextarea v-if="bubbleTimelineEnabled" v-model="bubbleTimeline">
<template #label>Bubble timeline</template>
<template #caption>Choose which instances should be displayed in the bubble.</template>
</MkTextarea>
<MkInput v-model="inquiryUrl" type="url">
2024-06-21 15:48:54 +02:00
<template #prefix><i class="ti ti-link"></i></template>
<template #label>{{ i18n.ts._serverSettings.inquiryUrl }}</template>
<template #caption>{{ i18n.ts._serverSettings.inquiryUrlDescription }}</template>
</MkInput>
2023-05-01 10:09:07 +02:00
<MkTextarea v-model="preservedUsernames">
<template #label>{{ i18n.ts.preservedUsernames }}</template>
<template #caption>{{ i18n.ts.preservedUsernamesDescription }}</template>
</MkTextarea>
2023-05-01 10:09:07 +02:00
<MkTextarea v-model="sensitiveWords">
<template #label>{{ i18n.ts.sensitiveWords }}</template>
<template #caption>{{ i18n.ts.sensitiveWordsDescription }}<br>{{ i18n.ts.sensitiveWordsDescription2 }}</template>
2023-05-01 10:09:07 +02:00
</MkTextarea>
<MkTextarea v-model="prohibitedWords">
<template #label>{{ i18n.ts.prohibitedWords }}</template>
<template #caption>{{ i18n.ts.prohibitedWordsDescription }}<br>{{ i18n.ts.prohibitedWordsDescription2 }}</template>
</MkTextarea>
<MkTextarea v-model="hiddenTags">
<template #label>{{ i18n.ts.hiddenTags }}</template>
<template #caption>{{ i18n.ts.hiddenTagsDescription }}</template>
</MkTextarea>
2023-03-13 09:37:22 +01:00
</div>
</FormSuspense>
</MkSpacer>
<template #footer>
<div :class="$style.footer">
2023-05-19 13:52:15 +02:00
<MkSpacer :contentMax="700" :marginMin="16" :marginMax="16">
2024-06-21 14:09:24 +02:00
<MkButton primary rounded @click="save"><i class="ti ti-check"></i> {{ i18n.ts.save }}</MkButton>
2023-03-13 09:37:22 +01:00
</MkSpacer>
</div>
</template>
</MkStickyContainer>
</div>
</template>
<script lang="ts" setup>
import { ref, computed } from 'vue';
2023-03-13 09:37:22 +01:00
import XHeader from './_header_.vue';
import MkSwitch from '@/components/MkSwitch.vue';
import MkInput from '@/components/MkInput.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import FormSuspense from '@/components/form/suspense.vue';
2023-09-19 09:37:43 +02:00
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
2023-09-19 09:37:43 +02:00
import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
2023-03-13 09:37:22 +01:00
import MkButton from '@/components/MkButton.vue';
import FormLink from '@/components/form/link.vue';
2023-03-13 09:37:22 +01:00
const enableRegistration = ref<boolean>(false);
const emailRequiredForSignup = ref<boolean>(false);
2023-12-23 02:09:23 +01:00
const approvalRequiredForSignup = ref<boolean>(false);
const bubbleTimelineEnabled = ref<boolean>(false);
const sensitiveWords = ref<string>('');
const prohibitedWords = ref<string>('');
const hiddenTags = ref<string>('');
const preservedUsernames = ref<string>('');
2023-12-23 02:09:23 +01:00
const bubbleTimeline = ref<string>('');
const tosUrl = ref<string | null>(null);
const privacyPolicyUrl = ref<string | null>(null);
const inquiryUrl = ref<string | null>(null);
2023-03-13 09:37:22 +01:00
async function init() {
const meta = await misskeyApi('admin/meta');
enableRegistration.value = !meta.disableRegistration;
emailRequiredForSignup.value = meta.emailRequiredForSignup;
2023-12-23 02:09:23 +01:00
approvalRequiredForSignup.value = meta.approvalRequiredForSignup;
sensitiveWords.value = meta.sensitiveWords.join('\n');
prohibitedWords.value = meta.prohibitedWords.join('\n');
hiddenTags.value = meta.hiddenTags.join('\n');
preservedUsernames.value = meta.preservedUsernames.join('\n');
tosUrl.value = meta.tosUrl;
privacyPolicyUrl.value = meta.privacyPolicyUrl;
2023-12-23 02:09:23 +01:00
bubbleTimeline.value = meta.bubbleInstances.join('\n');
bubbleTimelineEnabled.value = meta.policies.btlAvailable;
inquiryUrl.value = meta.inquiryUrl;
2023-03-13 09:37:22 +01:00
}
function save() {
os.apiWithDialog('admin/update-meta', {
disableRegistration: !enableRegistration.value,
emailRequiredForSignup: emailRequiredForSignup.value,
2023-12-23 02:09:23 +01:00
approvalRequiredForSignup: approvalRequiredForSignup.value,
tosUrl: tosUrl.value,
privacyPolicyUrl: privacyPolicyUrl.value,
inquiryUrl: inquiryUrl.value,
sensitiveWords: sensitiveWords.value.split('\n'),
prohibitedWords: prohibitedWords.value.split('\n'),
hiddenTags: hiddenTags.value.split('\n'),
preservedUsernames: preservedUsernames.value.split('\n'),
2023-12-23 02:09:23 +01:00
bubbleInstances: bubbleTimeline.value.split('\n'),
2023-03-13 09:37:22 +01:00
}).then(() => {
fetchInstance(true);
2023-03-13 09:37:22 +01:00
});
}
const headerTabs = computed(() => []);
2023-03-13 09:37:22 +01:00
definePageMetadata(() => ({
2023-03-13 09:37:22 +01:00
title: i18n.ts.moderation,
2024-06-21 14:20:42 +02:00
icon: 'ti ti-shield',
}));
2023-03-13 09:37:22 +01:00
</script>
<style lang="scss" module>
.footer {
-webkit-backdrop-filter: var(--blur, blur(15px));
backdrop-filter: var(--blur, blur(15px));
}
</style>