summaryrefslogtreecommitdiff
path: root/packages/frontend/src/pages/admin/moderation.vue
blob: 1ee07d383e6488aab636a4fe41f1bbb478bfa21b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<template>
<div>
	<MkStickyContainer>
		<template #header><XHeader :tabs="headerTabs"/></template>
		<MkSpacer :content-max="700" :margin-min="16" :margin-max="32">
			<FormLink to="/admin/server-rules">{{ i18n.ts.serverRules }}</FormLink>
			<FormSuspense :p="init">
				<div class="_gaps_m">
					<FormSection first>
						<div class="_gaps_m">
							<MkInput v-model="tosUrl">
								<template #prefix><i class="ti ti-link"></i></template>
								<template #label>{{ i18n.ts.tosUrl }}</template>
							</MkInput>
							<MkTextarea v-model="preservedUsernames">
								<template #label>{{ i18n.ts.preservedUsernames }}</template>
								<template #caption>{{ i18n.ts.preservedUsernamesDescription }}</template>
							</MkTextarea>
							<MkTextarea v-model="sensitiveWords">
								<template #label>{{ i18n.ts.sensitiveWords }}</template>
								<template #caption>{{ i18n.ts.sensitiveWordsDescription }}</template>
							</MkTextarea>
						</div>
					</FormSection>
				</div>
			</FormSuspense>
		</MkSpacer>
		<template #footer>
			<div :class="$style.footer">
				<MkSpacer :content-max="700" :margin-min="16" :margin-max="16">
					<MkButton primary rounded @click="save"><i class="ti ti-check"></i> {{ i18n.ts.save }}</MkButton>
				</MkSpacer>
			</div>
		</template>
	</MkStickyContainer>
</div>
</template>

<script lang="ts" setup>
import { } from 'vue';
import XHeader from './_header_.vue';
import MkSwitch from '@/components/MkSwitch.vue';
import MkInput from '@/components/MkInput.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import FormSection from '@/components/form/section.vue';
import FormSplit from '@/components/form/split.vue';
import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os';
import { fetchInstance } from '@/instance';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import MkButton from '@/components/MkButton.vue';
import FormLink from '@/components/form/link.vue';

let sensitiveWords: string = $ref('');
let preservedUsernames: string = $ref('');
let tosUrl: string | null = $ref(null);

async function init() {
	const meta = await os.api('admin/meta');
	sensitiveWords = meta.sensitiveWords.join('\n');
	preservedUsernames = meta.preservedUsernames.join('\n');
	tosUrl = meta.tosUrl;
}

function save() {
	os.apiWithDialog('admin/update-meta', {
		tosUrl,
		sensitiveWords: sensitiveWords.split('\n'),
		preservedUsernames: preservedUsernames.split('\n'),
	}).then(() => {
		fetchInstance();
	});
}

const headerTabs = $computed(() => []);

definePageMetadata({
	title: i18n.ts.moderation,
	icon: 'ti ti-shield',
});
</script>

<style lang="scss" module>
.footer {
	-webkit-backdrop-filter: var(--blur, blur(15px));
	backdrop-filter: var(--blur, blur(15px));
}
</style>