feat: add post and comment purging, fix #92
This commit is contained in:
1 parent
a134ba11b1
commit
c5afc07b41
8 files changed
+197
-94
No files matched your search
@@ -1,11 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { getClient } from '$lib/lemmy'
|
||||
import type { CommentView, Community, PostView } from 'lemmy-js-client'
|
||||
import { amMod, ban, remove } from './moderation'
|
||||
import { amMod, ban, isAdmin, remove } from './moderation'
|
||||
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||
import {
|
||||
Fire,
|
||||
Icon,
|
||||
InformationCircle,
|
||||
LockClosed,
|
||||
@@ -111,53 +112,64 @@
|
||||
/>
|
||||
</svg>
|
||||
</Button>
|
||||
<span class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
|
||||
Moderation
|
||||
</span>
|
||||
<MenuButton
|
||||
color="warning"
|
||||
on:click={() => lock(!item.post.locked)}
|
||||
loading={locking}
|
||||
disabled={locking}
|
||||
>
|
||||
<Icon
|
||||
src={item.post.locked ? LockOpen : LockClosed}
|
||||
size="16"
|
||||
mini
|
||||
slot="icon"
|
||||
/>
|
||||
{item.post.locked ? 'Unlock' : 'Lock'}
|
||||
</MenuButton>
|
||||
<MenuButton
|
||||
color="success"
|
||||
on:click={() => pin(isPost(item) ? !item.post.featured_community : false)}
|
||||
loading={pinning}
|
||||
disabled={pinning}
|
||||
>
|
||||
<Icon src={InformationCircle} size="16" mini />
|
||||
{item.post.featured_community ? 'Unpin' : 'Pin'}
|
||||
</MenuButton>
|
||||
<MenuButton color="dangerSecondary" on:click={() => remove(item)}>
|
||||
<Icon src={Trash} size="16" mini />
|
||||
{#if isComment(item)}
|
||||
{item.comment.removed ? 'Restore' : 'Remove'}
|
||||
{:else}
|
||||
{item.post.removed ? 'Restore' : 'Remove'}
|
||||
{/if}
|
||||
</MenuButton>
|
||||
{#if $profile?.user && $profile.user.local_user_view.person.id != item.creator.id}
|
||||
{#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user) && item.community.local)}
|
||||
<span class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
|
||||
User
|
||||
Moderation
|
||||
</span>
|
||||
<MenuButton
|
||||
color="dangerSecondary"
|
||||
on:click={() =>
|
||||
ban(item.creator_banned_from_community, item.creator, item.community)}
|
||||
color="warning"
|
||||
on:click={() => lock(!item.post.locked)}
|
||||
loading={locking}
|
||||
disabled={locking}
|
||||
>
|
||||
<Icon src={ShieldExclamation} size="16" mini />
|
||||
{item.creator_banned_from_community
|
||||
? 'Unban from community'
|
||||
: 'Ban from community'}
|
||||
<Icon
|
||||
src={item.post.locked ? LockOpen : LockClosed}
|
||||
size="16"
|
||||
mini
|
||||
slot="icon"
|
||||
/>
|
||||
{item.post.locked ? 'Unlock' : 'Lock'}
|
||||
</MenuButton>
|
||||
<MenuButton
|
||||
color="success"
|
||||
on:click={() => pin(isPost(item) ? !item.post.featured_community : false)}
|
||||
loading={pinning}
|
||||
disabled={pinning}
|
||||
>
|
||||
<Icon src={InformationCircle} size="16" mini />
|
||||
{item.post.featured_community ? 'Unpin' : 'Pin'}
|
||||
</MenuButton>
|
||||
<MenuButton color="dangerSecondary" on:click={() => remove(item)}>
|
||||
<Icon src={Trash} size="16" mini />
|
||||
{#if isComment(item)}
|
||||
{item.comment.removed ? 'Restore' : 'Remove'}
|
||||
{:else}
|
||||
{item.post.removed ? 'Restore' : 'Remove'}
|
||||
{/if}
|
||||
</MenuButton>
|
||||
{#if $profile?.user && $profile.user.local_user_view.person.id != item.creator.id}
|
||||
<span class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
|
||||
User
|
||||
</span>
|
||||
<MenuButton
|
||||
color="dangerSecondary"
|
||||
on:click={() =>
|
||||
ban(item.creator_banned_from_community, item.creator, item.community)}
|
||||
>
|
||||
<Icon src={ShieldExclamation} size="16" mini />
|
||||
{item.creator_banned_from_community
|
||||
? 'Unban from community'
|
||||
: 'Ban from community'}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if $profile?.user && isAdmin($profile.user)}
|
||||
<span class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
|
||||
Admin
|
||||
</span>
|
||||
<MenuButton color="dangerSecondary" on:click={() => remove(item, true)}>
|
||||
<Icon src={Fire} size="16" mini />
|
||||
Purge
|
||||
</MenuButton>
|
||||
{/if}
|
||||
</Menu>
|
||||
Reference in new issue
Block a user