design: make modlog not look like buns in table view
This commit is contained in:
12 files changed
+193
-159
No files matched your search
@@ -1,18 +1,23 @@
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy'
|
||||
|
||||
import { browser } from '$app/environment'
|
||||
import { page } from '$app/state'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import { client } from '$lib/client/lemmy.svelte'
|
||||
import { CommunityLink } from '$lib/components/lemmy/community'
|
||||
import { isAdmin } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
|
||||
import { postLink } from '$lib/components/lemmy/post'
|
||||
import UserAutocomplete from '$lib/components/lemmy/user/UserAutocomplete.svelte'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import { Header } from '$lib/components/ui/layout'
|
||||
import Pageination from '$lib/components/ui/layout/Pageination.svelte'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { settings } from '$lib/settings.svelte.js'
|
||||
import { searchParam } from '$lib/util.svelte.js'
|
||||
import { Button, Select } from 'mono-svelte'
|
||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||
import Spinner from 'mono-svelte/loader/Spinner.svelte'
|
||||
import {
|
||||
Bars3BottomRight,
|
||||
Icon,
|
||||
@@ -22,13 +27,6 @@
|
||||
} from 'svelte-hero-icons'
|
||||
import ModlogItemCard from './item/ModlogItemCard.svelte'
|
||||
import ModlogItemTable from './item/ModlogItemTable.svelte'
|
||||
import { Header } from '$lib/components/ui/layout'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { client } from '$lib/client/lemmy.svelte'
|
||||
import Spinner from 'mono-svelte/loader/Spinner.svelte'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import { CommunityLink } from '$lib/components/lemmy/community'
|
||||
import { postLink } from '$lib/components/lemmy/post'
|
||||
|
||||
let { data = $bindable() } = $props()
|
||||
|
||||
@@ -40,7 +38,7 @@
|
||||
}`,
|
||||
)
|
||||
|
||||
run(() => {
|
||||
$effect(() => {
|
||||
settings.modlogCardView =
|
||||
view == 'true' ? true : view == 'false' ? false : undefined
|
||||
})
|
||||
@@ -58,9 +56,9 @@
|
||||
<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">
|
||||
<div class="text-sm text-slate-600 dark:text-zinc-400">
|
||||
{$t('form.post.community')}
|
||||
</span>
|
||||
</div>
|
||||
{#await client().getCommunity({ id: data.params.community })}
|
||||
<Spinner width={24} />
|
||||
{:then community}
|
||||
@@ -70,9 +68,9 @@
|
||||
{/if}
|
||||
{#if data.params.user}
|
||||
<li>
|
||||
<span class="text-sm text-slate-600 dark:text-zinc-400">
|
||||
<div class="text-sm text-slate-600 dark:text-zinc-400">
|
||||
{$t('routes.admin.applications.user')}
|
||||
</span>
|
||||
</div>
|
||||
{#await client().getPersonDetails( { person_id: data.params.user, limit: 1 }, )}
|
||||
<Spinner width={24} />
|
||||
{:then person}
|
||||
@@ -82,10 +80,10 @@
|
||||
{/if}
|
||||
{#if data.params.moderator}
|
||||
<li>
|
||||
<span class="text-sm text-slate-600 dark:text-zinc-400">
|
||||
<div class="text-sm text-slate-600 dark:text-zinc-400">
|
||||
<!--TODO add translation key-->
|
||||
Moderator
|
||||
</span>
|
||||
</div>
|
||||
{#await client().getPersonDetails( { person_id: data.params.moderator, limit: 1 }, )}
|
||||
<Spinner width={24} />
|
||||
{:then person}
|
||||
@@ -95,10 +93,9 @@
|
||||
{/if}
|
||||
{#if data.params.post}
|
||||
<li>
|
||||
<span class="text-sm text-slate-600 dark:text-zinc-400">
|
||||
<!--TODO add translation key-->
|
||||
<div class="text-sm text-slate-600 dark:text-zinc-400">
|
||||
{$t('nav.create.post')}
|
||||
</span>
|
||||
</div>
|
||||
{#await client().getPost({ id: data.params.post })}
|
||||
<Spinner width={24} />
|
||||
{:then post}
|
||||
@@ -113,10 +110,9 @@
|
||||
{/if}
|
||||
{#if data.params.comment}
|
||||
<li>
|
||||
<span class="text-sm text-slate-600 dark:text-zinc-400">
|
||||
<!--TODO add translation key-->
|
||||
<div class="text-sm text-slate-600 dark:text-zinc-400">
|
||||
{$t('moderation.removeSubmission.comment')}
|
||||
</span>
|
||||
</div>
|
||||
{#await client().getComment({ id: data.params.comment })}
|
||||
<Spinner width={24} />
|
||||
{:then comment}
|
||||
@@ -145,21 +141,21 @@
|
||||
</span>
|
||||
{/snippet}
|
||||
<Option value="All">All</Option>
|
||||
<Option value="ModRemovePost">Remove Post</Option>
|
||||
<Option value="ModLockPost">Lock Post</Option>
|
||||
<Option value="ModFeaturePost">Feature Post</Option>
|
||||
<Option value="ModRemoveComment">Remove Comment</Option>
|
||||
<Option value="ModRemoveCommunity">Remove Community</Option>
|
||||
<Option value="ModBanFromCommunity">Ban From Community</Option>
|
||||
<Option value="ModAddCommunity">Add Moderator</Option>
|
||||
<Option value="ModTransferCommunity">Transfer Community</Option>
|
||||
<Option value="ModAdd">Add Admin</Option>
|
||||
<Option value="ModBan">Ban Admin</Option>
|
||||
<Option value="ModHideCommunity">Hide Community</Option>
|
||||
<Option value="AdminPurgePerson">Purge User</Option>
|
||||
<Option value="AdminPurgeCommunity">Purge Community</Option>
|
||||
<Option value="AdminPurgePost">Purge Post</Option>
|
||||
<Option value="AdminPurgeComment">Purge Comment</Option>
|
||||
<Option value="ModRemovePost">Remove post</Option>
|
||||
<Option value="ModLockPost">Lock post</Option>
|
||||
<Option value="ModFeaturePost">Feature post</Option>
|
||||
<Option value="ModRemoveComment">Remove comment</Option>
|
||||
<Option value="ModRemoveCommunity">Remove community</Option>
|
||||
<Option value="ModBanFromCommunity">Ban from community</Option>
|
||||
<Option value="ModAddCommunity">Add moderator</Option>
|
||||
<Option value="ModTransferCommunity">Transfer community</Option>
|
||||
<Option value="ModAdd">Add admin</Option>
|
||||
<Option value="ModBan">Ban admin</Option>
|
||||
<Option value="ModHideCommunity">Hide community</Option>
|
||||
<Option value="AdminPurgePerson">Purge user</Option>
|
||||
<Option value="AdminPurgeCommunity">Purge community</Option>
|
||||
<Option value="AdminPurgePost">Purge post</Option>
|
||||
<Option value="AdminPurgeComment">Purge comment</Option>
|
||||
</Select>
|
||||
|
||||
<Select bind:value={view} class="w-36">
|
||||
@@ -175,41 +171,25 @@
|
||||
</Select>
|
||||
</div>
|
||||
<div class="flex flex-col md:flex-row md:items-center gap-2 w-full">
|
||||
<ObjectAutocomplete
|
||||
type="instance"
|
||||
placeholder="Filter by instance"
|
||||
showWhenEmpty={true}
|
||||
label="Instance"
|
||||
class="flex-1"
|
||||
q={page.url.searchParams.get('instance') || ''}
|
||||
onselect={(e) =>
|
||||
searchParam(
|
||||
page.url,
|
||||
'instance',
|
||||
e?.domain.toString() ?? '',
|
||||
'page',
|
||||
'community',
|
||||
'user',
|
||||
'mod_id',
|
||||
)}
|
||||
/>
|
||||
<ObjectAutocomplete
|
||||
placeholder="Filter by community"
|
||||
listing_type="All"
|
||||
showWhenEmpty={true}
|
||||
label="Community"
|
||||
class="flex-1"
|
||||
q={page.url.searchParams.get('community') ? 'Selected' : ''}
|
||||
onselect={(e) =>
|
||||
searchParam(page.url, 'community', e?.id.toString() ?? '', 'page')}
|
||||
searchParam(
|
||||
page.url,
|
||||
'community',
|
||||
e?.community.id.toString() ?? '',
|
||||
'page',
|
||||
)}
|
||||
/>
|
||||
<UserAutocomplete
|
||||
instance={page.url.searchParams.get('instance') || undefined}
|
||||
placeholder="Filter by user"
|
||||
jwt={profile.current?.jwt}
|
||||
listing_type="All"
|
||||
showWhenEmpty={true}
|
||||
class="flex-1"
|
||||
label="User"
|
||||
q={page.url.searchParams.get('user')
|
||||
? (data.filters.user ?? 'Selected')
|
||||
@@ -220,10 +200,8 @@
|
||||
{#if profile.current?.user && isAdmin(profile.current?.user)}
|
||||
<UserAutocomplete
|
||||
placeholder="Filter by moderator"
|
||||
jwt={profile.current?.jwt}
|
||||
listing_type="All"
|
||||
showWhenEmpty={true}
|
||||
class="flex-1"
|
||||
label="Moderator"
|
||||
q={page.url.searchParams.get('mod_id')
|
||||
? (data.filters.moderator ?? 'Selected')
|
||||
@@ -244,8 +222,8 @@
|
||||
'instance',
|
||||
)
|
||||
}}
|
||||
size="square-lg"
|
||||
class="self-end shrink-0"
|
||||
size="custom"
|
||||
class="self-end shrink-0 h-8.5 aspect-square"
|
||||
title="Clear filters"
|
||||
>
|
||||
<Icon src={XMark} size="16" mini />
|
||||
@@ -259,34 +237,29 @@
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<div style="width:100%; overflow-x: auto;">
|
||||
<div style="width:100%; overflow-x: auto;" class="table-container">
|
||||
<table
|
||||
class="table overflow-x-auto table-fixed relative"
|
||||
style="min-width: 800px;"
|
||||
class="table overflow-x-auto table-fixed relative w-full min-w-2xl"
|
||||
>
|
||||
<colgroup class="table-fixed">
|
||||
<col />
|
||||
<col />
|
||||
<col class="overflow-x-auto" />
|
||||
<col />
|
||||
<col />
|
||||
<col />
|
||||
<col />
|
||||
<col />
|
||||
<colgroup>
|
||||
<col style="width: 10.6%;" />
|
||||
<col style="width: 16.6%;" />
|
||||
<col style="width: 16.6%;" />
|
||||
<col style="width: 16.6%;" />
|
||||
<col style="width: 16.6%;" />
|
||||
<col style="width: 16.6%;" />
|
||||
</colgroup>
|
||||
<thead class="text-left sticky top-0">
|
||||
<thead class="text-left">
|
||||
<tr class="rounded-t-lg overflow-hidden">
|
||||
<th>Time</th>
|
||||
<th>Moderator</th>
|
||||
<th>Action</th>
|
||||
<th>User</th>
|
||||
<th>Community</th>
|
||||
<th>Content</th>
|
||||
<th>Action</th>
|
||||
<th>Reason</th>
|
||||
<th>Link</th>
|
||||
<th align="right">Content</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-sm">
|
||||
<tbody class="text-sm divide-y divide-slate-200 dark:divide-zinc-800">
|
||||
{#each data.modlog as modlog (modlog)}
|
||||
<ModlogItemTable item={modlog} />
|
||||
{/each}
|
||||
@@ -294,7 +267,11 @@
|
||||
</table>
|
||||
</div>
|
||||
{/if}
|
||||
<Pageination page={data.page} href={(page) => `?page=${page}`} />
|
||||
<Pageination
|
||||
page={data.page}
|
||||
hasMore={data.params.hasMore}
|
||||
href={(page) => `?page=${page}`}
|
||||
/>
|
||||
{:else}
|
||||
<Placeholder
|
||||
title="No results"
|
||||
@@ -305,21 +282,44 @@
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@reference '../../style/app.css'
|
||||
|
||||
:global(.table thead tr th) {
|
||||
@apply border border-slate-200 dark:border-zinc-800 px-4 py-2 bg-slate-100;
|
||||
.table-container {
|
||||
border: 1px solid var(--color-slate-200);
|
||||
background-color: white;
|
||||
border-radius: var(--radius-2xl);
|
||||
}
|
||||
|
||||
:global(.table tr td) {
|
||||
@apply border border-slate-200 px-4 py-2 overflow-auto;
|
||||
.table {
|
||||
table-layout: fixed !important;
|
||||
|
||||
thead {
|
||||
tr {
|
||||
th {
|
||||
padding: calc(var(--spacing) * 3);
|
||||
border-bottom: 1px solid var(--color-slate-200);
|
||||
font-weight: var(--font-weight-medium);
|
||||
font-size: var(--text-sm);
|
||||
background-color: var(--color-slate-25);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:global(.dark .table tr td) {
|
||||
@apply border-zinc-800;
|
||||
.table tbody {
|
||||
font-size: var(--text-xs);
|
||||
:global(tr td) {
|
||||
padding: calc(var(--spacing) * 1) calc(var(--spacing) * 3);
|
||||
}
|
||||
}
|
||||
|
||||
:global(.dark thead tr th) {
|
||||
@apply border-zinc-800 bg-zinc-900;
|
||||
:global(.dark) {
|
||||
.table-container {
|
||||
background-color: var(--color-zinc-950);
|
||||
border: 1px solid var(--color-zinc-800);
|
||||
}
|
||||
|
||||
thead tr th {
|
||||
background-color: var(--color-zinc-900);
|
||||
border-bottom: 1px solid var(--color-zinc-800);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,4 @@
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import { getClient } from '$lib/client/lemmy.svelte'
|
||||
import { client } from '$lib/client/lemmy.svelte'
|
||||
import type {
|
||||
AdminPurgeCommentView,
|
||||
AdminPurgeCommunityView,
|
||||
@@ -19,6 +18,7 @@ import type {
|
||||
ModlogActionType,
|
||||
Person,
|
||||
} from '$lib/client/types'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
|
||||
export type ActionName =
|
||||
| 'ban'
|
||||
@@ -188,7 +188,10 @@ export const _toModLog = (item: ModAction): ModLog => {
|
||||
timestamp: timestamp(item.mod_ban.when_),
|
||||
moderator: item.moderator,
|
||||
moderatee: item.banned_person,
|
||||
reason: `${item.mod_ban.reason ?? ''} (banned ${expires})`,
|
||||
reason:
|
||||
item.mod_ban.reason +
|
||||
' ' +
|
||||
(item.mod_ban.banned === true ? `(banned ${expires})` : ''),
|
||||
link: `/u/${fullUserName(item.banned_person)}`,
|
||||
}
|
||||
} else if ('mod_add' in item) {
|
||||
@@ -206,9 +209,7 @@ export const _toModLog = (item: ModAction): ModLog => {
|
||||
}
|
||||
}
|
||||
|
||||
export async function load({ url }) {
|
||||
const instance = url.searchParams.get('instance') || undefined
|
||||
|
||||
export async function load({ url, fetch }) {
|
||||
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
|
||||
@@ -219,7 +220,9 @@ export async function load({ url }) {
|
||||
const type: ModlogActionType =
|
||||
(url.searchParams.get('type') as ModlogActionType) || 'All'
|
||||
|
||||
const results = await getClient(instance).getModlog({
|
||||
const results = await client({
|
||||
func: fetch,
|
||||
}).getModlog({
|
||||
community_id: community,
|
||||
limit: 20,
|
||||
type_: type,
|
||||
@@ -270,6 +273,7 @@ export async function load({ url }) {
|
||||
moderator: modId,
|
||||
post: postId,
|
||||
comment: commentId,
|
||||
hasMore: moderationActions.length >= 20,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
<script lang="ts">
|
||||
import Link from '$lib/components/input/Link.svelte'
|
||||
import { CommunityLink } from '$lib/components/lemmy/community'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import { t } from '$lib/i18n/translations.js'
|
||||
import { Button, modal } from 'mono-svelte'
|
||||
import type { ModLog } from '../+page.js'
|
||||
import ModlogAction from '../ModlogAction.svelte'
|
||||
|
||||
@@ -13,6 +14,18 @@
|
||||
let { item }: Props = $props()
|
||||
</script>
|
||||
|
||||
{#snippet itemInfo()}
|
||||
<Button color="primary" rounding="pill" class="w-max" href={item.link}>
|
||||
{$t('common.jump')}
|
||||
</Button>
|
||||
{#if item.moderatee}
|
||||
<UserLink avatar user={item.moderatee} />
|
||||
{/if}
|
||||
<div>
|
||||
{item.content}
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
<tr class="">
|
||||
<td style="width: 10%;">
|
||||
<span>
|
||||
@@ -28,18 +41,10 @@
|
||||
user={item.moderator}
|
||||
/>
|
||||
{:else}
|
||||
<p class="text-slate-500 dark:text-zinc-500">Hidden</p>
|
||||
<p class="text-slate-500 dark:text-zinc-500">Unknown</p>
|
||||
<p></p>
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
<ModlogAction action={item.actionName} />
|
||||
</td>
|
||||
<td>
|
||||
{#if item.moderatee}
|
||||
<UserLink showInstance={false} user={item.moderatee} />
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
{#if item.community}
|
||||
<CommunityLink
|
||||
@@ -51,18 +56,21 @@
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
{#if item.content}
|
||||
<p>{item.content}</p>
|
||||
{/if}
|
||||
<ModlogAction action={item.actionName} />
|
||||
</td>
|
||||
<td>
|
||||
{#if item.reason}
|
||||
<p>{item.reason}</p>
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
{#if item.link}
|
||||
<Link highlight href={item.link} />
|
||||
<td align="right">
|
||||
{#if item.content}
|
||||
<Button
|
||||
size="sm"
|
||||
onclick={() => modal({ title: $t('common.info'), snippet: itemInfo })}
|
||||
>
|
||||
{$t('common.info')}
|
||||
</Button>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -73,7 +73,7 @@
|
||||
})
|
||||
.then((i) => i.comments)
|
||||
loading = false
|
||||
data.data.value.thread.singleThread = false
|
||||
data.data.value.params.thread.singleThread = false
|
||||
}
|
||||
|
||||
let tags = $derived.by<{ title?: string; tags: Tag[] }>(() => {
|
||||
@@ -217,28 +217,28 @@
|
||||
{/await}
|
||||
</article>
|
||||
{#await data.data.value.comments then comments}
|
||||
{#if data.data.value.thread.showContext || data.data.value.thread.singleThread}
|
||||
{#if data.data.value.params.thread.showContext || data.data.value.params.thread.singleThread}
|
||||
<div
|
||||
class="sticky mx-auto z-50 max-w-md min-w-0 flex flex-col items-center overflow-auto gap-1
|
||||
bg-slate-50/50 dark:bg-zinc-900/50 backdrop-blur-xl border border-slate-200/50 dark:border-zinc-800/50
|
||||
p-1 rounded-full justify-between top-6 lg:top-22"
|
||||
p-1 rounded-full justify-between top-6 lg:top-22 my-4"
|
||||
>
|
||||
<Button
|
||||
color="none"
|
||||
rounding="pill"
|
||||
{loading}
|
||||
disabled={loading}
|
||||
href={data.data.value.thread.showContext
|
||||
href={data.data.value.params.thread.showContext
|
||||
? `/comment/${
|
||||
// split first comment path to get 5 before
|
||||
comments[0].comment.path.split('.').slice(-5)[1]
|
||||
}`
|
||||
: data.data.value.thread.singleThread
|
||||
: data.data.value.params.thread.singleThread
|
||||
? postLink(data.data.value.post.post)
|
||||
: undefined}
|
||||
class="hover:bg-white/50 dark:hover:bg-zinc-800/30"
|
||||
>
|
||||
{data.data.value.thread.showContext
|
||||
{data.data.value.params.thread.showContext
|
||||
? $t('routes.post.thread.context')
|
||||
: $t('routes.post.thread.allComments')}
|
||||
{#snippet suffix()}
|
||||
@@ -290,7 +290,7 @@
|
||||
<CommentProvider
|
||||
{comments}
|
||||
post={data.data.value.post}
|
||||
focus={data.data.value.thread.focus}
|
||||
focus={data.data.value.params.thread.focus}
|
||||
onupdate={reloadComments}
|
||||
bind:sort={data.data.value.params.comments.sort}
|
||||
virtualize={!page.url.searchParams.get('noVirtualize')}
|
||||
|
||||
@@ -68,6 +68,7 @@ export async function load({ params, url, route }) {
|
||||
focus,
|
||||
max_depth: passedMaxDepth,
|
||||
} = buildContext(url.searchParams.get('thread') || undefined)
|
||||
|
||||
const max_depth = passedMaxDepth
|
||||
|
||||
const feedData = feed(route.id, async (p) => {
|
||||
@@ -84,11 +85,7 @@ export async function load({ params, url, route }) {
|
||||
cross_posts: i.cross_posts,
|
||||
post_view: i.post_view,
|
||||
})),
|
||||
thread: {
|
||||
showContext,
|
||||
focus,
|
||||
singleThread: parentId != null,
|
||||
},
|
||||
thread: p.thread,
|
||||
params: p,
|
||||
}
|
||||
})
|
||||
@@ -105,6 +102,11 @@ export async function load({ params, url, route }) {
|
||||
},
|
||||
posts: { id: Number(params.id) },
|
||||
preload: cachedPost,
|
||||
thread: {
|
||||
showContext: showContext,
|
||||
focus: focus,
|
||||
singleThread: parentId != null,
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
})
|
||||
|
||||
onMount(() => {
|
||||
if (browser && !isNaN(Number(page.url.hash)))
|
||||
if (browser && !isNaN(Number(page.url.hash.slice(1)) || NaN))
|
||||
// hack because virtual list needs to calc heights
|
||||
setTimeout(() => {
|
||||
document
|
||||
|
||||
Reference in new issue
Block a user