feat: add mark page resolved button to moderation
This commit is contained in:
4 files changed
+65
-6
No files matched your search
@@ -17,5 +17,5 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
class="bg-primary-900 dark:bg-primary-100 h-1 rounded-full"
|
class="bg-primary-900 dark:bg-primary-100 h-1 rounded-full"
|
||||||
style="width: {tween.current * 100}%;"
|
style="width: {tween.current >= 0 ? tween.current * 100 : 0}%;"
|
||||||
></div>
|
></div>
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
title={label}
|
title={label}
|
||||||
style="transition-property: background-color, filter;"
|
style="transition-property: background-color, filter;"
|
||||||
>
|
>
|
||||||
|
{#snippet prefix()}
|
||||||
{#if icon}
|
{#if icon}
|
||||||
<Icon
|
<Icon
|
||||||
src={icon}
|
src={icon}
|
||||||
@@ -57,6 +58,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
{@render customIcon?.({ size: isPanel ? 16 : 18, isSelected })}
|
{@render customIcon?.({ size: isPanel ? 16 : 18, isSelected })}
|
||||||
{/if}
|
{/if}
|
||||||
|
{/snippet}
|
||||||
<span class="hidden {adaptive ? '@3xl:block' : ''}">{label}</span>
|
<span class="hidden {adaptive ? '@3xl:block' : ''}">{label}</span>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -312,7 +312,9 @@
|
|||||||
"resolve": "Resolve",
|
"resolve": "Resolve",
|
||||||
"resolved": "Resolved",
|
"resolved": "Resolved",
|
||||||
"unresolve": "Unresolve",
|
"unresolve": "Unresolve",
|
||||||
"resolvedBy": "Resolved by"
|
"resolvedBy": "Resolved by",
|
||||||
|
"markAll": "Mark page resolved",
|
||||||
|
"markAllComplete": "Batch action completed."
|
||||||
},
|
},
|
||||||
"admin": {
|
"admin": {
|
||||||
"title": "Administration",
|
"title": "Administration",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import MultiSelect from '$lib/components/input/Switch.svelte'
|
import MultiSelect from '$lib/components/input/Switch.svelte'
|
||||||
import { page } from '$app/state'
|
import { page } from '$app/state'
|
||||||
import {
|
import {
|
||||||
|
Check,
|
||||||
EnvelopeOpen,
|
EnvelopeOpen,
|
||||||
Funnel,
|
Funnel,
|
||||||
Icon,
|
Icon,
|
||||||
@@ -13,11 +14,14 @@
|
|||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
import { searchParam } from '$lib/util.svelte.js'
|
import { searchParam } from '$lib/util.svelte.js'
|
||||||
import { Button, Material, Select } from 'mono-svelte'
|
import { Button, Material, Select, toast } from 'mono-svelte'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||||
import { tick } from 'svelte'
|
import { tick } from 'svelte'
|
||||||
|
import ProgressBar from '$lib/components/ui/ProgressBar.svelte'
|
||||||
|
import { client } from '$lib/lemmy.svelte'
|
||||||
|
import { goto } from '$app/navigation'
|
||||||
|
|
||||||
let { data = $bindable() } = $props()
|
let { data = $bindable() } = $props()
|
||||||
|
|
||||||
@@ -26,6 +30,50 @@
|
|||||||
$effect(() => {
|
$effect(() => {
|
||||||
reports = data.items
|
reports = data.items
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let batch = $state({
|
||||||
|
progress: -1,
|
||||||
|
})
|
||||||
|
async function markAllAsResolved() {
|
||||||
|
if (!reports) return
|
||||||
|
batch.progress = 0
|
||||||
|
|
||||||
|
const promises = await Promise.all(
|
||||||
|
reports.map((report) => {
|
||||||
|
switch (report.type) {
|
||||||
|
case 'comment': {
|
||||||
|
const promise = client().resolveCommentReport({
|
||||||
|
report_id: report.id,
|
||||||
|
resolved: true,
|
||||||
|
})
|
||||||
|
promise.then(() => (batch.progress += 1 / reports!.length))
|
||||||
|
return promise
|
||||||
|
}
|
||||||
|
case 'post': {
|
||||||
|
const promise = client().resolvePostReport({
|
||||||
|
report_id: report.id,
|
||||||
|
resolved: true,
|
||||||
|
})
|
||||||
|
promise.then(() => (batch.progress += 1 / reports!.length))
|
||||||
|
return promise
|
||||||
|
}
|
||||||
|
case 'message': {
|
||||||
|
const promise = client().resolvePrivateMessageReport({
|
||||||
|
report_id: report.id,
|
||||||
|
resolved: true,
|
||||||
|
})
|
||||||
|
promise.then(() => (batch.progress += 1 / reports!.length))
|
||||||
|
return promise
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
toast({ content: $t('routes.moderation.markAllComplete'), type: 'success' })
|
||||||
|
await goto(page.url, { invalidateAll: true })
|
||||||
|
|
||||||
|
batch.progress = -1
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="mb-4 flex flex-col gap-4">
|
<div class="mb-4 flex flex-col gap-4">
|
||||||
@@ -49,14 +97,21 @@
|
|||||||
<Option value="all">{$t('filter.location.all')}</Option>
|
<Option value="all">{$t('filter.location.all')}</Option>
|
||||||
<Option value="unread">{$t('filter.unread')}</Option>
|
<Option value="unread">{$t('filter.unread')}</Option>
|
||||||
</Select>
|
</Select>
|
||||||
<Button href="/modlog" class="h-max ml-auto">
|
<Button
|
||||||
<Icon src={Newspaper} size="16" mini />
|
loading={batch.progress >= 0}
|
||||||
{$t('routes.modlog')}
|
disabled={batch.progress >= 0}
|
||||||
|
onclick={markAllAsResolved}
|
||||||
|
class="h-max ml-auto"
|
||||||
|
rounding="xl"
|
||||||
|
>
|
||||||
|
<Icon src={Check} size="16" mini />
|
||||||
|
{$t('routes.moderation.markAll')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Header>
|
</Header>
|
||||||
</div>
|
</div>
|
||||||
|
<ProgressBar progress={batch.progress} />
|
||||||
{#if reports && reports.length > 0}
|
{#if reports && reports.length > 0}
|
||||||
<div
|
<div
|
||||||
class="flex flex-col *:py-4 divide-y divide-slate-200 dark:divide-zinc-800"
|
class="flex flex-col *:py-4 divide-y divide-slate-200 dark:divide-zinc-800"
|
||||||
|
|||||||
Reference in new issue
Block a user