Merge branch 'main' into main

This commit is contained in:
Xylight authored and GitHub committed 2024-07-11 15:46:43 -07:00
commit e0c9c07e84
138 files changed
+17608 -2197

No files matched your search

@@ -1,5 +1,5 @@
<div
class="flex flex-col divide-y divide-zinc-800 [&>*]:py-3 first:p-0 last:py-0"
class="flex flex-col divide-y divide-slate-200 dark:divide-zinc-800 [&>*]:py-3 first:p-0 last:py-0"
>
<slot />
</div>
@@ -17,6 +17,7 @@
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { Button } from 'mono-svelte'
import Entity from '$lib/components/ui/Entity.svelte'
import { t } from '$lib/translations.js'
// sveltekit doesn't feel like making types work right now
export let data: PageData & {
@@ -81,7 +82,7 @@
{#if data.community_blocks?.length > 0 || data.person_blocks?.length > 0 || (data.my_user?.instance_blocks?.length ?? 0) > 0}
{#if data.my_user?.instance_blocks && (data.my_user?.instance_blocks?.length ?? 0) > 0}
<div>
<SectionTitle>Instances</SectionTitle>
<SectionTitle>{$t('content.instances')}</SectionTitle>
<EditableList let:action on:action={(i) => unblockInstances(i.detail)}>
{#each data.my_user?.instance_blocks as block (block.instance.id)}
<div
@@ -105,17 +106,10 @@
{/each}
</EditableList>
</div>
{:else}
<Placeholder
description="Go to a community's page and click 'block instance' to stop seeing posts and
comments from its instance."
title="No blocked instances"
center={false}
/>
{/if}
{#if data.community_blocks?.length > 0}
<div>
<SectionTitle>Communities</SectionTitle>
<SectionTitle>{$t('content.communities')}</SectionTitle>
<EditableList let:action on:action={(i) => unblockCommunity(i.detail)}>
{#each data.community_blocks as block (block.community.id)}
<div
@@ -135,17 +129,10 @@
{/each}
</EditableList>
</div>
{:else}
<Placeholder
description="Go to a community's page and click 'block' to stop seeing posts and
comments from it."
title="No blocked communities"
center={false}
/>
{/if}
{#if data.person_blocks?.length > 0}
<div>
<SectionTitle>Users</SectionTitle>
<SectionTitle>{$t('content.users')}</SectionTitle>
<EditableList let:action on:action={(i) => unblockUser(i.detail)}>
{#each data.person_blocks as block (block.target.id)}
<div
@@ -165,20 +152,5 @@
{/each}
</EditableList>
</div>
{:else}
<Placeholder
description="Go to a user's profile and click 'block' to stop seeing posts and
comments from them."
title="No blocked users"
center={false}
/>
{/if}
{:else}
<div class="my-auto">
<Placeholder
description="Go to a community or user's page and click 'block' to stop seeing submissions from it."
title="No blocks"
center={false}
/>
</div>
{/if}
@@ -10,6 +10,8 @@
import Switch from '$lib/components/input/Switch.svelte'
import { feature } from '$lib/version.js'
import QrCode from "svelte-qrcode"
import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let data
@@ -40,12 +42,12 @@
await setUser(res.jwt, instance, username!)
$currentInstance = instance
toast({ content: 'Your login was refreshed.', type: 'success' })
toast({ content: $t('toast.loginRefresh'), type: 'success' })
} else {
throw new Error('Invalid credentials')
throw new Error($t('toast.invalidLogin'))
}
toast({ content: 'Successfully changed your password. ' })
toast({ content: $t('toast.passwordReset') })
} catch (e) {
toast({
content: e as any,
@@ -84,84 +86,91 @@
</script>
<h1 class="font-bold text-3xl">Credentials</h1>
<h1 class="font-bold text-3xl">{$t('routes.profile.credentials')}</h1>
<div class="flex flex-row flex-wrap gap-8">
<div class="flex flex-col gap-2 max-w-sm w-full">
<h1 class="font-bold text-2xl">Password</h1>
<h1 class="font-bold text-2xl">{$t('form.password')}</h1>
<form
on:submit|preventDefault={changePassword}
class="max-w-sm flex flex-col gap-4"
>
<TextInput
bind:value={oldPassword}
label="Current Password"
label={$t('form.profile.currentPassword')}
type="password"
minlength={10}
required
/>
<TextInput
bind:value={newPassword}
label="New Password"
label={$t('form.profile.newPassword')}
type="password"
minlength={10}
required
/>
<TextInput
bind:value={newPasswordVerify}
label="New Password (Verify)"
label={$t('form.profile.verifyNewPassword')}
type="password"
minlength={10}
required
/>
<Button size="lg" color="primary" submit {loading} disabled={loading}>
Submit
{$t('form.submit')}
</Button>
</form>
</div>
<div class="flex flex-col gap-4 max-w-sm w-full">
<h1 class="font-bold text-2xl">2FA</h1>
<Header>{$t('form.profile.2fa.2fa')}</Header>
<p>
2FA is <span class="font-bold">
{totpEnabled ? 'enabled' : 'disabled'}
<span class="font-bold">
{totpEnabled ? $t('common.enabled') : $t('common.disabled')}
</span>
</p>
{#if totpEnabled || totpLink}
{#if totpLink && !totpEnabled}
<span class="font-normal text-xs">Scan this code using your authenticator app or add it manually</span>
<QrCode value={totpLink} size=1024/>
<TextInput disabled type="password" value={totpLink} label="TOTP Link">
<QrCode value={totpLink} size=768/>
<TextInput
disabled
type="password"
value={totpLink}
label={$t('form.profile.2fa.totp')}
>
<button
slot="suffix"
class="contents"
on:click={() => {
if (!totpLink) return
navigator.clipboard?.writeText(totpLink)
toast({ content: 'Copied to clipboard.' })
toast({ content: $t('toast.copied') })
}}
>
<Icon src={ClipboardDocument} size="20" mini />
</button>
<Icon src={ClipboardDocument} size="20" mini />
</button>
<span class="font-normal text-xs">
{$t('form.profile.2fa.paste')}
</span>
</TextInput>
{/if}
<form class="flex flex-col gap-2" on:submit|preventDefault={() => {}}>
<TextInput
bind:value={verify_totp}
placeholder="012345"
label="2FA Code"
label={$t('form.2fa')}
/>
{#if totpEnabled}
<Button on:click={() => twofa(false, true)} size="lg" color="primary">
Disable
{$t('common.disabled')}
</Button>
{:else}
<Button on:click={() => twofa(true, true)} size="lg" color="primary">
Enable
{$t('common.enabled')}
</Button>
{/if}
</form>
{:else}
<Button on:click={() => twofa(true)} size="lg" color="primary">
Setup
{$t('form.setup')}
</Button>
{/if}
</div>
@@ -7,6 +7,8 @@
import type { SaveUserSettings } from 'lemmy-js-client'
import { Button, Checkbox, Modal, TextInput } from 'mono-svelte'
import { uploadImage } from '$lib/util.js'
import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let data
@@ -39,8 +41,7 @@
})
toast({
content:
'Saved your user settings. If you changed your email, a verification email will have been sent.',
content: $t('toast.saveSettings'),
type: 'success',
})
} catch (err) {
@@ -63,21 +64,21 @@
switch (level) {
case 0: {
toast({
content: 'Are you sure you want to delete your account?',
content: $t('toast.confirmDelete1'),
action: () => deleteAccount(1),
})
return
}
case 1: {
toast({
content: 'Are you really sure?',
content: $t('toast.confirmDelete2'),
action: () => deleteAccount(2),
})
return
}
case 2: {
toast({
content: 'Final warning. Are you reeeeeeally sure?',
content: $t('toast.confirmDelete3'),
action: () => deleteAccount(3),
})
return
@@ -91,13 +92,13 @@
if (!(deletion.password || null)) {
toast({
content: 'You must provide your password.',
content: $t('toast.needPassword'),
type: 'warning',
})
}
const id = toast({
content: 'You did this. Deleting account...',
content: $t('toast.deleting'),
loading: true,
})
@@ -119,7 +120,7 @@
setUserID(-1)
toast({
content: 'Your account was deleted.',
content: $t('toast.deleted'),
})
goto('/')
} catch (err) {
@@ -141,50 +142,58 @@
action="Submit"
on:action={() => deleteAccount(4)}
>
<span slot="title">Delete account</span>
<span slot="title">{$t('form.profile.deleteAccount.label')}</span>
<TextInput
label="Password"
label={$t('form.password')}
type="password"
bind:value={deletion.password}
/>
<Checkbox bind:checked={deletion.deleteContent}>
Delete content
{$t('form.profile.deleteAccount.deleteContent')}
<span slot="description">
This will delete ALL of your account's posts and comments.
{$t('form.profile.deleteAccount.warning')}
</span>
</Checkbox>
</Modal>
{/if}
<form class="flex flex-col gap-4 h-full" on:submit|preventDefault={save}>
<h1 class="font-bold text-2xl">User settings</h1>
<Header>{$t('routes.profile.settings')}</Header>
{#if data.my_user?.local_user_view?.local_user && formData}
<TextInput
label="Display name"
label={$t('form.profile.displayName')}
bind:value={formData.display_name}
placeholder="Optional"
/>
<MarkdownEditor
images={false}
bind:value={formData.bio}
label="Bio"
label={$t('form.profile.bio')}
previewButton
/>
<ImageInput label="Profile Image" bind:files={profileImage} />
<ImageInput label="Banner Image" bind:files={bannerImage} />
<TextInput label="Email" bind:value={formData.email} />
<ImageInput label={$t('form.profile.avatar')} bind:files={profileImage} />
<ImageInput label={$t('form.profile.banner')} bind:files={bannerImage} />
<TextInput label={$t('form.profile.email')} bind:value={formData.email} />
<TextInput
label="Matrix User"
label={$t('form.profile.matrix')}
bind:value={formData.matrix_user_id}
placeholder="@user:example.com"
/>
<Checkbox bind:checked={formData.show_nsfw}>Show NSFW content</Checkbox>
<Checkbox bind:checked={formData.show_scores}>Show Scores</Checkbox>
<Checkbox bind:checked={formData.bot_account}>Bot Account</Checkbox>
<Checkbox bind:checked={formData.show_nsfw}>
{$t('form.profile.showNSFW')}
</Checkbox>
<Checkbox bind:checked={formData.show_scores}>
{$t('form.profile.scores')}
</Checkbox>
<Checkbox bind:checked={formData.bot_account}>
{$t('form.profile.bot')}
</Checkbox>
<Checkbox bind:checked={formData.show_bot_accounts}>
Show Bot Accounts
{$t('form.profile.showBots')}
</Checkbox>
<Checkbox bind:checked={formData.show_read_posts}>
{$t('form.profile.showRead')}
</Checkbox>
<Checkbox bind:checked={formData.show_read_posts}>Show Read Posts</Checkbox>
<Button
submit
@@ -194,10 +203,8 @@
{loading}
disabled={loading}
>
Save
{$t('common.save')}
</Button>
{:else}
<Material padding="lg">The API didn't return your user settings.</Material>
{/if}
<Button
on:click={() => deleteAccount(0)}
@@ -205,6 +212,6 @@
size="lg"
class="ml-auto"
>
Delete account
{$t('form.profile.deleteAccount.label')}
</Button>
</form>
+8 -2
View File
@@ -3,10 +3,11 @@
import { page } from '$app/stores'
import MultiSelect from '$lib/components/input/Switch.svelte'
import { t } from '$lib/translations'
</script>
<svelte:head>
<title>Profile</title>
<title>{$t('profile.profile')}</title>
</svelte:head>
<div class="flex flex-col gap-4 h-full z-0">
@@ -17,7 +18,12 @@
'/profile/blocks',
'/profile/password',
]}
optionNames={['User', 'Settings', 'Blocks', 'Credentials']}
optionNames={[
$t('routes.profile.user'),
$t('routes.profile.settings'),
$t('routes.profile.blocks'),
$t('routes.profile.credentials'),
]}
selected={$page.url.pathname}
on:select={(e) => {
goto(e.detail)