client: improve suspend toggle

This commit is contained in:
Johann150 2022-11-13 01:12:05 +01:00
parent 56033c26f0
commit 0571a0843c
Signed by untrusted user: Johann150
GPG Key ID: 9EE6577A2A06F8F1
2 changed files with 27 additions and 6 deletions

View File

@ -190,7 +190,9 @@ charts: "Charts"
perHour: "Per Hour" perHour: "Per Hour"
perDay: "Per Day" perDay: "Per Day"
stopActivityDelivery: "Stop sending activities" stopActivityDelivery: "Stop sending activities"
stopActivityDeliveryDescription: "Local activities will not be sent to this instance. Receiving activities works as before."
blockThisInstance: "Block this instance" blockThisInstance: "Block this instance"
blockThisInstanceDescription: "Local activites will not be sent to this instance. Activites from this instance will be discarded."
operations: "Operations" operations: "Operations"
software: "Software" software: "Software"
version: "Version" version: "Version"

View File

@ -26,8 +26,27 @@
<FormSection v-if="iAmModerator"> <FormSection v-if="iAmModerator">
<template #label>Moderation</template> <template #label>Moderation</template>
<FormSwitch v-model="suspended" class="_formBlock" @update:modelValue="toggleSuspend">{{ i18n.ts.stopActivityDelivery }}</FormSwitch> <FormSwitch
<FormSwitch v-model="isBlocked" class="_formBlock" @update:modelValue="toggleBlock">{{ i18n.ts.blockThisInstance }}</FormSwitch> :model-value="suspended || isBlocked"
@update:model-value="newValue => {suspended = newValue; toggleSuspend() }"
:disabled="isBlocked"
class="_formBlock"
>
{{ i18n.ts.stopActivityDelivery }}
<template #caption>
{{ i18n.ts.stopActivityDeliveryDescription }}
</template>
</FormSwitch>
<FormSwitch
v-model="isBlocked"
@update:modelValue="toggleBlock"
class="_formBlock"
>
{{ i18n.ts.blockThisInstance }}
<template #caption>
{{ i18n.ts.blockThisInstanceDescription }}
</template>
</FormSwitch>
<MkButton @click="refreshMetadata"><i class="fas fa-refresh"></i> Refresh metadata</MkButton> <MkButton @click="refreshMetadata"><i class="fas fa-refresh"></i> Refresh metadata</MkButton>
</FormSection> </FormSection>
@ -152,7 +171,7 @@ const usersPagination = {
offsetMode: true, offsetMode: true,
}; };
async function fetch() { async function fetch(): Promise<void> {
instance = await os.api('federation/show-instance', { instance = await os.api('federation/show-instance', {
host: props.host, host: props.host,
}); });
@ -160,21 +179,21 @@ async function fetch() {
isBlocked = instance.isBlocked; isBlocked = instance.isBlocked;
} }
async function toggleBlock(ev) { async function toggleBlock(): Promise<void> {
if (meta == null) return; if (meta == null) return;
await os.api('admin/update-meta', { await os.api('admin/update-meta', {
blockedHosts: isBlocked ? meta.blockedHosts.concat([instance.host]) : meta.blockedHosts.filter(x => x !== instance.host), blockedHosts: isBlocked ? meta.blockedHosts.concat([instance.host]) : meta.blockedHosts.filter(x => x !== instance.host),
}); });
} }
async function toggleSuspend(v) { async function toggleSuspend(): Promise<void> {
await os.api('admin/federation/update-instance', { await os.api('admin/federation/update-instance', {
host: instance.host, host: instance.host,
isSuspended: suspended, isSuspended: suspended,
}); });
} }
function refreshMetadata() { function refreshMetadata(): void {
os.api('admin/federation/refresh-remote-instance-metadata', { os.api('admin/federation/refresh-remote-instance-metadata', {
host: instance.host, host: instance.host,
}); });