merge: Replace "suspend delivery" button with a toggle (resolves #725) (!677)

View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/677

Closes #725

Approved-by: dakkar <dakkar@thenautilus.net>
Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
Hazelnoot 2024-10-11 18:03:12 +00:00
commit 883168bc00
2 changed files with 7 additions and 15 deletions

View file

@ -1359,7 +1359,7 @@ _delivery:
none: "Publishing"
manuallySuspended: "Manually suspended"
goneSuspended: "Server is suspended due to server deletion"
autoSuspendedForNotResponding: "Server is suspended due to no responding"
autoSuspendedForNotResponding: "Server is suspended due to not responding"
_bubbleGame:
howToPlay: "How to play"
hold: "Hold"

View file

@ -46,9 +46,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="_buttons">
<MkButton inline :disabled="!instance" danger @click="deleteAllFiles">{{ i18n.ts.deleteAllFiles }}</MkButton>
<MkButton inline :disabled="!instance" danger @click="severAllFollowRelations">{{ i18n.ts.severAllFollowRelations }}</MkButton>
<MkButton v-if="suspensionState === 'none'" inline :disabled="!instance" danger @click="stopDelivery">{{ i18n.ts._delivery.stop }}</MkButton>
<MkButton v-if="suspensionState !== 'none'" inline :disabled="!instance" @click="resumeDelivery">{{ i18n.ts._delivery.resume }}</MkButton>
</div>
<MkSwitch v-model="isSuspended" :disabled="!instance" @update:modelValue="toggleSuspended">{{ i18n.ts._delivery.stop }}</MkSwitch>
<MkInfo v-if="isBaseBlocked" warn>{{ i18n.ts.blockedByBase }}</MkInfo>
<MkSwitch v-model="isBlocked" :disabled="!meta || !instance || isBaseBlocked" @update:modelValue="toggleBlock">{{ i18n.ts.blockThisInstance }}</MkSwitch>
<MkInfo v-if="isBaseSilenced" warn>{{ i18n.ts.silencedByBase }}</MkInfo>
@ -206,6 +205,7 @@ const chartSrc = ref('instance-requests');
const meta = ref<Misskey.entities.AdminMetaResponse | null>(null);
const instance = ref<Misskey.entities.FederationInstance | null>(null);
const suspensionState = ref<'none' | 'manuallySuspended' | 'goneSuspended' | 'autoSuspendedForNotResponding'>('none');
const isSuspended = ref(false);
const isBlocked = ref(false);
const isSilenced = ref(false);
const isNSFW = ref(false);
@ -272,6 +272,7 @@ async function fetch(): Promise<void> {
host: props.host,
});
suspensionState.value = instance.value?.suspensionState ?? 'none';
isSuspended.value = instance.value?.suspensionState !== 'none';
isBlocked.value = instance.value?.isBlocked ?? false;
isSilenced.value = instance.value?.isSilenced ?? false;
isNSFW.value = instance.value?.isNSFW ?? false;
@ -310,21 +311,12 @@ async function toggleMediaSilenced(): Promise<void> {
});
}
async function stopDelivery(): Promise<void> {
async function toggleSuspended(): Promise<void> {
if (!instance.value) throw new Error('No instance?');
suspensionState.value = 'manuallySuspended';
suspensionState.value = isSuspended.value ? 'manuallySuspended' : 'none';
await misskeyApi('admin/federation/update-instance', {
host: instance.value.host,
isSuspended: true,
});
}
async function resumeDelivery(): Promise<void> {
if (!instance.value) throw new Error('No instance?');
suspensionState.value = 'none';
await misskeyApi('admin/federation/update-instance', {
host: instance.value.host,
isSuspended: false,
isSuspended: isSuspended.value,
});
}