14 files changed
+739
-34
No files matched your search
@@ -12,6 +12,9 @@
|
||||
export let options: T[]
|
||||
export let extractSelected: (item: T | null) => any
|
||||
export let extractName: (item: T) => string
|
||||
export let showWhenEmpty: boolean = false
|
||||
let canSearch: boolean = false
|
||||
export { canSearch as searchOnMount }
|
||||
|
||||
const debounce = (fn: Function, ms = 300) => {
|
||||
let timeoutId: ReturnType<typeof setTimeout>
|
||||
@@ -24,6 +27,7 @@
|
||||
const dispatcher = createEventDispatcher<{ search: string }>()
|
||||
|
||||
const debounceFunc = debounce(() => {
|
||||
canSearch = true
|
||||
dispatcher('search', query)
|
||||
}, debounceTime)
|
||||
</script>
|
||||
@@ -37,13 +41,20 @@
|
||||
}}
|
||||
{...$$restProps}
|
||||
/>
|
||||
<Menu open={options.length != 0} alignment="bottom-left">
|
||||
{#each options as option}
|
||||
<slot {extractName} {extractSelected} {option}>
|
||||
<MenuButton on:click={() => extractSelected(option)}>
|
||||
{extractName(option)}
|
||||
</MenuButton>
|
||||
</slot>
|
||||
{/each}
|
||||
<Menu
|
||||
open={(options.length != 0 || showWhenEmpty) && canSearch}
|
||||
alignment="bottom-left"
|
||||
>
|
||||
{#if query == '' && showWhenEmpty}
|
||||
<slot {extractName} {extractSelected} {query} />
|
||||
{:else}
|
||||
{#each options as option}
|
||||
<slot {extractName} {extractSelected} {option} {query}>
|
||||
<MenuButton on:click={() => extractSelected(option)}>
|
||||
{extractName(option)}
|
||||
</MenuButton>
|
||||
</slot>
|
||||
{/each}
|
||||
{/if}
|
||||
</Menu>
|
||||
</div>
|
||||
@@ -40,6 +40,7 @@
|
||||
on:keydown={(e) => dispatcher('keydown', e)}
|
||||
on:input={(e) => dispatcher('input', e)}
|
||||
on:change={(e) => dispatcher('change', e)}
|
||||
on:focus
|
||||
{...$$restProps}
|
||||
class={className}
|
||||
{required}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type { Community, ListingType } from 'lemmy-js-client'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { Icon, XCircle } from 'svelte-hero-icons'
|
||||
|
||||
let type: 'community' = 'community'
|
||||
export let q: string = ''
|
||||
@@ -12,6 +13,8 @@
|
||||
export let jwt: string | undefined = undefined
|
||||
export let listing_type: ListingType = 'Subscribed'
|
||||
export let items: Community[] | undefined = undefined
|
||||
export let showWhenEmpty: boolean = false
|
||||
let showNone: boolean = false
|
||||
|
||||
const dispatcher = createEventDispatcher<{ select: Community }>()
|
||||
</script>
|
||||
@@ -20,8 +23,11 @@
|
||||
<SearchInput
|
||||
options={items || []}
|
||||
on:search={async () => {
|
||||
if (q == '') showNone = true
|
||||
else showNone = false
|
||||
|
||||
const results = await getClient().search({
|
||||
q: q,
|
||||
q: q || ' ',
|
||||
auth: jwt,
|
||||
type_: 'Communities',
|
||||
limit: 20,
|
||||
@@ -40,15 +46,27 @@
|
||||
let:extractName
|
||||
let:extractSelected
|
||||
let:option
|
||||
{showWhenEmpty}
|
||||
{...$$restProps}
|
||||
let:query
|
||||
>
|
||||
<MenuButton on:click={() => extractSelected(option)}>
|
||||
<Avatar url={option.icon} alt={option.title} width={24} />
|
||||
<div class="flex flex-col text-left">
|
||||
<span>{option.title}</span>
|
||||
<span class="text-xs opacity-80">
|
||||
{new URL(option.actor_id).hostname}
|
||||
</span>
|
||||
</div>
|
||||
</MenuButton>
|
||||
{#if query == '' && showWhenEmpty}
|
||||
<MenuButton on:click={() => dispatcher('select', undefined)}>
|
||||
<Icon src={XCircle} size="16" mini />
|
||||
<div class="flex flex-col text-left">
|
||||
<span>None</span>
|
||||
</div>
|
||||
</MenuButton>
|
||||
{:else if option}
|
||||
<MenuButton on:click={() => extractSelected(option)}>
|
||||
<Avatar url={option.icon} alt={option.title} width={24} />
|
||||
<div class="flex flex-col text-left">
|
||||
<span>{option.title}</span>
|
||||
<span class="text-xs opacity-80">
|
||||
{new URL(option.actor_id).hostname}
|
||||
</span>
|
||||
</div>
|
||||
</MenuButton>
|
||||
{/if}
|
||||
</SearchInput>
|
||||
{/if}
|
||||
@@ -54,6 +54,12 @@
|
||||
<FormattedNumber number={site.counts.communities} />
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-row gap-2 items-center">
|
||||
<Button href="/modlog">
|
||||
<Icon src={Newspaper} size="16" mini />
|
||||
Modlog
|
||||
</Button>
|
||||
</div>
|
||||
{#if taglines && taglines.length > 0}
|
||||
<Markdown
|
||||
source={taglines[Math.floor(Math.random() * taglines.length)].content}
|
||||
|
||||
@@ -72,9 +72,7 @@
|
||||
<MenuButton
|
||||
on:click={() => {
|
||||
navigator.clipboard.writeText(
|
||||
`${$page.url.origin}/post/${getInstance()}/${
|
||||
comment.post.id
|
||||
}?thread=${comment.comment.path}#${comment.comment.id}`
|
||||
`/comment/${getInstance()}/${comment.comment.id}`
|
||||
)
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -49,6 +49,7 @@ interface Settings {
|
||||
}
|
||||
newVote: boolean
|
||||
randomPlaceholders: boolean
|
||||
modlogCardView: boolean | undefined
|
||||
}
|
||||
|
||||
export const defaultSettings: Settings = {
|
||||
@@ -85,6 +86,7 @@ export const defaultSettings: Settings = {
|
||||
},
|
||||
newVote: toBool(env.PUBLIC_NEW_VOTE_BUTTONS) ?? false,
|
||||
randomPlaceholders: toBool(env.PUBLIC_RANDOM_PLACEHOLDERS) ?? true,
|
||||
modlogCardView: toBool(env.PUBLIC_MODLOG_CARD_VIEW) ?? undefined,
|
||||
}
|
||||
|
||||
export const userSettings = writable(defaultSettings)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { getInstance } from '$lib/lemmy.js'
|
||||
import { redirect } from '@sveltejs/kit'
|
||||
|
||||
export function load({ params }) {
|
||||
throw redirect(300, `/comment/${getInstance()}/${params.instance}`)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { redirect } from '@sveltejs/kit'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
export async function load({ params, fetch }) {
|
||||
const comment = await getClient(undefined, fetch).getComment({
|
||||
id: Number(params.id),
|
||||
auth: get(profile)?.jwt,
|
||||
})
|
||||
|
||||
throw redirect(
|
||||
300,
|
||||
`/post/${comment.comment_view.post.id}?thread=${comment.comment_view.comment.path}#${comment.comment_view.comment.id}`
|
||||
)
|
||||
}
|
||||
@@ -6,26 +6,28 @@
|
||||
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
||||
import { page } from '$app/stores'
|
||||
import { goto } from '$app/navigation'
|
||||
import { EnvelopeOpen, Icon, Inbox } from 'svelte-hero-icons'
|
||||
import { EnvelopeOpen, Icon, Inbox, Newspaper } from 'svelte-hero-icons'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
|
||||
export let data
|
||||
</script>
|
||||
|
||||
<div class="mb-4 flex flex-col gap-4">
|
||||
<h1 class="font-bold text-2xl">Reports</h1>
|
||||
<MultiSelect
|
||||
selected={data.type}
|
||||
options={['all', 'unread']}
|
||||
optionNames={['All', 'Unread']}
|
||||
on:select={(e) => {
|
||||
$page.url.searchParams.delete('page')
|
||||
$page.url.searchParams.set('type', e.detail)
|
||||
goto($page.url.toString(), {
|
||||
invalidateAll: true,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
<div class="flex flex-row gap-2 flex-wrap items-center">
|
||||
<MultiSelect
|
||||
selected={data.type}
|
||||
options={['all', 'unread']}
|
||||
optionNames={['All', 'Unread']}
|
||||
on:select={(e) => searchParam($page.url, 'type', e.detail, 'page')}
|
||||
/>
|
||||
<Button href="/modlog" class="h-max ml-auto">
|
||||
<Icon src={Newspaper} size="16" mini />
|
||||
Modlog
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{#if data.items && data.items.length > 0}
|
||||
<div class="flex flex-col gap-4">
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
<script lang="ts">
|
||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
import { page } from '$app/stores'
|
||||
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import ModlogItemCard from './item/ModlogItemCard.svelte'
|
||||
import ModlogItemTable from './item/ModlogItemTable.svelte'
|
||||
|
||||
export let data
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Modlog</title>
|
||||
</svelte:head>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<h1 class="font-bold text-2xl">Modlog</h1>
|
||||
<div class="flex flex-col gap-2">
|
||||
<MultiSelect
|
||||
options={[
|
||||
'All',
|
||||
'ModRemovePost',
|
||||
'ModLockPost',
|
||||
'ModFeaturePost',
|
||||
'ModRemoveComment',
|
||||
'ModRemoveCommunity',
|
||||
'ModBanFromCommunity',
|
||||
'ModAddCommunity',
|
||||
'ModTransferCommunity',
|
||||
'ModAdd',
|
||||
'ModBan',
|
||||
'ModHideCommunity',
|
||||
'AdminPurgePerson',
|
||||
'AdminPurgeCommunity',
|
||||
'AdminPurgePost',
|
||||
'AdminPurgeComment',
|
||||
]}
|
||||
optionNames={[
|
||||
'All',
|
||||
'Remove Post',
|
||||
'Lock Post',
|
||||
'Feature Post',
|
||||
'Remove Comment',
|
||||
'Remove Community',
|
||||
'Ban From Community',
|
||||
'Add Community',
|
||||
'Transfer Community',
|
||||
'Add',
|
||||
'Ban',
|
||||
'Hide Community',
|
||||
'Purge Person',
|
||||
'Purge Community',
|
||||
'Purge Post',
|
||||
'Purge Comment',
|
||||
]}
|
||||
selected={data.type}
|
||||
on:select={(e) => searchParam($page.url, 'type', e.detail, 'page')}
|
||||
/>
|
||||
<div class="max-w-sm">
|
||||
<div class="block my-1 font-bold text-sm">Community</div>
|
||||
<ObjectAutocomplete
|
||||
placeholder="Filter by community"
|
||||
jwt={$profile?.jwt}
|
||||
listing_type="All"
|
||||
showWhenEmpty={true}
|
||||
on:select={(e) =>
|
||||
searchParam($page.url, 'community', e.detail?.id.toString(), 'page')}
|
||||
/>
|
||||
</div>
|
||||
<MultiSelect
|
||||
options={[false, true, undefined]}
|
||||
optionNames={['Table', 'Cards', 'Default']}
|
||||
selected={$userSettings.modlogCardView ??
|
||||
!window.matchMedia('(min-width: 1600px)').matches}
|
||||
on:select={(e) => ($userSettings.modlogCardView = e.detail)}
|
||||
/>
|
||||
</div>
|
||||
{#if data.modlog}
|
||||
{#if $userSettings.modlogCardView ?? !window.matchMedia('(min-width: 1600px)').matches}
|
||||
<div class="flex flex-col gap-4">
|
||||
{#each data.modlog as modlog}
|
||||
<ModlogItemCard item={modlog} />
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<div style="width:100%; overflow-x: auto;">
|
||||
<table
|
||||
class="table overflow-x-auto table-fixed relative"
|
||||
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%" />
|
||||
</colgroup>
|
||||
<thead class="text-left sticky top-0">
|
||||
<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>Reason</th>
|
||||
<th>Link</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-sm">
|
||||
{#each data.modlog as modlog}
|
||||
<ModlogItemTable item={modlog} />
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
<Pageination
|
||||
page={data.page}
|
||||
on:change={(e) => searchParam($page.url, 'page', e.detail.toString())}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<style lang="postcss">
|
||||
:global(.table thead tr th) {
|
||||
@apply border border-slate-200 dark:border-zinc-800 px-4 py-2 bg-slate-100;
|
||||
}
|
||||
|
||||
:global(.table tr td) {
|
||||
@apply border border-slate-200 px-4 py-2 overflow-auto;
|
||||
}
|
||||
|
||||
:global(.dark .table tr td) {
|
||||
@apply border-zinc-800;
|
||||
}
|
||||
|
||||
:global(.dark thead tr th) {
|
||||
@apply border-zinc-800 bg-zinc-900;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,244 @@
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type {
|
||||
AdminPurgeCommentView,
|
||||
AdminPurgeCommunityView,
|
||||
AdminPurgePersonView,
|
||||
AdminPurgePostView,
|
||||
Community,
|
||||
ModAddCommunityView,
|
||||
ModAddView,
|
||||
ModBanFromCommunityView,
|
||||
ModBanView,
|
||||
ModFeaturePostView,
|
||||
ModHideCommunityView,
|
||||
ModLockPostView,
|
||||
ModRemoveCommentView,
|
||||
ModRemovePostView,
|
||||
ModTransferCommunityView,
|
||||
ModlogActionType,
|
||||
ModlogListParams,
|
||||
Person,
|
||||
} from 'lemmy-js-client'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
export type ActionName =
|
||||
| 'ban'
|
||||
| 'banCommunity'
|
||||
| 'unban'
|
||||
| 'unbanCommunity'
|
||||
| 'postRemoval'
|
||||
| 'commentRemoval'
|
||||
| 'postLock'
|
||||
| 'postUnlock'
|
||||
| 'postUnfeature'
|
||||
| 'postFeature'
|
||||
| 'modAdd'
|
||||
| 'modRemove'
|
||||
| 'purge'
|
||||
| 'Unknown'
|
||||
|
||||
type ModAction =
|
||||
| ModBanFromCommunityView
|
||||
| ModRemoveCommentView
|
||||
| ModRemovePostView
|
||||
| ModAddCommunityView
|
||||
| ModLockPostView
|
||||
| ModFeaturePostView
|
||||
| ModTransferCommunityView
|
||||
| AdminPurgeCommentView
|
||||
| AdminPurgeCommunityView
|
||||
| AdminPurgePostView
|
||||
| AdminPurgePersonView
|
||||
| ModHideCommunityView
|
||||
| ModBanView
|
||||
| ModAddView
|
||||
|
||||
export interface ModLog {
|
||||
reason?: string
|
||||
moderatee?: Person
|
||||
content?: string
|
||||
moderator?: Person
|
||||
community?: Community
|
||||
actionName: ActionName
|
||||
timestamp: number
|
||||
link?: string
|
||||
}
|
||||
|
||||
const fullUserName = (user: Person) =>
|
||||
`${user.name}@${new URL(user.actor_id).hostname}`
|
||||
const timestamp = (when: string) => Date.parse(`${when}Z`)
|
||||
|
||||
export const _toModLog = (item: ModAction): ModLog => {
|
||||
if ('mod_ban_from_community' in item) {
|
||||
return {
|
||||
moderator: item.moderator,
|
||||
moderatee: item.banned_person,
|
||||
community: item.community,
|
||||
actionName: item.mod_ban_from_community.banned
|
||||
? 'banCommunity'
|
||||
: 'unbanCommunity',
|
||||
reason: item.mod_ban_from_community.reason,
|
||||
timestamp: timestamp(item.mod_ban_from_community.when_),
|
||||
}
|
||||
} else if ('mod_remove_comment' in item) {
|
||||
return {
|
||||
actionName: 'commentRemoval',
|
||||
community: item.community,
|
||||
content: item.comment.content,
|
||||
timestamp: timestamp(item.mod_remove_comment.when_),
|
||||
moderatee: item.commenter,
|
||||
moderator: item.moderator,
|
||||
reason: item.mod_remove_comment.reason,
|
||||
link: `/comment/${item.comment.id}`,
|
||||
}
|
||||
} else if ('mod_remove_post' in item) {
|
||||
return {
|
||||
actionName: 'postRemoval',
|
||||
community: item.community,
|
||||
content: item.post.name,
|
||||
timestamp: timestamp(item.mod_remove_post.when_),
|
||||
moderator: item.moderator,
|
||||
reason: item.mod_remove_post.reason,
|
||||
link: `/post/${item.post.id}`,
|
||||
}
|
||||
} else if ('mod_add_community' in item) {
|
||||
return {
|
||||
actionName: item.mod_add_community.removed ? 'modRemove' : 'modAdd',
|
||||
community: item.community,
|
||||
timestamp: timestamp(item.mod_add_community.when_),
|
||||
moderator: item.moderator,
|
||||
moderatee: item.modded_person,
|
||||
}
|
||||
} else if ('mod_feature_post' in item) {
|
||||
return {
|
||||
actionName: item.mod_feature_post.featured
|
||||
? 'postFeature'
|
||||
: 'postUnfeature',
|
||||
timestamp: timestamp(item.mod_feature_post.when_),
|
||||
community: item.community,
|
||||
link: `/post/${item.post.id}`,
|
||||
moderator: item.moderator,
|
||||
content: item.post.name,
|
||||
}
|
||||
} else if ('mod_lock_post' in item) {
|
||||
return {
|
||||
actionName: item.mod_lock_post.locked ? 'postLock' : 'postUnlock',
|
||||
timestamp: timestamp(item.mod_lock_post.when_),
|
||||
community: item.community,
|
||||
link: `/post/${item.post.id}`,
|
||||
moderator: item.moderator,
|
||||
content: item.post.name,
|
||||
}
|
||||
} else if ('mod_transfer_community' in item) {
|
||||
return {
|
||||
actionName: 'Unknown',
|
||||
timestamp: timestamp(item.mod_transfer_community.when_),
|
||||
moderator: item.moderator,
|
||||
moderatee: item.modded_person,
|
||||
community: item.community,
|
||||
}
|
||||
} else if ('admin_purge_post' in item) {
|
||||
return {
|
||||
actionName: 'purge',
|
||||
timestamp: timestamp(item.admin_purge_post.when_),
|
||||
moderator: item.admin,
|
||||
community: item.community,
|
||||
content: 'Purged a post',
|
||||
reason: item.admin_purge_post.reason,
|
||||
}
|
||||
} else if ('admin_purge_comment' in item) {
|
||||
return {
|
||||
actionName: 'purge',
|
||||
timestamp: timestamp(item.admin_purge_comment.when_),
|
||||
moderator: item.admin,
|
||||
content: 'Purged a comment',
|
||||
reason: item.admin_purge_comment.reason,
|
||||
}
|
||||
} else if ('admin_purge_community' in item) {
|
||||
return {
|
||||
actionName: 'purge',
|
||||
timestamp: timestamp(item.admin_purge_community.when_),
|
||||
moderator: item.admin,
|
||||
content: 'Purged a community',
|
||||
reason: item.admin_purge_community.reason,
|
||||
}
|
||||
} else if ('admin_purge_person' in item) {
|
||||
return {
|
||||
actionName: 'purge',
|
||||
timestamp: timestamp(item.admin_purge_person.when_),
|
||||
moderator: item.admin,
|
||||
content: 'Purged a user',
|
||||
reason: item.admin_purge_person.reason,
|
||||
}
|
||||
} else if ('mod_ban' in item) {
|
||||
return {
|
||||
actionName: item.mod_ban.banned ? 'ban' : 'unban',
|
||||
timestamp: timestamp(item.mod_ban.when_),
|
||||
moderator: item.moderator,
|
||||
moderatee: item.banned_person,
|
||||
reason: item.mod_ban.reason,
|
||||
link: `/u/${fullUserName(item.banned_person)}`,
|
||||
}
|
||||
} else if ('mod_add' in item) {
|
||||
return {
|
||||
actionName: item.mod_add.removed ? 'modRemove' : 'modAdd',
|
||||
timestamp: timestamp(item.mod_add.when_),
|
||||
moderator: item.moderator,
|
||||
moderatee: item.modded_person,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
actionName: 'Unknown',
|
||||
timestamp: 0,
|
||||
}
|
||||
}
|
||||
|
||||
export async function load({ url }) {
|
||||
let community = Number(url.searchParams.get('community')) || undefined
|
||||
let modId = Number(url.searchParams.get('mod_id')) || undefined
|
||||
const page = Number(url.searchParams.get('page')) || 1
|
||||
let type: ModlogActionType =
|
||||
(url.searchParams.get('type') as ModlogActionType) || 'All'
|
||||
|
||||
const results = await getClient().getModlog({
|
||||
auth: get(profile)?.jwt,
|
||||
community_id: community,
|
||||
limit: 40,
|
||||
type_: type,
|
||||
page: page,
|
||||
mod_person_id: modId,
|
||||
})
|
||||
|
||||
const moderation = [
|
||||
...results.banned_from_community,
|
||||
...results.removed_comments,
|
||||
...results.removed_posts,
|
||||
|
||||
...results.added_to_community,
|
||||
...results.transferred_to_community,
|
||||
|
||||
...results.featured_posts,
|
||||
...results.locked_posts,
|
||||
|
||||
...results.admin_purged_comments,
|
||||
...results.admin_purged_communities,
|
||||
...results.admin_purged_posts,
|
||||
...results.admin_purged_persons,
|
||||
|
||||
...results.hidden_communities,
|
||||
...results.banned,
|
||||
...results.added,
|
||||
]
|
||||
|
||||
const moderationActions = moderation
|
||||
.map(_toModLog)
|
||||
.sort((a, b) => b.timestamp - a.timestamp)
|
||||
|
||||
return {
|
||||
page: page,
|
||||
type: type,
|
||||
modlog: moderationActions,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<script lang="ts">
|
||||
import type { IconSource } from 'svelte-hero-icons'
|
||||
import {
|
||||
CheckCircle,
|
||||
Fire,
|
||||
Icon,
|
||||
InformationCircle,
|
||||
LockClosed,
|
||||
LockOpen,
|
||||
QuestionMarkCircle,
|
||||
Trash,
|
||||
UserMinus,
|
||||
UserPlus,
|
||||
XCircle,
|
||||
} from 'svelte-hero-icons'
|
||||
import type { ActionName } from './+page.js'
|
||||
|
||||
export let action: ActionName
|
||||
|
||||
$: actionData = getAction(action)
|
||||
|
||||
const getAction = (
|
||||
action: ActionName
|
||||
): { icon: IconSource; text: string; class: string } => {
|
||||
switch (action) {
|
||||
case 'ban': {
|
||||
return {
|
||||
icon: XCircle,
|
||||
class: 'text-red-600 dark:text-red-400',
|
||||
text: 'Ban (instance)',
|
||||
}
|
||||
}
|
||||
case 'banCommunity': {
|
||||
return {
|
||||
icon: XCircle,
|
||||
class: 'text-red-600 dark:text-red-400',
|
||||
text: 'Ban (Community)',
|
||||
}
|
||||
}
|
||||
case 'unban': {
|
||||
return {
|
||||
icon: CheckCircle,
|
||||
class: 'text-green-600 dark:text-green-400',
|
||||
text: 'Unban (instance)',
|
||||
}
|
||||
}
|
||||
case 'unbanCommunity': {
|
||||
return {
|
||||
icon: CheckCircle,
|
||||
class: 'text-green-600 dark:text-green-400',
|
||||
text: 'Unban (Community)',
|
||||
}
|
||||
}
|
||||
case 'commentRemoval': {
|
||||
return {
|
||||
icon: Trash,
|
||||
class: 'text-red-600 dark:text-red-400',
|
||||
text: 'Removal',
|
||||
}
|
||||
}
|
||||
case 'postRemoval': {
|
||||
return {
|
||||
icon: Trash,
|
||||
class: 'text-red-600 dark:text-red-400',
|
||||
text: 'Removal',
|
||||
}
|
||||
}
|
||||
case 'modAdd': {
|
||||
return {
|
||||
icon: UserPlus,
|
||||
class: 'text-green-600 dark:text-green-400',
|
||||
text: 'Added Mod',
|
||||
}
|
||||
}
|
||||
case 'modRemove': {
|
||||
return {
|
||||
icon: UserMinus,
|
||||
class: 'text-red-600 dark:text-red-400',
|
||||
text: 'Removed Mod',
|
||||
}
|
||||
}
|
||||
case 'postFeature': {
|
||||
return {
|
||||
icon: InformationCircle,
|
||||
class: 'text-green-600 dark:text-green-400',
|
||||
text: 'Featured Post',
|
||||
}
|
||||
}
|
||||
case 'postUnfeature': {
|
||||
return {
|
||||
icon: InformationCircle,
|
||||
class: 'text-red-600 dark:text-red-400',
|
||||
text: 'Unfeatured Post',
|
||||
}
|
||||
}
|
||||
case 'postLock': {
|
||||
return {
|
||||
icon: LockClosed,
|
||||
class: 'text-yellow-600 dark:text-yellow-400',
|
||||
text: 'Locked Post',
|
||||
}
|
||||
}
|
||||
case 'postUnlock': {
|
||||
return {
|
||||
icon: LockOpen,
|
||||
class: 'text-yellow-600 dark:text-yellow-400',
|
||||
text: 'Unlocked Post',
|
||||
}
|
||||
}
|
||||
case 'purge': {
|
||||
return {
|
||||
icon: Fire,
|
||||
class: 'text-red-600 dark:text-red-400',
|
||||
text: 'Purge',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
icon: QuestionMarkCircle,
|
||||
text: 'Unknown',
|
||||
class: '',
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<span class="font-bold">
|
||||
<span class="flex items-center gap-1 {actionData.class}">
|
||||
<Icon src={actionData.icon} size="16" mini class="inline flex-shrink-0" />
|
||||
{actionData.text}
|
||||
</span>
|
||||
</span>
|
||||
@@ -0,0 +1,61 @@
|
||||
<script lang="ts">
|
||||
import Link from '$lib/components/input/Link.svelte'
|
||||
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
||||
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import Card from '$lib/components/ui/Card.svelte'
|
||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import type { ModLog } from '../+page.js'
|
||||
import ModlogAction from '../ModlogAction.svelte'
|
||||
|
||||
export let item: ModLog
|
||||
</script>
|
||||
|
||||
<Card elevation={0} class="p-5 flex flex-col gap-2 text-sm">
|
||||
<div class="flex flex-row justify-between flex-wrap gap-2">
|
||||
{#if item.community}
|
||||
<CommunityLink community={item.community} avatar showInstance />
|
||||
{/if}
|
||||
<SectionTitle class="font-normal">
|
||||
<RelativeDate date={new Date(item.timestamp)} />
|
||||
</SectionTitle>
|
||||
</div>
|
||||
{#if item.actionName}
|
||||
<SectionTitle class="mt-2">Action</SectionTitle>
|
||||
<span class="text-base">
|
||||
<ModlogAction action={item.actionName} />
|
||||
</span>
|
||||
{/if}
|
||||
{#if item.moderator}
|
||||
<SectionTitle class="mt-2">Moderator</SectionTitle>
|
||||
<span
|
||||
class="flex items-center gap-1 text-green-600 dark:text-green-400 font-medium"
|
||||
>
|
||||
<UserLink showInstance={true} avatar user={item.moderator} />
|
||||
{#if !item.moderator.admin}
|
||||
<ShieldIcon filled width={16} />
|
||||
{/if}
|
||||
</span>
|
||||
{/if}
|
||||
{#if item.moderatee}
|
||||
<SectionTitle class="mt-2">User</SectionTitle>
|
||||
<UserLink showInstance={true} avatar user={item.moderatee} />
|
||||
{/if}
|
||||
{#if item.link || item.content}
|
||||
<SectionTitle class="mt-2">Item</SectionTitle>
|
||||
{#if item.link && item.content}
|
||||
<Link href={item.link} highlight>
|
||||
{item.content}
|
||||
</Link>
|
||||
{:else if item.content}
|
||||
<p>{item.content}</p>
|
||||
{:else if item.link}
|
||||
<Link href={item.link} highlight />
|
||||
{/if}
|
||||
{/if}
|
||||
{#if item.reason}
|
||||
<SectionTitle class="mt-2">Reason</SectionTitle>
|
||||
<p>{item.reason}</p>
|
||||
{/if}
|
||||
</Card>
|
||||
@@ -0,0 +1,61 @@
|
||||
<script lang="ts">
|
||||
import Link from '$lib/components/input/Link.svelte'
|
||||
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import type { ModLog } from '../+page.js'
|
||||
import ModlogAction from '../ModlogAction.svelte'
|
||||
|
||||
export let item: ModLog
|
||||
</script>
|
||||
|
||||
<tr class="">
|
||||
<td>
|
||||
<span>
|
||||
<RelativeDate date={new Date(item.timestamp)} />
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{#if item.moderator}
|
||||
<UserLink
|
||||
showInstance={false}
|
||||
avatar
|
||||
avatarSize={20}
|
||||
user={item.moderator}
|
||||
/>
|
||||
{/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
|
||||
showInstance={false}
|
||||
avatar
|
||||
avatarSize={20}
|
||||
community={item.community}
|
||||
/>
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
{#if item.content}
|
||||
<p>{item.content}</p>
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
{#if item.reason}
|
||||
<p>{item.reason}</p>
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
{#if item.link}
|
||||
<Link highlight href={item.link} />
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
Reference in new issue
Block a user