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:
1 parent
02b4c72233
commit
4e88f11ced
15 files changed
+193
-31
No files matched your search
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user