impr: add more options to moderation page (#604)

* feat: allow filtering by community on modpage

* feat: add arbitrary banning

* temp

* feat: combine reports on reports page

* design: clarify report design

* fix: update lang key for navbar moderation
This commit is contained in:
Xylight authored and GitHub committed 2025-07-06 22:43:26 +00:00
1 parent 5b8f9d15af
commit 412977a484
16 files changed
+621 -190

No files matched your search

@@ -25,10 +25,11 @@
Newspaper,
NoSymbol,
Plus,
ShieldCheck,
} from 'svelte-hero-icons'
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
import ItemList from '../generic/ItemList.svelte'
import { isAdmin } from '../moderation/moderation'
import { amMod, isAdmin } from '../moderation/moderation'
import { block, blockInstance, purgeCommunity } from './CommunityCard.svelte'
interface Props {
@@ -37,6 +38,7 @@
counts?: CommunityAggregates | undefined
moderators?: CommunityModeratorView[]
blocked?: boolean
banner?: boolean
class?: string
}
@@ -46,12 +48,13 @@
counts = undefined,
moderators = [],
blocked = false,
banner = !(settings.nsfwBlur && community.nsfw),
class: clazz = '',
}: Props = $props()
</script>
<EntityHeader
banner={settings.nsfwBlur && community.nsfw ? undefined : community.banner}
banner={banner ? community.banner : undefined}
avatar={community.icon}
name={community.title}
url="/c/{fullCommunityName(community.name, community.actor_id)}"
@@ -178,6 +181,15 @@
<Icon src={Newspaper} size="16" mini />
{$t('cards.community.modlog')}
</MenuButton>
{#if profile.data.user && amMod(profile.data.user, community)}
<MenuButton
color="success-subtle"
href="/moderation?community={community.id}"
>
<Icon src={ShieldCheck} size="16" micro />
{$t('routes.moderation.feed')}
</MenuButton>
{/if}
{#if profile.data?.jwt}
<MenuButton
color="danger-subtle"
@@ -21,6 +21,7 @@
} from 'svelte-hero-icons'
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
import { settings } from '$lib/settings.svelte'
import type { Snippet } from 'svelte'
let showInfo = $state(false)
interface Props {
@@ -29,6 +30,7 @@
showCounts?: boolean
class?: string
icon?: import('svelte').Snippet
children?: Snippet
}
let {
@@ -37,6 +39,7 @@
showCounts = true,
class: clazz = 'py-4 flex flex-col gap-4 text-sm max-w-full relative',
icon,
children,
}: Props = $props()
</script>
@@ -137,66 +140,70 @@
</div>
</div>
</a>
<div class="flex flex-row items-center gap-2">
<Button
size="square-md"
rounding="pill"
color="ghost"
onclick={() => (showInfo = !showInfo)}
>
<Icon src={InformationCircle} size="16" mini />
</Button>
<Subscribe {community}>
{#snippet children({ subscribe, subscribing })}
<Button
disabled={subscribing || !profile.data?.jwt}
loading={subscribing}
onclick={async () => {
const res = await subscribe()
{#if children}
{@render children?.()}
{:else}
<div class="flex flex-row items-center gap-2">
<Button
size="square-md"
rounding="pill"
color="ghost"
onclick={() => (showInfo = !showInfo)}
>
<Icon src={InformationCircle} size="16" mini />
</Button>
<Subscribe {community}>
{#snippet children({ subscribe, subscribing })}
<Button
disabled={subscribing || !profile.data?.jwt}
loading={subscribing}
onclick={async () => {
const res = await subscribe()
if (res) {
const newSubscribed =
res.community_view.subscribed != 'NotSubscribed'
? 'Subscribed'
: 'NotSubscribed'
if (res) {
const newSubscribed =
res.community_view.subscribed != 'NotSubscribed'
? 'Subscribed'
: 'NotSubscribed'
community.subscribed = newSubscribed
addSubscription(
community.community,
newSubscribed == 'Subscribed',
)
}
}}
size="custom"
title={isSubscribed(community.subscribed)
? $t('cards.community.subscribed')
: $t('cards.community.subscribe')}
color={isSubscribed(community.subscribed)
? 'elevatedLow'
: 'primary'}
class="{isSubscribed(community.subscribed)
? 'text-slate-600 dark:text-zinc-400'
: ''}
community.subscribed = newSubscribed
addSubscription(
community.community,
newSubscribed == 'Subscribed',
)
}
}}
size="custom"
title={isSubscribed(community.subscribed)
? $t('cards.community.subscribed')
: $t('cards.community.subscribe')}
color={isSubscribed(community.subscribed)
? 'elevatedLow'
: 'primary'}
class="{isSubscribed(community.subscribed)
? 'text-slate-600 dark:text-zinc-400'
: ''}
aspect-square h-8.5 @md:px-2 @md:min-w-30 @md:aspect-auto @md:rounded-full"
>
{#snippet prefix()}
<Icon
src={isSubscribed(community.subscribed) ? Check : Plus}
size="16"
micro
/>
{/snippet}
<span class="hidden @md:block">
{#if isSubscribed(community.subscribed)}
{$t('cards.community.subscribed')}
{:else}
{$t('cards.community.subscribe')}
{/if}
</span>
</Button>
{/snippet}
</Subscribe>
</div>
>
{#snippet prefix()}
<Icon
src={isSubscribed(community.subscribed) ? Check : Plus}
size="16"
micro
/>
{/snippet}
<span class="hidden @md:block">
{#if isSubscribed(community.subscribed)}
{$t('cards.community.subscribed')}
{:else}
{$t('cards.community.subscribe')}
{/if}
</span>
</Button>
{/snippet}
</Subscribe>
</div>
{/if}
</div>
{#if showCounts}
<div class="flex flex-row gap-3 items-center justify-center">
+1 -1
View File
@@ -138,7 +138,7 @@
</MenuButton>
{#if amModOfAny(profile.data.user)}
<MenuButton href="/moderation" icon={ShieldCheck}>
{$t('routes.moderation.reports')}
{$t('routes.moderation.feed')}
{#snippet suffix()}
{@render notifBadge($notifications.reports)}
{/snippet}
@@ -11,6 +11,7 @@
import { Home, Icon, MagnifyingGlass } from 'svelte-hero-icons'
import { getGroups, type Action, type Group } from './actions.svelte'
import CommandItem from './CommandItem.svelte'
import { fuzzySearch } from '$lib/util.svelte'
interface Props {
open?: boolean
@@ -37,38 +38,6 @@
let breadcrumbs: Action[] = $state([])
let input = $state<HTMLInputElement>()
function fuzzySearch(text: string, pattern: string): number {
const textLower = text.toLowerCase()
const patternLower = pattern.toLowerCase()
let score = 0
let lastIndex = -1
let consecutiveBonus = 0
for (let i = 0; i < patternLower.length; i++) {
const index = textLower.indexOf(patternLower[i], lastIndex + 1)
if (index === -1) return 0
score += 1
if (index === lastIndex + 1) {
consecutiveBonus++
score += consecutiveBonus
} else {
consecutiveBonus = 0
}
lastIndex = index
}
// Bonus for matching start of words
if (textLower.startsWith(patternLower)) {
score += 2
} else if (textLower.includes(' ' + patternLower)) {
score += 1
}
return score
}
const debounce = (fn: Function, ms = 300) => {
let timeoutId: ReturnType<typeof setTimeout>
// eslint-disable-next-line
+7 -1
View File
@@ -333,7 +333,13 @@
"resolvedBy": "Resolved by",
"markAll": "Mark page resolved",
"markAllComplete": "Batch action completed.",
"reports": "Reports"
"feed": "Reports",
"manage": {
"title": "Manage",
"modlogs": "Recent moderation logs",
"ban": "Ban",
"unban": "Unban"
}
},
"admin": {
"title": "Administration",
+2
View File
@@ -9,6 +9,7 @@ import type {
Post,
PostReportView,
PostView,
PrivateMessage,
PrivateMessageReportView,
PrivateMessageView,
} from 'lemmy-js-client'
@@ -25,6 +26,7 @@ export type Result =
| PostReportView
| CommentReportView
| PrivateMessageReportView
| PrivateMessage
export function getItemPublished(item: Result) {
// reports... why
+32
View File
@@ -186,3 +186,35 @@ export function escapeHtml(input: string): string {
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
}
export function fuzzySearch(text: string, pattern: string): number {
const textLower = text.toLowerCase()
const patternLower = pattern.toLowerCase()
let score = 0
let lastIndex = -1
let consecutiveBonus = 0
for (let i = 0; i < patternLower.length; i++) {
const index = textLower.indexOf(patternLower[i], lastIndex + 1)
if (index === -1) return 0
score += 1
if (index === lastIndex + 1) {
consecutiveBonus++
score += consecutiveBonus
} else {
consecutiveBonus = 0
}
lastIndex = index
}
// Bonus for matching start of words
if (textLower.startsWith(patternLower)) {
score += 2
} else if (textLower.includes(' ' + patternLower)) {
score += 1
}
return score
}
+33
View File
@@ -0,0 +1,33 @@
<script lang="ts">
import { Material, Popover } from 'mono-svelte'
import { Icon, Sparkles } from 'svelte-hero-icons'
</script>
<Popover placement="left">
{#snippet target()}
<button
class="potato p-4 rounded-full border border-slate-200 dark:border-zinc-800 cursor-pointer pointer-events-auto"
>
<Icon src={Sparkles} size="32" />
</button>
{/snippet}
{#snippet popover()}
<Material color="uniform" rounding="2xl">
<h1 class="font-bold text-3xl">AI !!!!</h1>
</Material>
{/snippet}
</Popover>
<style>
.potato {
background: linear-gradient(
30deg,
color-mix(
in srgb,
var(--color-zinc-900) 90%,
var(--color-purple-400) 10%
),
color-mix(in srgb, var(--color-zinc-900) 90%, var(--color-blue-400) 10%)
);
}
</style>
+31
View File
@@ -0,0 +1,31 @@
<script lang="ts">
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
import { t } from '$lib/i18n/translations'
let { children } = $props()
</script>
<svelte:head>
<title>{$t('routes.moderation.title')}</title>
</svelte:head>
<div class="w-full space-y-4 pb-8">
<div
class="sticky w-max mx-auto z-50 max-w-full min-w-0 flex items-center gap-2 top-6 lg:top-22"
>
<Tabs
class="overflow-auto"
routes={[
{
href: '/moderation',
name: $t('routes.moderation.feed'),
},
{
href: '/moderation/communities',
name: $t('routes.communities.title'),
},
]}
/>
</div>
{@render children?.()}
</div>
+6
View File
@@ -0,0 +1,6 @@
import { profile } from '$lib/auth.svelte'
import { error } from '@sveltejs/kit'
export function load() {
if (!profile.data.jwt) error(401)
}
+77 -37
View File
@@ -7,13 +7,14 @@
import { t } from '$lib/i18n/translations'
import { client } from '$lib/lemmy.svelte'
import { searchParam } from '$lib/util.svelte.js'
import { Button, Select, toast } from 'mono-svelte'
import { Button, Material, Select, Spinner, toast } from 'mono-svelte'
import Option from 'mono-svelte/forms/select/Option.svelte'
import { tick } from 'svelte'
import { Check, Funnel, Icon, Inbox } from 'svelte-hero-icons'
import { Check, Funnel, Icon, Inbox, XMark } from 'svelte-hero-icons'
import { fly } from 'svelte/transition'
import Report from './Report.svelte'
import Pageination from '$lib/components/ui/Pageination.svelte'
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
let { data = $bindable() } = $props()
@@ -26,38 +27,40 @@
await Promise.all(
data.items?.value.map(report => {
switch (report.type) {
case 'comment': {
const promise = client().resolveCommentReport({
report_id: report.id,
resolved: true,
})
promise.then(
() => (batch.progress += 1 / data.items?.value!.length),
)
return promise
report.map(r => {
switch (r.type) {
case 'comment': {
const promise = client().resolveCommentReport({
report_id: r.id,
resolved: true,
})
promise.then(
() => (batch.progress += 1 / data.items?.value!.length),
)
return promise
}
case 'post': {
const promise = client().resolvePostReport({
report_id: r.id,
resolved: true,
})
promise.then(
() => (batch.progress += 1 / data.items?.value!.length),
)
return promise
}
case 'message': {
const promise = client().resolvePrivateMessageReport({
report_id: r.id,
resolved: true,
})
promise.then(
() => (batch.progress += 1 / data.items?.value!.length),
)
return promise
}
}
case 'post': {
const promise = client().resolvePostReport({
report_id: report.id,
resolved: true,
})
promise.then(
() => (batch.progress += 1 / data.items?.value!.length),
)
return promise
}
case 'message': {
const promise = client().resolvePrivateMessageReport({
report_id: report.id,
resolved: true,
})
promise.then(
() => (batch.progress += 1 / data.items?.value!.length),
)
return promise
}
}
})
}),
)
@@ -101,6 +104,30 @@
{$t('routes.moderation.markAll')}
</Button>
</div>
{#if data.filters.community}
<ul class="font-normal flex flex-col gap-2 mt-2">
<li>
<span class="text-sm text-slate-600 dark:text-zinc-400">
{$t('form.post.community')}
</span>
{#await client().getCommunity({ id: data.filters.community })}
<Spinner width={24} />
{:then community}
<a
class="inline"
aria-label={$t('common.remove')}
href="?community="
>
<Icon src={XMark} size="16" micro class="inline" />
</a>
<CommunityLink
class="w-max inline"
community={community.community_view.community}
/>
{/await}
</li>
</ul>
{/if}
{/snippet}
</Header>
</div>
@@ -109,14 +136,27 @@
<div
class="flex flex-col *:py-4 divide-y divide-slate-200 dark:divide-zinc-800"
>
{#each data.items?.value as item (item.id)}
{#each data.items?.value as item}
<div
in:fly={{ y: -6, opacity: 0, duration: 500 }}
class="flex flex-col gap-3 text-sm -mx-4 sm:-mx-6 px-4 sm:px-6"
class="flex flex-col gap-3 text-sm -mx-4 sm:-mx-6 px-4 sm:px-6 items-center"
>
<div class="space-y-2">
<Material
rounding={item.length == 1 ? 'none' : '2xl'}
color={item.length == 1 ? 'none' : 'uniform'}
padding={item.length == 1 ? 'none' : 'md'}
class={['space-y-2 w-full']}
>
<Report {item} />
</div>
</Material>
{#if item.length > 1}
<Material
padding="none"
rounding="none"
color="uniform"
class="-mt-3 rounded-b-2xl w-[95%] h-4 bg-slate-50! dark:bg-zinc-950!"
></Material>
{/if}
</div>
{/each}
</div>
+24 -8
View File
@@ -1,10 +1,12 @@
import { profile } from '$lib/auth.svelte'
import { isAdmin } from '$lib/components/lemmy/moderation/moderation.js'
import { getClient } from '$lib/lemmy.svelte.js'
import { isCommentView, isPostView } from '$lib/lemmy/item'
import {
generalizeCommentReport,
generalizePostReport,
generalizePrivateMessageReport,
type ReportView,
} from '$lib/lemmy/report.js'
import { ReactiveState } from '$lib/promise.svelte'
import { error } from '@sveltejs/kit'
@@ -17,20 +19,15 @@ export async function load({ url, fetch }) {
const page = Number(url.searchParams.get('page')) || 1
const type: ReportListType =
(url.searchParams.get('type') as ReportListType) || 'unread'
const community = Number(url.searchParams.get('community')) || undefined
// can they please
// make a sane, consistent, and simple API for once
// 3 separate requests? really?
// and this time instead of get() it's list(). Why?!
// the interfaces don't even extend each other
// meaning I have to make a separate function to get dates
// for EACH FREAKING ITEM KAJSHDAWLD auwdi awiody
const client = getClient(undefined, fetch)
const params = {
limit: 20,
page: page,
unresolved_only: type == 'unread',
community_id: community,
}
const admin = profile.data?.user ? isAdmin(profile!.data.user!) : false
@@ -53,9 +50,28 @@ export async function load({ url, fetch }) {
),
].sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime())
const grouped = everything.reduce(
(groups, item) => {
const key = isPostView(item.item)
? item.item.post.id
: isCommentView(item.item)
? item.item.comment.id
: item.item.id
if (!groups[key]) {
groups[key] = []
}
groups[key].push(item)
return groups
},
{} as Record<number, ReportView[]>,
)
return {
type: new ReactiveState(type),
page: page,
items: new ReactiveState(everything),
items: new ReactiveState(Object.values(grouped)),
filters: {
community: community,
},
}
}
+127 -52
View File
@@ -4,19 +4,23 @@
import PrivateMessage from '$lib/components/lemmy/inbox/PrivateMessage.svelte'
import Post from '$lib/components/lemmy/post/Post.svelte'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import { t } from '$lib/i18n/translations'
import { getClient } from '$lib/lemmy.svelte.js'
import { errorMessage } from '$lib/lemmy/error'
import type { ReportView } from '$lib/lemmy/report.js'
import { Button, Material, toast } from 'mono-svelte'
import { Badge, Button, Material, Modal, toast } from 'mono-svelte'
import { CheckCircle, Icon } from 'svelte-hero-icons'
interface Props {
item: ReportView
item: ReportView[]
}
let { item = $bindable() }: Props = $props()
let { item: items = $bindable() }: Props = $props()
// TODO more strict type enforcing, this hack is not good
const item = items[0]
let resolving = $state(false)
async function resolve() {
@@ -26,63 +30,72 @@
try {
switch (item.type) {
case 'comment': {
const res = await getClient().resolveCommentReport({
report_id: item.id,
resolved: !item.resolved,
})
item.resolved = res.comment_report_view.comment_report.resolved
item.resolver = res.comment_report_view.resolver
toast({
content: item.resolved
? $t('toast.resolveReport')
: $t('toast.unresolveReport'),
type: 'success',
})
await Promise.all(
items.map(async i =>
getClient()
.resolveCommentReport({
report_id: i.id,
resolved: !i.resolved,
})
.then(res => {
i.resolved = res.comment_report_view.comment_report.resolved
i.resolver = res.comment_report_view.resolver
$notifications.reports += i.resolved ? 1 : -1
}),
),
)
break
}
case 'post': {
const res = await getClient().resolvePostReport({
report_id: item.id,
resolved: !item.resolved,
})
await Promise.all(
items.map(async i =>
getClient()
.resolvePostReport({
report_id: i.id,
resolved: !i.resolved,
})
.then(res => {
i.resolved = res.post_report_view.post_report.resolved
item.resolved = res.post_report_view.post_report.resolved
item.resolver = res.post_report_view.resolver
toast({
content: item.resolved
? $t('toast.resolveReport')
: $t('toast.unresolveReport'),
type: 'success',
})
i.resolver = res.post_report_view.resolver
$notifications.reports += i.resolved ? 1 : -1
}),
),
)
break
}
case 'message': {
const res = await getClient().resolvePrivateMessageReport({
report_id: item.id,
resolved: !item.resolved,
})
await Promise.all(
items.map(async i =>
getClient()
.resolvePrivateMessageReport({
report_id: i.id,
resolved: !i.resolved,
})
.then(res => {
i.resolved =
res.private_message_report_view.private_message_report.resolved
item.resolved =
res.private_message_report_view.private_message_report.resolved
i.resolver = res.private_message_report_view.resolver
item.resolver = res.private_message_report_view.resolver
toast({
content: item.resolved
? $t('toast.resolveReport')
: $t('toast.unresolveReport'),
type: 'success',
})
$notifications.reports += i.resolved ? 1 : -1
}),
),
)
break
}
}
$notifications.reports += item.resolved ? 1 : -1
toast({
content: item.resolved
? $t('toast.resolveReport')
: $t('toast.unresolveReport'),
type: 'success',
})
} catch (err) {
toast({
content: errorMessage(err as string),
@@ -92,16 +105,69 @@
resolving = false
}
let usersModal = $state(false)
let reasonsModal = $state(false)
</script>
<div class="flex flex-row">
<div class="flex flex-col gap-1.5 flex-1">
<span class="text-xs font-medium">Report from</span>
<span class="font-bold">
<UserLink avatar user={item.creator} />
</span>
<Modal title="Report from" bind:open={usersModal}>
<div class="flex flex-col divide-y divide-slate-200 dark:divide-zinc-800">
{#each items as item}
<UserLink avatar={false} user={item.creator} class="py-1" />
{/each}
</div>
</Modal>
<Modal title={$t('moderation.reason')} bind:open={reasonsModal}>
<div class="flex flex-col divide-y divide-slate-200 dark:divide-zinc-800">
{#each items as item}
<div class="py-2">
<UserLink avatar={false} user={item.creator} class="py-1 block" />
<blockquote
class="italic text-sm pl-4 border-l-2 border-slate-300 dark:border-zinc-700"
>
{item.reason}
</blockquote>
</div>
{/each}
</div>
</Modal>
<div class={['flex flex-row flex-wrap gap-4']}>
{#if item.type == 'comment' || item.type == 'post'}
<div class="flex flex-col gap-1.5">
<span class="text-xs font-medium">{$t('form.post.community')}</span>
<a
href="?community={item.item.community.id}"
class="flex items-center gap-1 font-medium hover:underline"
>
<Avatar
circle={false}
url={item.item.community.icon}
alt={item.item.community.name}
width={24}
/>
{item.item.community.title}
</a>
</div>
{/if}
{#if items.length > 1}
<button
onclick={() => (usersModal = !usersModal)}
class="flex-1 text-2xl font-medium hover:underline cursor-pointer text-left w-max"
>
{items.length}x
</button>
{:else}
<div class="flex flex-col gap-1.5">
<span class="text-xs font-medium">Report from</span>
<span class="font-bold">
<UserLink avatar user={item.creator} />
</span>
</div>
{/if}
<div class="flex-1"></div>
<Button
onclick={resolve}
class="h-max self-end {item.resolved
@@ -123,9 +189,9 @@
<Material rounding="xl" color="uniform" class="dark:bg-zinc-950">
{#if item.type == 'comment'}
<CommentItem community={true} comment={item.item} class="p-0!" />
<CommentItem comment={item.item} class="p-0!" />
{:else if item.type == 'post'}
<Post post={item.item} class="p-0!" />
<Post hideCommunity post={item.item} class="p-0!" />
{:else if item.type == 'message'}
<PrivateMessage
message={{
@@ -145,7 +211,16 @@
<p>
{item.reason}
</p>
{#if items.length > 1}
<button
class="cursor-pointer"
onclick={() => (reasonsModal = !reasonsModal)}
>
<Badge class="w-max my-1">+{items.length - 1}</Badge>
</button>
{/if}
</div>
<div class="flex-1"></div>
{#if item.resolver}
<div>
<SectionTitle small>
@@ -0,0 +1,85 @@
<script lang="ts">
import CommunityHeader from '$lib/components/lemmy/community/CommunityHeader.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/i18n/translations'
import { Button, Material, Spinner } from 'mono-svelte'
import ModlogItemCard from '../../../modlog/item/ModlogItemCard.svelte'
import Expandable from '$lib/components/ui/Expandable.svelte'
import UserAutocomplete from '$lib/components/lemmy/user/UserAutocomplete.svelte'
import { ban } from '$lib/components/lemmy/moderation/moderation'
import Switch from '$lib/components/input/Switch.svelte'
let banFromCommunity = $state(false)
let { data } = $props()
</script>
<Header pageHeader>
{#snippet extended()}
<CommunityHeader
community={data.community.community_view.community}
counts={data.community.community_view.counts}
moderators={data.community.moderators}
subscribed={data.community.community_view.subscribed}
banner={false}
/>
{/snippet}
</Header>
<div
class="flex flex-col *:py-2 divide-y divide-slate-200 dark:divide-zinc-800"
>
<Expandable>
{#snippet title()}
{$t('routes.moderation.manage.modlogs')}
{/snippet}
<Material
color="uniform"
rounding="2xl"
class="dark:bg-zinc-950 max-h-96 h-full overflow-auto space-y-4 mt-1"
>
{#await data.modlog}
<Spinner width={24} />
{:then log}
{#each log as modLog}
<ModlogItemCard item={modLog} />
{/each}
<div
class="sticky -bottom-4 pb-4 w-full flex items-center bg-gradient-to-b from-white/0 to-white dark:from-zinc-950/0 dark:to-zinc-950"
>
<Button
color="primary"
rounding="pill"
class="mx-auto"
href="/modlog?community={data.community.community_view.community
.id}"
>
{$t('form.post.readMore')}
</Button>
</div>
{/await}
</Material>
</Expandable>
<Expandable>
{#snippet title()}
<div>
{$t('moderation.ban.banFromCommunity')}
</div>
{/snippet}
<div class="flex flex-col gap-4">
<Switch
options={[false, true]}
optionNames={[
$t('routes.moderation.manage.ban'),
$t('routes.moderation.manage.unban'),
]}
bind:selected={banFromCommunity}
/>
<UserAutocomplete
onselect={p =>
ban(banFromCommunity, p, data.community.community_view.community)}
listing_type="All"
/>
</div>
</Expandable>
</div>
@@ -0,0 +1,44 @@
import { client } from '$lib/lemmy.svelte.js'
import { _toModLog } from '../../../modlog/+page.js'
export async function load({ params, fetch }) {
const modlog = client({ func: fetch })
.getModlog({
community_id: Number(params.id),
limit: 5,
page: 1,
})
.then(i =>
[
...i.banned_from_community,
...i.removed_comments,
...i.removed_posts,
...i.added_to_community,
...i.transferred_to_community,
...i.featured_posts,
...i.locked_posts,
...i.admin_purged_comments,
...i.admin_purged_communities,
...i.admin_purged_posts,
...i.admin_purged_persons,
...i.hidden_communities,
...i.banned,
...i.added,
]
.map(_toModLog)
.toSorted((a, b) => b.timestamp - a.timestamp),
)
const community = await client({ func: fetch }).getCommunity({
id: Number(params.id),
})
return {
community: community,
modlog: modlog,
}
}
@@ -0,0 +1,73 @@
<script lang="ts">
import { profile } from '$lib/auth.svelte'
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/i18n/translations'
import { Button, Material, Spinner } from 'mono-svelte'
</script>
<Header pageHeader>
{$t('nav.communities')}
</Header>
<div class="w-full h-full flex flex-col mt-4">
{#if !profile.data.user}
<div class="mx-auto my-auto">
<Spinner width={24} />
</div>
{:else}
<Material
color="uniform"
rounding="2xl"
class="flex flex-col dark:bg-zinc-950 max-h-[32rem] overflow-auto"
>
{#each profile.data.user.moderates as moderate}
{@const community = moderate.community}
<div
class="-mx-4 px-4 hover:bg-slate-100 hover:dark:bg-zinc-900 transition-colors duration-75"
>
<CommunityItem
community={{
banned_from_community: false,
blocked: false,
community: community,
counts: {
comments: 0,
community_id: 0,
posts: 0,
published: '2023-10-05',
subscribers: 0,
subscribers_local: 0,
users_active_day: 0,
users_active_half_year: 0,
users_active_month: 0,
users_active_week: 0,
},
subscribed: 'NotSubscribed',
}}
class="py-1 -mx-4 px-4"
>
<Button
href="/moderation?community={community.id}"
color="secondary"
rounding="pill"
size="sm"
class="h-max self-center"
>
{$t('routes.moderation.feed')}
</Button>
<div class="w-2"></div>
<Button
href="/moderation/c/{community.id}"
color="primary"
rounding="pill"
size="sm"
class="h-max self-center"
>
{$t('routes.moderation.manage.title')}
</Button>
</CommunityItem>
</div>
{/each}
</Material>
{/if}
</div>