impr: moderation experience (#587)

* feat: display filters on the top

* feat: add grid view for modlog cards

* misc: add user modlog button

* fix: add pageination to moderation page

* feat: make reply reason save
This commit is contained in:
Xylight authored and GitHub committed 2025-06-17 20:49:07 -07:00
1 parent 02b4c72233
commit 4e88f11ced
15 files changed
+193 -31

No files matched your search

@@ -13,6 +13,7 @@
instance?: string | undefined
listing_type?: ListingType
showWhenEmpty?: boolean
placeholder?: string
// eslint-disable-next-line
onselect?: (item: any) => void
}
+1 -1
View File
@@ -134,7 +134,7 @@
<div class="flex flex-row flex-wrap gap-1">
<Link highlight href="/modlog">
{$t('routes.modlog')}
{$t('routes.modlog.title')}
</Link>
•
<Link highlight href="/legal">
@@ -5,6 +5,7 @@
Fire,
Icon,
Megaphone,
Newspaper,
ShieldExclamation,
Trash,
} from 'svelte-hero-icons'
@@ -88,6 +89,18 @@
? $t('moderation.unfeature')
: $t('moderation.feature')}
</MenuButton>
<MenuButton color="success-subtle" href="/modlog?user={item.creator.id}">
<Icon src={Newspaper} size="16" micro />
{$t('moderation.modlog.user')}
</MenuButton>
<MenuButton
color="success-subtle"
href="/modlog?comment={item.comment.id}"
>
<Icon src={Newspaper} size="16" micro />
{$t('moderation.modlog.comment')}
</MenuButton>
{/if}
{/if}
@@ -11,6 +11,7 @@
LockClosed,
LockOpen,
Megaphone,
Newspaper,
ShieldExclamation,
Trash,
} from 'svelte-hero-icons'
@@ -148,6 +149,14 @@
? $t('moderation.ban.unbanFromCommunity')
: $t('moderation.ban.banFromCommunity')}
</MenuButton>
<MenuButton color="success-subtle" href="/modlog?user={item.creator.id}">
<Icon src={Newspaper} size="16" micro />
{$t('moderation.modlog.user')}
</MenuButton>
<MenuButton color="success-subtle" href="/modlog?post={item.post.id}">
<Icon src={Newspaper} size="16" micro />
{$t('moderation.modlog.post')}
</MenuButton>
{/if}
{/if}
{#if profile.data?.user && isAdmin(profile.data.user)}
@@ -32,11 +32,21 @@
}: Props = $props()
let reason = $state('')
let commentReason: boolean = $state(false)
let privateMessage: boolean = $state(false)
let commentReason: boolean = $state(
settings.moderation.defaultRemoveAction != null,
)
let privateMessage: boolean = $state(
settings.moderation.defaultRemoveAction == 'message',
)
let loading = $state(false)
let preset = $state(settings.moderation.presets[0]?.content ?? '')
$effect(() => {
if (!commentReason) settings.moderation.defaultRemoveAction = null
else if (privateMessage) settings.moderation.defaultRemoveAction = 'message'
else settings.moderation.defaultRemoveAction = 'comment'
})
let removed = $derived(
item
? isCommentView(item)
@@ -163,7 +173,6 @@
const resetText = () => {
reason = ''
commentReason = false
}
run(() => {
+10 -2
View File
@@ -207,7 +207,10 @@
"footer": "{{users:number}} active {{users; 1:user; default:users;}}",
"endFeed": "You have reached the end of {{community_name; undefined:the feed.; default:{{community_name}}.}}"
},
"modlog": "Modlog",
"modlog": {
"title": "Modlog",
"filters": "Filters"
},
"instances": "Instances",
"legal": {
"title": "Legal",
@@ -603,7 +606,12 @@
"labelInstanceOnly": "Moderation (Instance Only)",
"feature": "Feature",
"unfeature": "Unfeature",
"votes": "Votes"
"votes": "Votes",
"modlog": {
"user": "User moderation log",
"post": "Post moderation log",
"comment": "Comment moderation log"
}
},
"common": {
"back": "Back",
+3 -1
View File
@@ -59,6 +59,7 @@ interface Settings {
nsfwBlur: boolean
moderation: {
presets: Preset[]
defaultRemoveAction: 'comment' | 'message' | null
}
randomPlaceholders: boolean
modlogCardView: boolean | undefined
@@ -102,7 +103,7 @@ interface Settings {
}
export const defaultSettings: Settings = {
settingsVer: 4,
settingsVer: 5,
expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? true,
markReadPosts: toBool(env.PUBLIC_MARK_READ_POSTS) ?? true,
showInstances: {
@@ -138,6 +139,7 @@ export const defaultSettings: Settings = {
content: `Your submission in *"{{post}}"* was removed for {{reason}}.`,
},
],
defaultRemoveAction: null,
},
randomPlaceholders: toBool(env.PUBLIC_RANDOM_PLACEHOLDERS) ?? false,
modlogCardView: toBool(env.PUBLIC_MODLOG_CARD_VIEW) ?? undefined,
+7
View File
@@ -13,6 +13,7 @@
import { Check, Funnel, Icon, Inbox } from 'svelte-hero-icons'
import { fly } from 'svelte/transition'
import Report from './Report.svelte'
import Pageination from '$lib/components/ui/Pageination.svelte'
let { data = $bindable() } = $props()
@@ -118,6 +119,11 @@
</div>
{/each}
</div>
<Pageination
page={data.page}
href={current => `?page=${current}`}
hasMore={data.items.value.length >= 20}
/>
{:else}
<Placeholder
icon={Inbox}
@@ -125,3 +131,4 @@
description={$t('routes.moderation.empty.description')}
/>
{/if}
<div class="h-4"></div>
+97 -13
View File
@@ -23,6 +23,12 @@
import ModlogItemCard from './item/ModlogItemCard.svelte'
import ModlogItemTable from './item/ModlogItemTable.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/i18n/translations'
import { client } from '$lib/lemmy.svelte'
import Spinner from 'mono-svelte/loader/Spinner.svelte'
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import { postLink } from '$lib/components/lemmy/post/helpers'
let { data = $bindable() } = $props()
@@ -41,11 +47,91 @@
</script>
<svelte:head>
<title>Modlog</title>
<title>{$t('routes.modlog.title')}</title>
</svelte:head>
<div class="flex flex-col gap-4">
<Header pageHeader>Modlog</Header>
<Header pageHeader>
{$t('routes.modlog.title')}
{#snippet extended()}
<span class="font-medium text-lg">{$t('routes.modlog.filters')}</span>
<ul class="font-normal flex flex-col gap-2 mt-2">
{#if data.params.community}
<li>
<span class="text-sm text-slate-600 dark:text-zinc-400">
{$t('form.post.community')}
</span>
{#await client().getCommunity({ id: data.params.community })}
<Spinner width={24} />
{:then community}
<CommunityLink community={community.community_view.community} />
{/await}
</li>
{/if}
{#if data.params.user}
<li>
<span class="text-sm text-slate-600 dark:text-zinc-400">
{$t('routes.admin.applications.user')}
</span>
{#await client().getPersonDetails( { person_id: data.params.user, limit: 1 }, )}
<Spinner width={24} />
{:then person}
<UserLink class="inline" user={person.person_view.person} />
{/await}
</li>
{/if}
{#if data.params.moderator}
<li>
<span class="text-sm text-slate-600 dark:text-zinc-400">
<!--TODO add translation key-->
Moderator
</span>
{#await client().getPersonDetails( { person_id: data.params.moderator, limit: 1 }, )}
<Spinner width={24} />
{:then person}
<UserLink class="inline" user={person.person_view.person} />
{/await}
</li>
{/if}
{#if data.params.post}
<li>
<span class="text-sm text-slate-600 dark:text-zinc-400">
<!--TODO add translation key-->
{$t('nav.create.post')}
</span>
{#await client().getPost({ id: data.params.post })}
<Spinner width={24} />
{:then post}
<a
class="hover:underline block"
href={postLink(post.post_view.post)}
>
{post.post_view.post.name}
</a>
{/await}
</li>
{/if}
{#if data.params.comment}
<li>
<span class="text-sm text-slate-600 dark:text-zinc-400">
<!--TODO add translation key-->
{$t('moderation.removeSubmission.comment')}
</span>
{#await client().getComment({ id: data.params.comment })}
<Spinner width={24} />
{:then comment}
<a
class="hover:underline block"
href="/comment/{data.params.comment}"
>
{comment.comment_view.comment.content.slice(1, 200)}...
</a>
{/await}
</li>
{/if}
</ul>
{/snippet}
</Header>
<div class="flex flex-row flex-wrap gap-2">
<Select
bind:value={data.type}
@@ -92,7 +178,6 @@
<ObjectAutocomplete
type="instance"
placeholder="Filter by instance"
jwt={profile.data?.jwt}
showWhenEmpty={true}
label="Instance"
class="flex-1"
@@ -110,7 +195,6 @@
/>
<ObjectAutocomplete
placeholder="Filter by community"
jwt={profile.data?.jwt}
listing_type="All"
showWhenEmpty={true}
label="Community"
@@ -169,7 +253,7 @@
</div>
{#if data.modlog && data.modlog.length > 0}
{#if settings.modlogCardView ?? !window.matchMedia('(min-width: 1600px)').matches}
<div class="flex flex-col gap-4">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
{#each data.modlog as modlog (modlog)}
<ModlogItemCard item={modlog} />
{/each}
@@ -181,14 +265,14 @@
style="min-width: 800px;"
>
<colgroup class="table-fixed">
<col width="8%" />
<col width="18%" />
<col width="12%" class="overflow-x-auto" />
<col width="8%" />
<col width="10%" />
<col width="18%" />
<col width="20%" />
<col width="20%" />
<col />
<col />
<col class="overflow-x-auto" />
<col />
<col />
<col />
<col />
<col />
</colgroup>
<thead class="text-left sticky top-0">
<tr class="rounded-t-lg overflow-hidden">
+13
View File
@@ -208,9 +208,13 @@ export const _toModLog = (item: ModAction): ModLog => {
export async function load({ url }) {
const instance = url.searchParams.get('instance') || undefined
const community = Number(url.searchParams.get('community')) || undefined
const user = Number(url.searchParams.get('user')) || undefined
const modId = Number(url.searchParams.get('mod_id')) || undefined
const postId = Number(url.searchParams.get('post')) || undefined
const commentId = Number(url.searchParams.get('comment')) || undefined
const page = Number(url.searchParams.get('page')) || 1
const type: ModlogActionType =
(url.searchParams.get('type') as ModlogActionType) || 'All'
@@ -222,6 +226,8 @@ export async function load({ url }) {
page: page,
mod_person_id: modId,
other_person_id: user,
post_id: postId,
comment_id: commentId,
})
const moderation = [
@@ -258,5 +264,12 @@ export async function load({ url }) {
community: community ? moderationActions[0]?.community?.title : undefined,
moderator: modId ? moderationActions[0]?.moderator?.name : undefined,
},
params: {
user: user,
community: community,
moderator: modId,
post: postId,
comment: commentId,
},
}
}
@@ -14,7 +14,7 @@
</script>
<tr class="">
<td>
<td style="width: 10%;">
<span>
<RelativeDate date={new Date(item.timestamp)} />
</span>
@@ -41,7 +41,9 @@
<div class="w-full h-full flex flex-col justify-center mx-auto max-w-xl gap-6">
<header class="space-y-1">
<div class="font-mono bg-zinc-950 rounded-xs p-0.5 px-1 w-max">
<div
class="font-mono bg-slate-100 dark:bg-zinc-950 rounded-xs p-0.5 px-1 w-max"
>
{page.params.instance}/post/{page.params.id}
</div>
<Header>
+1
View File
@@ -0,0 +1 @@
You are being redirected.
+5
View File
@@ -0,0 +1,5 @@
import { redirect } from '@sveltejs/kit'
export async function load() {
redirect(302, '/moderation')
}
+17 -9
View File
@@ -38,6 +38,7 @@
Envelope,
Fire,
Icon,
Newspaper,
NoSymbol,
PencilSquare,
ShieldExclamation,
@@ -151,7 +152,7 @@
<div class="flex flex-col gap-4 max-w-full w-full">
{#if !inline}
<Header pageHeader>
<Header pageHeader class="tracking-normal!">
<div class="w-full">
<EntityHeader
avatar={data.person_view.value.person.avatar}
@@ -210,37 +211,44 @@
{/if}
{#snippet actions()}
{#if profile.data?.user && profile.data.jwt && data.person_view.value.person.id != profile.data.user.local_user_view.person.id}
<div class="flex items-center gap-2 w-full">
<div class="flex items-center gap-2 w-full flex-wrap">
<Button
size="square-md"
size="sm"
rounding="pill"
color="secondary"
href="/inbox/messages/{data.person_view.value.person.id}"
title="Message"
>
{#snippet prefix()}
<Icon solid size="16" src={Envelope} />
<Icon micro size="16" src={Envelope} />
{/snippet}
{$t('content.message')}
</Button>
{#if data.person_view.value.person.matrix_user_id}
<Button
size="square-md"
size="sm"
rounding="pill"
color="secondary"
href="https://matrix.to/#/{data.person_view.value.person
.matrix_user_id}"
title="Matrix User"
>
{#snippet prefix()}
<Icon solid size="16" src={AtSymbol} />
{/snippet}
{$t('form.profile.matrix')}
</Button>
{/if}
{#if isAdmin(profile.data?.user)}
<Menu class="ml-auto" placement="bottom-end">
{#snippet target()}
<Button size="square-md">
<Button size="sm" rounding="pill">
<ShieldIcon width={16} filled />
{$t('moderation.label')}
</Button>
{/snippet}
<MenuButton color="success-subtle">
<Icon src={Newspaper} size="16" micro />
{$t('moderation.modlog.user')}
</MenuButton>
<MenuButton
color="danger-subtle"
onclick={() =>
@@ -267,7 +275,7 @@
{/if}
<Menu placement="bottom-end">
{#snippet target()}
<Button size="square-md">
<Button size="custom" class="h-7 w-7" rounding="pill">
{#snippet prefix()}
<Icon src={EllipsisHorizontal} size="16" mini />
{/snippet}