feat: add admin team list
This commit is contained in:
1 parent
1e4e9ae1de
commit
d9bcfb5525
2 files changed
+75
-2
No files matched your search
@@ -7,8 +7,13 @@
|
|||||||
<div class="flex flex-col gap-4 h-full">
|
<div class="flex flex-col gap-4 h-full">
|
||||||
<MultiSelect
|
<MultiSelect
|
||||||
headless
|
headless
|
||||||
options={['/admin/config', '/admin/applications', '/admin/taglines']}
|
options={[
|
||||||
optionNames={['Configuration', 'Applications', 'Taglines']}
|
'/admin/config',
|
||||||
|
'/admin/applications',
|
||||||
|
'/admin/taglines',
|
||||||
|
'/admin/team',
|
||||||
|
]}
|
||||||
|
optionNames={['Configuration', 'Applications', 'Taglines', 'Team']}
|
||||||
selected={$page.url.pathname}
|
selected={$page.url.pathname}
|
||||||
on:select={(e) => {
|
on:select={(e) => {
|
||||||
goto(e.detail)
|
goto(e.detail)
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { goto } from '$app/navigation'
|
||||||
|
import { profile } from '$lib/auth.js'
|
||||||
|
import Button from '$lib/components/input/Button.svelte'
|
||||||
|
import UserLink from '$lib/components/lemmy/user/UserLink.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'
|
||||||
|
|
||||||
|
export let data
|
||||||
|
|
||||||
|
let leaving = false
|
||||||
|
|
||||||
|
async function leaveTeam() {
|
||||||
|
if (!$profile?.jwt || !$profile?.user) return
|
||||||
|
|
||||||
|
leaving = true
|
||||||
|
$profile.user.local_user_view.person.admin = false
|
||||||
|
|
||||||
|
try {
|
||||||
|
await getClient().leaveAdmin({
|
||||||
|
auth: $profile.jwt,
|
||||||
|
})
|
||||||
|
|
||||||
|
toast({
|
||||||
|
content: 'You have left the admin team.',
|
||||||
|
type: 'success',
|
||||||
|
})
|
||||||
|
|
||||||
|
goto('/')
|
||||||
|
} catch (err) {
|
||||||
|
toast({
|
||||||
|
content: err as any,
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
leaving = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1 class="font-bold text-2xl">Admins</h1>
|
||||||
|
<p class="text-slate-600 dark:text-zinc-400">
|
||||||
|
Remove admins on their user page.
|
||||||
|
</p>
|
||||||
|
<EditableList>
|
||||||
|
{#each data.site?.admins ?? [] as admin}
|
||||||
|
<div class="py-4 flex items-center">
|
||||||
|
<UserLink avatar showInstance={false} user={admin.person} />
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</EditableList>
|
||||||
|
<Button
|
||||||
|
color="danger"
|
||||||
|
class="mt-auto ml-auto"
|
||||||
|
size="lg"
|
||||||
|
loading={leaving}
|
||||||
|
disabled={leaving}
|
||||||
|
on:click={() => {
|
||||||
|
toast({
|
||||||
|
content: 'Are you sure you want to leave the admin team?',
|
||||||
|
action: leaveTeam,
|
||||||
|
duration: 60 * 1000,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Leave the admin team
|
||||||
|
</Button>
|
||||||
Reference in new issue
Block a user