feat: 通報の即時解決機能の改善 (#132)

* feat: 通報の即時解決機能にplaceholderを設定

* PRから
2134a79353
7c7ca57bd7
de88d6099b
This commit is contained in:
まっちゃとーにゅ 2023-08-03 04:51:02 +09:00 committed by GitHub
parent 233d967b82
commit 33e21dd2ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 19 deletions

View file

@ -108,15 +108,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
const now = new Date(); const now = new Date();
let expirationDate: Date | null = new Date(); let expirationDate: Date | null = new Date();
const previousMonth = expirationDate.getUTCMonth();
(ps.expiresAt === '1hour' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 hour')); } : (ps.expiresAt === '1hour' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 hour')); } :
ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } : ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } :
ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } : ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } :
ps.expiresAt === '1week' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 week')); } : ps.expiresAt === '1week' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 week')); } :
ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 1 + 1) / 12))); } : ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 1 + 1) / 12))); } :
ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 3 + 1) / 12 ))); } : ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 3 + 1) / 12))); } :
ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 6 + 1) / 12))); } : ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 6 + 1) / 12))); } :
ps.expiresAt === '1year' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 year')); } : function () { expirationDate = null; })(); ps.expiresAt === '1year' ? function () { expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + 1); } : function () { expirationDate = null; })();
return await this.abuseReportResolverRepository.insert({ return await this.abuseReportResolverRepository.insert({
id: this.idService.genId(), id: this.idService.genId(),

View file

@ -95,14 +95,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (ps.forward) properties.forward = ps.forward; if (ps.forward) properties.forward = ps.forward;
if (ps.expiresAt) { if (ps.expiresAt) {
let expirationDate: Date | null = new Date(); let expirationDate: Date | null = new Date();
const previousMonth = expirationDate.getUTCMonth();
(ps.expiresAt === '1hour' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 hour')); } : (ps.expiresAt === '1hour' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 hour')); } :
ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } : ps.expiresAt === '12hours' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('12 hours')); } :
ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } : ps.expiresAt === '1day' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 day')); } :
ps.expiresAt === '1week' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 week')); } : ps.expiresAt === '1week' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 week')); } :
ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 1 + 1) / 12))); } : ps.expiresAt === '1month' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 1 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 1 + 1) / 12))); } :
ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 3 + 1) / 12))); } : ps.expiresAt === '3months' ? function () {expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 3 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 3 + 1) / 12))); } :
ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((expirationDate!.getUTCMonth() + 6 + 1) / 12))); } : ps.expiresAt === '6months' ? function () { expirationDate!.setUTCMonth((expirationDate!.getUTCMonth() + 6 + 1) % 12 - 1); expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + (Math.floor((previousMonth + 6 + 1) / 12))); } :
ps.expiresAt === '1year' ? function () { expirationDate!.setTime(expirationDate!.getTime() + ms('1 year')); } : function () { expirationDate = null; })(); ps.expiresAt === '1year' ? function () { expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + 1); } : function () { expirationDate = null; })();
properties.expiresAt = ps.expiresAt; properties.expiresAt = ps.expiresAt;
properties.expirationDate = expirationDate; properties.expirationDate = expirationDate;

View file

