migrate: convert most components to svelte 5
This commit is contained in:
1 parent
d670f39f0a
commit
10ef4123da
225 files changed
+5441
-3341
No files matched your search
@@ -4,6 +4,13 @@
|
||||
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
import { Badge } from 'mono-svelte'
|
||||
/**
|
||||
* @typedef {Object} Props
|
||||
* @property {import('svelte').Snippet} [children]
|
||||
*/
|
||||
|
||||
/** @type {Props} */
|
||||
let { children } = $props();
|
||||
</script>
|
||||
|
||||
{#if $notifications.applications > 0}
|
||||
@@ -44,5 +51,5 @@
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<slot />
|
||||
{@render children?.()}
|
||||
</div>
|
||||
@@ -9,7 +9,7 @@
|
||||
import { t } from '$lib/translations'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
export let data
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<Header pageHeader>{$t('routes.admin.applications.title')}</Header>
|
||||
|
||||
@@ -15,12 +15,16 @@
|
||||
import ApplicationDenyModal from '$lib/components/lemmy/modal/ApplicationDenyModal.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
|
||||
export let application: RegistrationApplicationView
|
||||
interface Props {
|
||||
application: RegistrationApplicationView;
|
||||
}
|
||||
|
||||
let approving = false
|
||||
let denying = false
|
||||
let denyReason = ''
|
||||
let reviewing = false
|
||||
let { application = $bindable() }: Props = $props();
|
||||
|
||||
let approving = $state(false)
|
||||
let denying = $state(false)
|
||||
let denyReason = $state('')
|
||||
let reviewing = $state(false)
|
||||
|
||||
async function review(approve: boolean) {
|
||||
if (!$profile?.jwt) return
|
||||
@@ -114,7 +118,7 @@
|
||||
</div>
|
||||
<p>{application.registration_application.deny_reason}</p>
|
||||
</div>
|
||||
<div class="md:ml-auto" />
|
||||
<div class="md:ml-auto"></div>
|
||||
{:else}
|
||||
<div class="flex items-center gap-1 text-sm">
|
||||
<UserLink avatar user={application.admin} />
|
||||
@@ -124,7 +128,7 @@
|
||||
: $t('routes.admin.applications.denied')}
|
||||
</SectionTitle>
|
||||
</div>
|
||||
<div class="md:ml-auto" />
|
||||
<div class="md:ml-auto"></div>
|
||||
{/if}
|
||||
{/if}
|
||||
<div class="ml-auto self-end">
|
||||
@@ -139,7 +143,9 @@
|
||||
loading={denying || reviewing}
|
||||
disabled={approving || denying || reviewing}
|
||||
>
|
||||
<Icon src={XMark} mini size="16" slot="prefix" />
|
||||
{#snippet prefix()}
|
||||
<Icon src={XMark} mini size="16" />
|
||||
{/snippet}
|
||||
</Button>
|
||||
<Button
|
||||
size="square-md"
|
||||
@@ -152,7 +158,9 @@
|
||||
loading={approving}
|
||||
disabled={approving || denying || reviewing}
|
||||
>
|
||||
<Icon src={Check} mini size="16" slot="prefix" />
|
||||
{#snippet prefix()}
|
||||
<Icon src={Check} mini size="16" />
|
||||
{/snippet}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
|
||||
import { profile } from '$lib/auth.js'
|
||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||
import { Label, Switch, toast } from 'mono-svelte'
|
||||
@@ -11,14 +13,18 @@
|
||||
import { t } from '$lib/translations.js'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
export let data: PageData
|
||||
interface Props {
|
||||
data: PageData;
|
||||
}
|
||||
|
||||
const formData: Omit<EditSite, 'auth'> | undefined = data.site
|
||||
let { data }: Props = $props();
|
||||
|
||||
const formData: Omit<EditSite, 'auth'> | undefined = $state(data.site
|
||||
? {
|
||||
...data.site.site_view.local_site,
|
||||
...data.site.site_view.site,
|
||||
}
|
||||
: undefined
|
||||
: undefined)
|
||||
|
||||
async function save() {
|
||||
if (!$profile?.jwt) return
|
||||
@@ -44,19 +50,19 @@
|
||||
saving = false
|
||||
}
|
||||
|
||||
let saving = false
|
||||
let saving = $state(false)
|
||||
|
||||
let uploading = {
|
||||
let uploading = $state({
|
||||
icon: false,
|
||||
banner: false,
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{$t('routes.admin.title')}</title>
|
||||
</svelte:head>
|
||||
|
||||
<form class="flex flex-col gap-4" on:submit|preventDefault={save}>
|
||||
<form class="flex flex-col gap-4" onsubmit={preventDefault(save)}>
|
||||
<Header pageHeader>{$t('routes.admin.config.title')}</Header>
|
||||
{#if formData}
|
||||
<TextInput bind:value={formData.name} label={$t('form.name')} />
|
||||
@@ -78,7 +84,7 @@
|
||||
<Label>{$t('routes.admin.config.icon')}</Label>
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => (uploading.icon = !uploading.icon)}
|
||||
onclick={() => (uploading.icon = !uploading.icon)}
|
||||
class="flex flex-col gap-4 bg-white dark:bg-black border border-slate-300 dark:border-zinc-800 p-4 w-full h-32 rounded-xl"
|
||||
>
|
||||
{#if formData.icon}
|
||||
@@ -106,7 +112,7 @@
|
||||
<Label>{$t('routes.admin.config.banner')}</Label>
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => (uploading.banner = !uploading.banner)}
|
||||
onclick={() => (uploading.banner = !uploading.banner)}
|
||||
class="flex flex-col gap-4 bg-white dark:bg-black border border-slate-300 dark:border-zinc-800 p-4 w-full h-32 rounded-xl"
|
||||
>
|
||||
{#if formData.banner}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { run, preventDefault } from 'svelte/legacy';
|
||||
|
||||
import { profile } from '$lib/auth.js'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
@@ -29,17 +31,17 @@
|
||||
import { expoInOut, expoOut } from 'svelte/easing'
|
||||
import { slide } from 'svelte/transition'
|
||||
|
||||
export let data
|
||||
let { data = $bindable() } = $props();
|
||||
|
||||
let blockInstance = {
|
||||
let blockInstance = $state({
|
||||
instance: '',
|
||||
loading: false,
|
||||
},
|
||||
allowInstance = {
|
||||
}),
|
||||
allowInstance = $state({
|
||||
instance: '',
|
||||
loading: false,
|
||||
},
|
||||
saving = false
|
||||
}),
|
||||
saving = $state(false)
|
||||
|
||||
const moderateInstance = async (instance: string, blocked: boolean) => {
|
||||
if (instance == '') return
|
||||
@@ -117,7 +119,7 @@
|
||||
saving = false
|
||||
}
|
||||
|
||||
let csv: FileList | null
|
||||
let csv: FileList | null = $state()
|
||||
|
||||
async function parseCsv(files: FileList) {
|
||||
if (!(files.length > 0)) return
|
||||
@@ -162,9 +164,9 @@
|
||||
reader.readAsText(files[0])
|
||||
}
|
||||
|
||||
$: {
|
||||
run(() => {
|
||||
if (csv) parseCsv(csv)
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -179,20 +181,26 @@
|
||||
</Header>
|
||||
{#if data.site && data.federated_instances?.federated_instances?.blocked}
|
||||
<FileInput preview={false} bind:files={csv}>
|
||||
<Button class="w-max" slot="button">
|
||||
<Icon src={Plus} mini size="18" slot="prefix" />
|
||||
{$t('routes.admin.federation.csv')}
|
||||
</Button>
|
||||
<svelte:fragment slot="choose">
|
||||
{''}
|
||||
</svelte:fragment>
|
||||
{#snippet button()}
|
||||
<Button class="w-max" >
|
||||
{#snippet prefix()}
|
||||
<Icon src={Plus} mini size="18" />
|
||||
{/snippet}
|
||||
{$t('routes.admin.federation.csv')}
|
||||
</Button>
|
||||
{/snippet}
|
||||
{#snippet choose()}
|
||||
|
||||
{''}
|
||||
|
||||
{/snippet}
|
||||
</FileInput>
|
||||
<div class="flex flex-col md:flex-row gap-4">
|
||||
<div class="flex-1 w-full max-h-[42rem] h-full flex flex-col gap-2">
|
||||
<h2 class="font-bold text-lg">{$t('routes.admin.federation.blocked')}</h2>
|
||||
<form
|
||||
on:submit|preventDefault={() =>
|
||||
moderateInstance(blockInstance.instance, true)}
|
||||
onsubmit={preventDefault(() =>
|
||||
moderateInstance(blockInstance.instance, true))}
|
||||
class="flex flex-row gap-2"
|
||||
>
|
||||
<TextInput
|
||||
@@ -242,7 +250,9 @@
|
||||
)
|
||||
}}
|
||||
>
|
||||
<Icon src={XMark} size="16" mini slot="prefix" />
|
||||
{#snippet prefix()}
|
||||
<Icon src={XMark} size="16" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
</div>
|
||||
{/each}
|
||||
@@ -261,13 +271,15 @@
|
||||
<span>{$t('routes.admin.federation.allowed')}</span>
|
||||
{#if allowInstance.instance || !(data.federated_instances.federated_instances.allowed?.length == 0)}
|
||||
<Popover openOnHover placement="bottom-end">
|
||||
<Icon
|
||||
src={ExclamationTriangle}
|
||||
solid
|
||||
class="text-yellow-500"
|
||||
slot="target"
|
||||
size="20"
|
||||
/>
|
||||
{#snippet target()}
|
||||
<Icon
|
||||
src={ExclamationTriangle}
|
||||
solid
|
||||
class="text-yellow-500"
|
||||
|
||||
size="20"
|
||||
/>
|
||||
{/snippet}
|
||||
<p class="font-normal">
|
||||
{$t('routes.admin.federation.emptyAllow.description')}
|
||||
</p>
|
||||
@@ -275,8 +287,8 @@
|
||||
{/if}
|
||||
</h2>
|
||||
<form
|
||||
on:submit|preventDefault={() =>
|
||||
moderateInstance(allowInstance.instance, false)}
|
||||
onsubmit={preventDefault(() =>
|
||||
moderateInstance(allowInstance.instance, false))}
|
||||
class="flex flex-row gap-2"
|
||||
>
|
||||
<TextInput
|
||||
@@ -322,7 +334,9 @@
|
||||
)
|
||||
}}
|
||||
>
|
||||
<Icon src={XMark} size="16" mini slot="prefix" />
|
||||
{#snippet prefix()}
|
||||
<Icon src={XMark} size="16" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
|
||||
import { profile } from '$lib/auth.js'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||
@@ -12,12 +14,12 @@
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import { t } from '$lib/translations.js'
|
||||
|
||||
export let data
|
||||
let { data } = $props();
|
||||
|
||||
let taglines = [...(data.site?.taglines.map((t: Tagline) => t.content) ?? [])]
|
||||
let newTagline = ''
|
||||
let taglines = $state([...(data.site?.taglines.map((t: Tagline) => t.content) ?? [])])
|
||||
let newTagline = $state('')
|
||||
|
||||
let saving = false
|
||||
let saving = $state(false)
|
||||
|
||||
async function save() {
|
||||
if (!$profile?.jwt) return
|
||||
@@ -58,7 +60,7 @@
|
||||
</Header>
|
||||
|
||||
<EditableList
|
||||
let:action
|
||||
|
||||
on:action={(e) => {
|
||||
taglines.splice(
|
||||
taglines.findIndex((i) => i == e.detail),
|
||||
@@ -69,32 +71,36 @@
|
||||
taglines = taglines
|
||||
}}
|
||||
>
|
||||
{#each taglines as tagline}
|
||||
<div class="flex py-3">
|
||||
<Markdown source={tagline} inline />
|
||||
{#snippet children({ action })}
|
||||
{#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 class="flex gap-2 ml-auto">
|
||||
<Button on:click={() => action(tagline)} size="square-md">
|
||||
<Icon src={Trash} mini size="16" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</EditableList>
|
||||
{/each}
|
||||
{/snippet}
|
||||
</EditableList>
|
||||
<form
|
||||
class="flex flex-col mt-auto gap-2 w-full"
|
||||
on:submit|preventDefault={() => {
|
||||
onsubmit={preventDefault(() => {
|
||||
if (newTagline == '' || !data.site) return
|
||||
|
||||
taglines = [...taglines, newTagline]
|
||||
|
||||
newTagline = ''
|
||||
}}
|
||||
})}
|
||||
>
|
||||
<MarkdownEditor bind:value={newTagline} images={false} />
|
||||
|
||||
<Button size="lg" submit>
|
||||
<Icon src={Plus} size="16" mini slot="prefix" />
|
||||
{#snippet prefix()}
|
||||
<Icon src={Plus} size="16" mini />
|
||||
{/snippet}
|
||||
{$t('common.add')}
|
||||
</Button>
|
||||
</form>
|
||||
@@ -108,13 +114,13 @@
|
||||
<div 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={() => {
|
||||
onsubmit={preventDefault(() => {
|
||||
if (newTagline == '' || !data.site) return
|
||||
|
||||
taglines = [...taglines, newTagline]
|
||||
|
||||
newTagline = ''
|
||||
}}
|
||||
})}
|
||||
>
|
||||
<MarkdownEditor
|
||||
bind:value={newTagline}
|
||||
@@ -123,7 +129,9 @@
|
||||
/>
|
||||
|
||||
<Button size="lg" submit>
|
||||
<Icon src={Plus} size="16" mini slot="prefix" />
|
||||
{#snippet prefix()}
|
||||
<Icon src={Plus} size="16" mini />
|
||||
{/snippet}
|
||||
{$t('common.add')}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
|
||||
import { profile } from '$lib/auth.js'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
@@ -13,10 +15,10 @@
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import { t } from '$lib/translations.js'
|
||||
|
||||
export let data
|
||||
let { data = $bindable() } = $props();
|
||||
|
||||
let newAdmin: string = '',
|
||||
adding: boolean = false
|
||||
let newAdmin: string = $state(''),
|
||||
adding: boolean = $state(false)
|
||||
|
||||
async function removeAdmin(id: number, confirm: boolean): Promise<any> {
|
||||
if (!confirm)
|
||||
@@ -46,27 +48,29 @@
|
||||
|
||||
<Header pageHeader>{$t('routes.admin.team.title')}</Header>
|
||||
{#if data.site}
|
||||
<EditableList let:action on:action={(e) => removeAdmin(e.detail, false)}>
|
||||
{#if data.site.admins.length <= 0}
|
||||
<Placeholder
|
||||
icon={QuestionMarkCircle}
|
||||
title={$t('routes.admin.team.empty.title')}
|
||||
description={$t('routes.admin.team.empty.description')}
|
||||
/>
|
||||
{:else}
|
||||
{#each data.site?.admins ?? [] as admin}
|
||||
<div class="py-3 flex items-center justify-between">
|
||||
<UserLink avatar showInstance={false} user={admin.person} />
|
||||
<Button on:click={() => action(admin.person.id)} size="square-md">
|
||||
<Icon src={Trash} mini size="16" />
|
||||
</Button>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
</EditableList>
|
||||
<EditableList on:action={(e) => removeAdmin(e.detail, false)}>
|
||||
{#snippet children({ action })}
|
||||
{#if data.site.admins.length <= 0}
|
||||
<Placeholder
|
||||
icon={QuestionMarkCircle}
|
||||
title={$t('routes.admin.team.empty.title')}
|
||||
description={$t('routes.admin.team.empty.description')}
|
||||
/>
|
||||
{:else}
|
||||
{#each data.site?.admins ?? [] as admin}
|
||||
<div class="py-3 flex items-center justify-between">
|
||||
<UserLink avatar showInstance={false} user={admin.person} />
|
||||
<Button on:click={() => action(admin.person.id)} size="square-md">
|
||||
<Icon src={Trash} mini size="16" />
|
||||
</Button>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
{/snippet}
|
||||
</EditableList>
|
||||
<form
|
||||
class="flex flex-row items-center gap-2 mt-auto w-full"
|
||||
on:submit|preventDefault={() => {
|
||||
onsubmit={preventDefault(() => {
|
||||
trycatch(async () => {
|
||||
if (!$profile?.jwt || newAdmin == '') return
|
||||
adding = true
|
||||
@@ -84,7 +88,7 @@
|
||||
newAdmin = ''
|
||||
adding = false
|
||||
})
|
||||
}}
|
||||
})}
|
||||
>
|
||||
<TextInput
|
||||
bind:value={newAdmin}
|
||||
@@ -93,7 +97,9 @@
|
||||
pattern={'@[^ |]{1,}'}
|
||||
/>
|
||||
<Button loading={adding} disabled={adding} size="md" class="h-full" submit>
|
||||
<Icon src={Plus} mini size="16" slot="prefix" />
|
||||
{#snippet prefix()}
|
||||
<Icon src={Plus} mini size="16" />
|
||||
{/snippet}
|
||||
{$t('common.add')}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
Reference in new issue
Block a user