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" none: "Publishing"
manuallySuspended: "Manually suspended" manuallySuspended: "Manually suspended"
goneSuspended: "Server is suspended due to server deletion" 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: _bubbleGame:
howToPlay: "How to play" howToPlay: "How to play"
hold: "Hold" hold: "Hold"

View file

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