@ -5,18 +5,18 @@
</MkInput> </MkInput>
<div> <div>
<div :class="$style.label">{{ i18n.ts._abuse._resolver.targetUserPattern }}</div> <div :class="$style.label">{{ i18n.ts._abuse._resolver.targetUserPattern }}</div>
<PrismEditor v-model="value.targetUserPattern" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :readonly="!props.editable"/> <PrismEditor v-model="value.targetUserPattern" placeholder="^(LocalUser|RemoteUser@RemoteHost)$" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :ignoreTabKey="true" :readonly="!props.editable"/>
</div> </div>
<div> <div>
<div :class="$style.label">{{ i18n.ts._abuse._resolver.reporterPattern }}</div> <div :class="$style.label">{{ i18n.ts._abuse._resolver.reporterPattern }}</div>
<PrismEditor v-model="value.reporterPattern" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :readonly="!props.editable"/> <PrismEditor v-model="value.reporterPattern" placeholder="^(LocalUser|.*@RemoteHost)$" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :ignoreTabKey="true" :readonly="!props.editable"/>
</div> </div>
<div> <div>
<div :class="$style.label">{{ i18n.ts._abuse._resolver.reportContentPattern }}</div> <div :class="$style.label">{{ i18n.ts._abuse._resolver.reportContentPattern }}</div>
<PrismEditor v-model="value.reportContentPattern" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :readonly="!props.editable"/> <PrismEditor v-model="value.reportContentPattern" placeholder=".*" class="_code code" :class="$style.highlight" :highlight="highlighter" :lineNumbers="false" :ignoreTabKey="true" :readonly="!props.editable"/>
</div> </div>
<MkSelect v-model="value.expiresAt" :disabled="!props.editable"> <MkSelect v-model="value.expiresAt" :disabled="!props.editable">
<template #label>{{ i18n.ts._abuse._resolver.expiresAt }}<span v-if="expirationDate" style="float: right;">{{ expirationDate }}</span></template> <template #label>{{ i18n.ts._abuse._resolver.expiresAt }}<span v-if="expirationDate" style="float: right;"><MkDate :time="expirationDate" mode="absolute">{{ expirationDate }}</MkDate></span></template>
<option value="1hour">{{ i18n.ts._abuse._resolver['1hour'] }}</option> <option value="1hour">{{ i18n.ts._abuse._resolver['1hour'] }}</option>
<option value="12hours">{{ i18n.ts._abuse._resolver['12hours'] }}</option> <option value="12hours">{{ i18n.ts._abuse._resolver['12hours'] }}</option>
<option value="1day">{{ i18n.ts._abuse._resolver['1day'] }}</option> <option value="1day">{{ i18n.ts._abuse._resolver['1day'] }}</option>
@ -70,7 +70,7 @@ const props = defineProps<{
previousExpiresAt?: string; previousExpiresAt?: string;
} }
}>(); }>();
let expirationDate: string | null = $ref(null); let expirationDate: Date | null = $ref(null);
type NonNullType<T> = { type NonNullType<T> = {
[P in keyof T]: NonNullable<T[P]> [P in keyof T]: NonNullable<T[P]>
@ -113,7 +113,7 @@ function highlighter(code) {
function renderExpirationDate(empty = false) { function renderExpirationDate(empty = false) {
if (value.value.expirationDate && !empty) { if (value.value.expirationDate && !empty) {
expirationDate = new Date(value.value.expirationDate).toLocaleString(); expirationDate = new Date(value.value.expirationDate);
} else { } else {
expirationDate = null; expirationDate = null;
} }

View file

@ -57,7 +57,7 @@
<MkAbuseReportResolver v-model="editingResolver" :data="(resolver as any)" :editable="editableResolver === resolver.id"> <MkAbuseReportResolver v-model="editingResolver" :data="(resolver as any)" :editable="editableResolver === resolver.id">
<template #button> <template #button>
<div v-if="editableResolver !== resolver.id"> <div v-if="editableResolver !== resolver.id">
<MkButton primary inline :class="$style.button-margin" @click="edit(resolver.id)"><i class="ti ti-pencil"></i> {{ i18n.ts.edit }}</MkButton> <MkButton primary inline :class="$style.buttonMargin" @click="edit(resolver.id)"><i class="ti ti-pencil"></i> {{ i18n.ts.edit }}</MkButton>
<MkButton danger inline @click="deleteResolver(resolver.id)"><i class="ti ti-trash"></i> {{ i18n.ts.remove }}</MkButton> <MkButton danger inline @click="deleteResolver(resolver.id)"><i class="ti ti-trash"></i> {{ i18n.ts.remove }}</MkButton>
</div> </div>
<div v-else> <div v-else>
@ -214,13 +214,13 @@ definePageMetadata({
flex: 1; flex: 1;
} }
.button-margin { .buttonMargin {
margin-right: 6px; margin-right: 6px;
} }
.state { .state {
@extend .input-base; @extend .input-base;
@extend .button-margin; @extend .buttonMargin;
} }
.reporterOrigin { .reporterOrigin {
@extend .input-base; @extend .input-base;
@ -228,7 +228,7 @@ definePageMetadata({
.targetUserOrigin { .targetUserOrigin {
@extend .input-base; @extend .input-base;
@extend .button-margin; @extend .buttonMargin;
} }
.margin { .margin {