Merge pull request #74 from Xyphyn/administration

feat: add admin tools
This commit is contained in:
Xylight authored and GitHub committed 2023-08-07 15:30:21 -07:00
commit 22b64d0000
27 files changed
+677 -84

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "photon-lemmy",
"version": "0.4.35",
"version": "0.5.0-beta.3",
"private": true,
"scripts": {
"dev": "vite dev",
+15
View File
@@ -0,0 +1,15 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte'
export let checked: boolean
const dispatcher = createEventDispatcher<{ change: boolean }>()
</script>
<label class="flex flex-row items-center gap-2 cursor-pointer text-sm">
<input
type="checkbox"
bind:checked
on:change={() => dispatcher('change', !checked)}
/>
<slot />
</label>
+40 -30
View File
@@ -1,40 +1,61 @@
<script lang="ts">
import Button from '$lib/components/input/Button.svelte'
import SelectMenu from '$lib/components/input/SelectMenu.svelte'
import { createEventDispatcher } from 'svelte'
import { ChevronDown, Icon } from 'svelte-hero-icons'
import Button from '$lib/components/input/Button.svelte'
import { createEventDispatcher } from 'svelte'
type T = $$Generic
export let options: T[]
export let disabled: boolean[] = []
export let optionNames: string[] = []
export let selected: T
export let headless: boolean = false
const dispatcher = createEventDispatcher<{ select: T }>()
$: dispatcher('select', selected)
$: {
dispatcher('select', selected)
}
let containerClass = `
flex flex-row items-center w-max max-w-full
${
headless
? 'pb-1'
: 'bg-slate-100 dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800 rounded-lg p-1'
}
gap-1
${$$props.class}
`
const buttonClass = (selected: boolean) => `
px-3 py-1.5 text-sm
${!selected ? 'hover:bg-slate-200 hover:dark:bg-zinc-800' : ''}
transition-colors rounded-md
${
selected
? headless
? ''
: 'bg-slate-900 text-slate-50 dark:bg-zinc-100 dark:text-black hover:bg-slate-800 hover:dark:bg-zinc-300'
: ''
}
disabled:opacity-60 disabled:pointer-events-none whitespace-nowrap
relative
`
</script>
<div
class="flex overflow-auto flex-row items-center max-w-full w-max bg-slate-100
rounded-lg dark:bg-zinc-900 gap-1 p-1 border border-slate-200 dark:border-zinc-800
{$$props.class}"
>
<div class={containerClass}>
{#each options.slice(0, 4) as option, index}
<button
class="px-3 py-1.5 text-sm rounded-md
transition-colors
{selected == option
? 'bg-slate-900 text-slate-50 dark:bg-zinc-100 dark:text-black\
hover:bg-slate-800 hover:dark:bg-zinc-300'
: ' hover:bg-slate-200 hover:dark:bg-zinc-800'}
disabled:opacity-60 disabled:pointer-events-none whitespace-nowrap"
class={buttonClass(selected == option)}
on:click={() => (selected = option)}
disabled={disabled[index] ?? false}
type="button"
>
{optionNames[index] || option}
{#if headless && option == selected}
<div
class="absolute -bottom-1 left-0 w-full border-b-2 rounded-t-sm border-black dark:border-white"
/>
{/if}
</button>
{/each}
{#if options.length > 4}
@@ -56,14 +77,3 @@
{/if}
</div>
<slot {selected} />
<style lang="postcss">
.custom-select {
@apply bg-slate-50 relative;
}
.custom-select select {
appearance: none;
@apply bg-inherit hidden;
}
</style>
+24 -7
View File
@@ -1,25 +1,42 @@
<script lang="ts">
import Button from '$lib/components/input/Button.svelte'
import { Color } from '$lib/ui/colors'
import Menu from '$lib/components/ui/menu/Menu.svelte'
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
import type { Alignment } from '$lib/components/ui/menu/menu.js'
import { createEventDispatcher } from 'svelte'
type T = $$Generic
export let options: T[]
export let optionNames: string[]
export let optionNames: string[] = []
export let selected: T
export let label: string | undefined = undefined
export let alignment: Alignment = 'bottom-left'
let open = false
const dispatcher = createEventDispatcher<{ select: T }>()
</script>
<Menu let:toggleOpen>
<Button slot="button" on:click={toggleOpen} color="tertiary" size="square-md">
<slot />
</Button>
{#if label}
<div class="block font-bold text-sm w-max">{label}</div>
{/if}
<Menu let:toggleOpen {alignment}>
<div slot="button" class="w-max relative">
<Button on:click={toggleOpen} color="secondary">
<slot>
{optionNames[options.findIndex((o) => selected == o)] || selected}
</slot>
</Button>
</div>
{#each options as option, index}
<MenuButton on:click={() => (selected = option)}>
<MenuButton
on:click={() => {
selected = option
dispatcher('select', option)
}}
>
{optionNames[index] || option}
</MenuButton>
{/each}
@@ -32,7 +32,7 @@
$: if (item) resetReason()
async function submit() {
if (!item || !$profile?.user || !community || !$profile?.jwt) return
if (!item || !$profile?.user || !$profile?.jwt) return
loading = true
@@ -63,15 +63,26 @@
}
}
await getClient().banFromCommunity({
auth: $profile.jwt,
ban: !banned,
community_id: community.id,
person_id: item.id,
reason: reason || undefined,
remove_data: deleteData,
expires: date ? Math.floor(date / 1000) : undefined,
})
if (community) {
await getClient().banFromCommunity({
auth: $profile.jwt,
ban: !banned,
community_id: community.id,
person_id: item.id,
reason: reason || undefined,
remove_data: deleteData,
expires: date ? Math.floor(date / 1000) : undefined,
})
} else {
await getClient().banPerson({
auth: $profile.jwt,
ban: !banned,
person_id: item.id,
reason: reason || undefined,
remove_data: deleteData,
expires: date ? Math.floor(date / 1000) : undefined,
})
}
open = false
@@ -94,7 +105,7 @@
}
</script>
<Modal bind:open>
<Modal bind:open class="max-w-xl w-full">
<h1 slot="title">{banned ? 'Unbanning' : 'Banning'} user</h1>
{#if item}
<form class="flex flex-col gap-4" on:submit|preventDefault={submit}>
@@ -102,6 +113,11 @@
<Avatar url={item.avatar} alt={item.name} width={24} />
<span class="font-bold">{item.name}</span>
</div>
<p>
{banned ? 'Unbanning' : 'Banning'} from {community
? community.name
: 'site'}
</p>
<TextArea
required
bind:value={reason}
@@ -63,7 +63,7 @@ export function remove(item: PostView | CommentView) {
}))
}
export function ban(banned: boolean, item: Person, community: Community) {
export function ban(banned: boolean, item: Person, community?: Community) {
modals.update((m) => ({
...m,
banning: {
+6 -2
View File
@@ -2,10 +2,14 @@
type CardColor = 'default' | 'warning' | 'error'
export let cardColor: CardColor = 'default'
export let elevation: 0 | 1 = 1
const getColor = (color: CardColor) => {
switch (color) {
case 'default':
return 'border border-slate-200 dark:border-zinc-800 dark:bg-zinc-900'
return elevation == 0
? 'border border-slate-200 dark:border-zinc-900 bg-slate-100 dark:bg-zinc-950'
: 'border border-slate-200 dark:border-zinc-800 bg-white dark:bg-zinc-900'
case 'warning':
return 'border border-yellow-300 dark:bg-yellow-950/30 dark:border-yellow-900 bg-yellow-50'
}
@@ -16,7 +20,7 @@
</script>
<div
class="bg-white break-words
class="break-words
{getColor(cardColor)} rounded-md {clazz}"
{...$$restProps}
>
+22 -6
View File
@@ -3,7 +3,10 @@
import Button from '$lib/components/input/Button.svelte'
import Link from '$lib/components/input/Link.svelte'
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
import { amModOfAny } from '$lib/components/lemmy/moderation/moderation.js'
import {
amModOfAny,
isAdmin,
} from '$lib/components/lemmy/moderation/moderation.js'
import Avatar from '$lib/components/ui/Avatar.svelte'
import Logo from '$lib/components/ui/Logo.svelte'
import Spinner from '$lib/components/ui/loader/Spinner.svelte'
@@ -17,6 +20,7 @@
Beaker,
Bookmark,
Cog6Tooth,
CommandLine,
GlobeAlt,
Icon,
Inbox,
@@ -82,10 +86,22 @@
</a>
</div>
<div class="flex flex-row gap-2 py-2 px-2">
{#if $profile?.user && isAdmin($profile.user)}
<Button
href="/admin"
aria-label="Admin"
class="max-md:w-9 max-md:h-8 max-md:!p-0
dark:text-zinc-300 text-slate-700 hover:text-inherit
hover:bg-slate-200 hover:dark:bg-zinc-900 relative"
>
<Icon src={CommandLine} mini size="16" slot="icon" />
<span class="hidden md:inline">Admin</span>
</Button>
{/if}
{#if amModOfAny($profile?.user)}
<Button
href="/moderation"
label="Search"
aria-label="Moderation"
class="max-md:w-9 max-md:h-8 max-md:!p-0 items-center justify-center
dark:text-zinc-300 text-slate-700 hover:text-inherit
hover:bg-slate-200 hover:dark:bg-zinc-900 relative"
@@ -95,13 +111,13 @@
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
/>
{/if}
<ShieldIcon width={15} />
<ShieldIcon filled width={15} />
<span class="hidden md:inline">Reports</span>
</Button>
{/if}
<Button
href="/search"
label="Search"
aria-label="Search"
class="max-md:w-9 max-md:h-8 max-md:!p-0 items-center justify-center
dark:text-zinc-300 text-slate-700 hover:text-inherit hover:bg-slate-200 hover:dark:bg-zinc-900"
>
@@ -110,7 +126,7 @@
</Button>
<Button
href="/communities"
label="Communities"
aria-label="Communities"
class="max-md:w-9 max-md:h-8 max-md:!p-0 items-center justify-center
dark:text-zinc-300 text-slate-700 hover:text-inherit hover:bg-slate-200 hover:dark:bg-zinc-900"
>
@@ -121,7 +137,7 @@
<Button
color="primary"
slot="button"
label="Create"
aria-label="Create"
on:click={toggleOpen}
class="max-md:w-9 max-md:h-8 max-md:!p-0"
>
+6 -2
View File
@@ -1,8 +1,12 @@
<div
class="text-slate-600 dark:text-zinc-400 flex flex-col justify-center items-center"
class="text-slate-600 dark:text-zinc-400 flex flex-col justify-center items-center gap-1"
>
<slot name="icon" />
{#if $$slots.title}
<h1 class="font-bold text-2xl"><slot name="title" /></h1>{/if}
<h1 class="font-bold text-3xl"><slot name="title" /></h1>
{/if}
{#if $$slots.description}
<p class="text-lg"><slot name="description" /></p>
{/if}
<slot name="action" />
</div>
@@ -0,0 +1,3 @@
<span class="text-sm font-bold text-slate-600 dark:text-zinc-400">
<slot />
</span>
+1 -1
View File
@@ -1,6 +1,6 @@
<aside
class="sticky top-16 break-words flex
flex-col gap-4 p-6 max-w-full w-96 max-h-[calc(100svh-4rem)]
flex-col gap-4 p-6 max-w-full w-80 max-h-[calc(100svh-4rem)]
overflow-auto text-sm border-slate-200 dark:border-zinc-800 {$$props.class}"
>
<slot />
+2 -9
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import type { Alignment } from '$lib/components/ui/menu/menu.js'
import { expoOut } from 'svelte/easing'
import { scale } from 'svelte/transition'
@@ -11,14 +12,6 @@
export let absolute = false
type Alignment =
| 'top-right'
| 'top-left'
| 'bottom-right'
| 'bottom-left'
| 'bottom-center'
| 'top-center'
export let alignment: Alignment = 'bottom-left'
let element: any
@@ -32,7 +25,7 @@
case 'bottom-left':
return 'top-[100%] origin-top-left'
case 'top-left':
return 'top-[100%] left-0 origin-top-left'
return 'bottom-[100%] left-0 origin-bottom-left'
case 'bottom-right':
return 'top-[100%] right-0 origin-top-right'
case 'top-center':
+7
View File
@@ -0,0 +1,7 @@
export type Alignment =
| 'top-right'
| 'top-left'
| 'bottom-right'
| 'bottom-left'
| 'bottom-center'
| 'top-center'
+6 -4
View File
@@ -68,10 +68,12 @@
{/if}
<PostFeed posts={data.posts.posts} />
</section>
<Pageination
page={data.page}
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
/>
<div class="mt-auto">
<Pageination
page={data.page}
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
/>
</div>
</div>
<aside class="hidden xl:block">
{#await data.streamed.site}
+18
View File
@@ -0,0 +1,18 @@
<script>
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
</script>
<div class="flex flex-col gap-4 h-full">
<MultiSelect
headless
options={['/admin/config', '/admin/applications', '/admin/taglines']}
optionNames={['Configuration', 'Applications', 'Taglines']}
selected={$page.url.pathname}
on:select={(e) => {
goto(e.detail)
}}
/>
<slot />
</div>
+21
View File
@@ -0,0 +1,21 @@
import { profile } from '$lib/auth.js'
import { get } from 'svelte/store'
import { getClient, site as siteStore } from '$lib/lemmy.js'
export async function load({ fetch }) {
if (!get(profile)) return
let { jwt } = get(profile)!
let site = get(siteStore)
if (!site) {
const res = await getClient(undefined, fetch).getSite({
auth: jwt,
})
site = res
}
return {
site: site,
}
}
+1
View File
@@ -0,0 +1 @@
You're not supposed to be here. You somehow avoided the redirect, nice.
+5
View File
@@ -0,0 +1,5 @@
import { redirect } from '@sveltejs/kit'
export const load = () => {
throw redirect(300, '/admin/config')
}
@@ -0,0 +1,46 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import Button from '$lib/components/input/Button.svelte'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import Card from '$lib/components/ui/Card.svelte'
import Pageination from '$lib/components/ui/Pageination.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import { searchParam } from '$lib/util.js'
import { ClipboardDocumentCheck, Icon } from 'svelte-hero-icons'
import Application from './Application.svelte'
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
export let data
</script>
<h1 class="font-bold text-2xl">Applications</h1>
<MultiSelect
options={[false, true]}
selected={data.unreadOnly ?? true}
optionNames={['All', 'Unread']}
on:select={(e) =>
searchParam($page.url, 'unreadOnly', e.detail.toString(), 'page')}
/>
{#if data.applications && data.applications.length > 0}
<div class="flex flex-col divide-y divide-slate-200 dark:divide-zinc-900">
{#each data.applications as application (application.registration_application.id)}
<Application {application} />
{/each}
</div>
{#if data.applications.length >= 40}
<div class="mt-auto">
<Pageination
page={data.page}
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
/>
</div>
{/if}
{:else}
<Placeholder>
<Icon src={ClipboardDocumentCheck} size="48" slot="icon" />
<span slot="title">No applications</span>
<span slot="description">You're all caught up for now.</span>
</Placeholder>
{/if}
+26
View File
@@ -0,0 +1,26 @@
import { profile } from '$lib/auth.js'
import { getClient } from '$lib/lemmy.js'
import { get } from 'svelte/store'
export async function load({ data, fetch, url }) {
if (!get(profile)) return
const { jwt } = get(profile)!
if (!jwt) return
const page = Number(url.searchParams.get('page')) || 1
const unreadOnly = (url.searchParams.get('unreadOnly') || 'true') == 'true'
const res = await getClient(undefined, fetch).listRegistrationApplications({
auth: jwt,
page: page,
limit: 40,
unread_only: unreadOnly,
})
return {
unreadOnly: unreadOnly,
page: page,
applications: res.registration_applications,
}
}
@@ -0,0 +1,105 @@
<script lang="ts">
import { profile } from '$lib/auth.js'
import Button from '$lib/components/input/Button.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 { toast } from '$lib/components/ui/toasts/toasts.js'
import { getClient } from '$lib/lemmy.js'
import type { RegistrationApplicationView } from 'lemmy-js-client'
import { Check, Icon, XMark } from 'svelte-hero-icons'
export let application: RegistrationApplicationView
let approving = false
let denying = false
async function review(approve: boolean) {
if (!$profile?.jwt) return
if (approve) {
approving = true
} else {
denying = true
}
try {
await getClient().approveRegistrationApplication({
approve: approve,
auth: $profile.jwt,
id: application.registration_application.id,
})
toast({
content: `Successfully ${
approve ? 'approved' : 'denied'
} that application.`,
type: 'success',
})
application.creator_local_user.accepted_application = approve
application.admin = $profile.user!.local_user_view.person
} catch (err) {
toast({
content: err as any,
type: 'error',
})
}
approving = false
denying = false
}
</script>
<Card elevation={0} class="p-4 flex flex-col gap-2">
<div class="flex flex-col gap-1">
<SectionTitle>User</SectionTitle>
<span class="text-sm">
<UserLink user={application.creator} avatar avatarSize={20} />
</span>
</div>
<div>
<SectionTitle>Application</SectionTitle>
<p>{application.registration_application.answer}</p>
</div>
<div class="flex flex-col md:flex-row gap-2 md:items-center">
{#if application.admin}
<div class="flex items-center gap-1">
<SectionTitle>
{application.creator_local_user.accepted_application
? 'Approved'
: 'Denied'} by
</SectionTitle>
<UserLink avatar user={application.admin} />
</div>
<div class="md:ml-auto" />
{/if}
<div class="ml-auto">
<Button
size="square-md"
class="hover:bg-slate-200 {!application.creator_local_user
.accepted_application
? 'text-red-500'
: ''}"
aria-label="Deny"
on:click={() => review(false)}
loading={denying}
disabled={approving || denying}
>
<Icon src={XMark} mini size="16" slot="icon" />
</Button>
<Button
size="square-md"
class="hover:bg-slate-200 {application.creator_local_user
.accepted_application
? 'text-green-500'
: ''}"
aria-label="Approve"
on:click={() => review(true)}
loading={approving}
disabled={approving || denying}
>
<Icon src={Check} mini size="16" slot="icon" />
</Button>
</div>
</div>
</Card>
+129
View File
@@ -0,0 +1,129 @@
<script lang="ts">
import { profile } from '$lib/auth.js'
import Button from '$lib/components/input/Button.svelte'
import Checkbox from '$lib/components/input/Checkbox.svelte'
import SelectMenu from '$lib/components/input/SelectMenu.svelte'
import TextArea from '$lib/components/input/TextArea.svelte'
import TextInput from '$lib/components/input/TextInput.svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { getClient } from '$lib/lemmy.js'
import type { EditSite } from 'lemmy-js-client'
import type { PageData } from './$types.js'
export let data: PageData
const site = {
...data.site?.site_view.site,
}
const local_site = {
...data.site?.site_view.local_site,
}
const h = {
fart: 'hey',
}
async function save() {
if (!$profile?.jwt) return
saving = true
const { jwt } = $profile
try {
await getClient().editSite({
auth: jwt,
name: site.name,
description: site.description,
sidebar: site.sidebar,
legal_information: local_site.legal_information,
enable_downvotes: local_site.enable_downvotes,
enable_nsfw: local_site.enable_nsfw,
registration_mode: local_site.registration_mode,
community_creation_admin_only: local_site.community_creation_admin_only,
require_email_verification: local_site.require_email_verification,
})
toast({
content: 'Updated your site.',
type: 'success',
})
} catch (err) {
toast({
content: err as any,
type: 'error',
})
}
saving = false
}
let saving = false
</script>
<svelte:head>
<title>Administration</title>
</svelte:head>
<form class="flex flex-col gap-4" on:submit|preventDefault={save}>
<h1 class="font-bold text-2xl">Site configuration</h1>
{#if site}
<TextInput bind:value={site.name} label="Name" />
<TextInput bind:value={site.description} label="Description" />
<MarkdownEditor previewButton bind:value={site.sidebar} label="Sidebar" />
{/if}
{#if local_site}
<MarkdownEditor
previewButton
bind:value={local_site.legal_information}
label="Legal"
/>
<Checkbox
checked={local_site.enable_downvotes ?? true}
on:change={(e) => {
local_site.enable_downvotes = !local_site.enable_downvotes
}}
>
Enable downvotes
</Checkbox>
<Checkbox
checked={local_site.enable_nsfw ?? true}
on:change={(e) => {
local_site.enable_nsfw = !local_site.enable_nsfw
}}
>
Enable NSFW
</Checkbox>
<SelectMenu
label="Registration mode"
alignment="top-left"
options={['Closed', 'RequireApplication', 'Open']}
optionNames={['Closed', 'Require Application', 'Open Registration']}
selected={local_site.registration_mode ?? 'Open'}
on:select={(e) => {
// @ts-ignore
local_site.registration_mode = e.detail
}}
/>
<Checkbox
checked={local_site.community_creation_admin_only ?? true}
on:change={(e) => {
local_site.community_creation_admin_only =
!local_site.community_creation_admin_only
}}
>
Only admins can create communities
</Checkbox>
<Checkbox
checked={local_site.require_email_verification ?? true}
on:change={(e) => {
local_site.require_email_verification =
!local_site.require_email_verification
}}
>
Require email verification
</Checkbox>
{/if}
<Button color="primary" size="lg" loading={saving} disabled={saving} submit>
Save
</Button>
</form>
View File
Whitespace-only changes.
+138
View File
@@ -0,0 +1,138 @@
<script lang="ts">
import { profile } from '$lib/auth.js'
import Button from '$lib/components/input/Button.svelte'
import TextInput from '$lib/components/input/TextInput.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import EditableList from '$lib/components/ui/list/EditableList.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { getClient } from '$lib/lemmy.js'
import { Icon, Plus, QuestionMarkCircle, Trash } from 'svelte-hero-icons'
export let data
let taglines = [...(data.site?.taglines.map((t) => t.content) ?? [])]
let newTagline = ''
let saving = false
async function save() {
if (!$profile?.jwt) return
saving = true
try {
await getClient().editSite({
auth: $profile.jwt,
taglines: taglines,
})
toast({
content: 'Successfully saved taglines.',
type: 'success',
})
} catch (err) {
toast({
content: err as any,
type: 'error',
})
}
saving = false
}
</script>
{#if taglines.length > 0}
<div class="flex flex-row justify-between items-center">
<h1 class="font-bold text-2xl">Taglines</h1>
<Button
color="primary"
on:click={save}
loading={saving}
disabled={saving}
size="lg"
class="h-max"
>
Save
</Button>
</div>
<EditableList
let:action
on:action={(e) => {
taglines.splice(
taglines.findIndex((i) => i == e.detail),
1
)
// hack for reactivity
taglines = taglines
}}
>
{#each taglines as tagline}
<div class="flex py-3">
<Markdown source={tagline} inline />
<div class="flex gap-2 ml-auto">
<Button on:click={() => action(tagline)} size="square-md">
<Icon src={Trash} mini size="16" />
</Button>
</div>
</div>
{/each}
</EditableList>
<form
class="flex flex-col mt-auto gap-2 w-full"
on:submit|preventDefault={() => {
if (newTagline == '' || !data.site) return
taglines = [...taglines, newTagline]
newTagline = ''
}}
>
<MarkdownEditor
bind:value={newTagline}
placeholder="Add a tagline"
images={false}
/>
<Button size="lg" submit>
<Icon src={Plus} size="16" mini slot="icon" />
Add one
</Button>
</form>
{:else}
<div class="my-auto">
<Placeholder>
<Icon src={QuestionMarkCircle} solid size="32" slot="icon" />
<span slot="title">No taglines</span>
<div slot="action" class="mt-4 max-w-xl w-full flex flex-col gap-2">
<form
class="flex flex-col gap-2 w-full"
on:submit|preventDefault={() => {
if (newTagline == '' || !data.site) return
taglines = [...taglines, newTagline]
newTagline = ''
}}
>
<MarkdownEditor
bind:value={newTagline}
placeholder="Add a tagline"
images={false}
/>
<Button size="lg" submit>
<Icon src={Plus} size="16" mini slot="icon" />
Add one
</Button>
</form>
<Button on:click={save} color="primary" size="lg" class="w-full">
Save
</Button>
</div>
</Placeholder>
</div>
{/if}
+8 -9
View File
@@ -9,6 +9,7 @@
import Pageination from '$lib/components/ui/Pageination.svelte'
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
import { profile } from '$lib/auth.js'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
export let data
@@ -81,16 +82,14 @@
}}
/>
</div>
<div class="flex flex-col gap-4 list-none my-4">
<div class="flex flex-col gap-4 list-none my-4 h-full">
{#if !data.data || (data.data?.length ?? 0) == 0}
<div
class="text-slate-600 dark:text-zinc-400 flex flex-col justify-center items-center py-8 gap-2"
>
<Icon src={EnvelopeOpen} size="48" />
<div>
<h1 class="font-bold text-3xl">Inbox empty</h1>
<p class="mt-2 text-center">You're all caught up!</p>
</div>
<div>
<Placeholder>
<Icon src={EnvelopeOpen} size="48" slot="icon" />
<span slot="title">Inbox empty</span>
<span slot="description">You're all caught up!</span>
</Placeholder>
</div>
{:else}
{#each data.data as item}
+17 -1
View File
@@ -12,6 +12,7 @@
Icon,
NoSymbol,
PencilSquare,
ShieldExclamation,
} from 'svelte-hero-icons'
import Button from '$lib/components/input/Button.svelte'
import CommentItem from '$lib/components/lemmy/comment/CommentItem.svelte'
@@ -27,10 +28,12 @@
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import TextArea from '$lib/components/input/TextArea.svelte'
import { profile } from '$lib/auth.js'
import { ban, isAdmin } from '$lib/components/lemmy/moderation/moderation.js'
export let data
let blocking = false
let banning = false
async function blockUser(block: number) {
if (!$profile?.user || !$profile?.jwt) throw new Error('Unauthenticated')
@@ -177,7 +180,7 @@
</div>
<div class="mx-auto">
<StickyCard class="w-full">
<StickyCard>
<Avatar
width={64}
url={data.person_view.person.avatar}
@@ -211,6 +214,19 @@
<Icon slot="icon" solid size="16" src={Envelope} />
Message
</Button>
{#if isAdmin($profile?.user)}
<Button
size="lg"
color="danger"
loading={banning}
disabled={banning}
on:click={() =>
ban(data.person_view.person.banned, data.person_view.person)}
>
<Icon slot="icon" mini size="16" src={ShieldExclamation} />
{data.person_view.person.banned ? 'Unban' : 'Ban'}
</Button>
{/if}
<Button
size="lg"
color="danger"
+2
View File
@@ -5,11 +5,13 @@
:root {
@apply bg-slate-50 dark:bg-zinc-950 text-slate-900
dark:text-zinc-100 !important;
accent-color: #000;
}
@media (prefers-color-scheme: dark) {
:root {
color-scheme: dark;
accent-color: #fff;
}
}