Expand shared profile and about dialogs
Lint / Lint (Go) (push) Successful in 17s
Lint / Lint (Python) (push) Successful in 9s
Tests / Test (Node/Svelte) (push) Successful in 13s
Tests / Test (Go) (push) Successful in 17s
Tests / Test (Python) (push) Successful in 9s
Lint / Lint (Node/Svelte) (push) Successful in 14s
Lint / Lint (Go) (push) Successful in 17s
Lint / Lint (Python) (push) Successful in 9s
Tests / Test (Node/Svelte) (push) Successful in 13s
Tests / Test (Go) (push) Successful in 17s
Tests / Test (Python) (push) Successful in 9s
Lint / Lint (Node/Svelte) (push) Successful in 14s
This commit is contained in:
1 parent
d134d6626a
commit
c95865dbe2
3 files changed
+44
-1
No files matched your search
@@ -1,15 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { Snippet } from 'svelte';
|
||||||
import type { AboutLink } from '../types';
|
import type { AboutLink } from '../types';
|
||||||
import Dialog from './Dialog.svelte';
|
import Dialog from './Dialog.svelte';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
brand = 'Application',
|
brand = 'Application',
|
||||||
|
children,
|
||||||
description = '',
|
description = '',
|
||||||
links = [],
|
links = [],
|
||||||
open = $bindable(false),
|
open = $bindable(false),
|
||||||
version = ''
|
version = ''
|
||||||
}: {
|
}: {
|
||||||
brand?: string;
|
brand?: string;
|
||||||
|
children?: Snippet;
|
||||||
description?: string;
|
description?: string;
|
||||||
links?: AboutLink[];
|
links?: AboutLink[];
|
||||||
open?: boolean;
|
open?: boolean;
|
||||||
@@ -31,6 +34,10 @@
|
|||||||
<p class="sc-muted">{description}</p>
|
<p class="sc-muted">{description}</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if children}
|
||||||
|
{@render children()}
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if links.length > 0}
|
{#if links.length > 0}
|
||||||
<div class="sc-about-links">
|
<div class="sc-about-links">
|
||||||
{#each links as link}
|
{#each links as link}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
let username = $state('');
|
let username = $state('');
|
||||||
let email = $state('');
|
let email = $state('');
|
||||||
|
let password = $state('');
|
||||||
|
let confirmPassword = $state('');
|
||||||
let error = $state('');
|
let error = $state('');
|
||||||
let saving = $state(false);
|
let saving = $state(false);
|
||||||
|
|
||||||
@@ -24,6 +26,8 @@
|
|||||||
if (open) {
|
if (open) {
|
||||||
username = currentUsername;
|
username = currentUsername;
|
||||||
email = currentEmail;
|
email = currentEmail;
|
||||||
|
password = '';
|
||||||
|
confirmPassword = '';
|
||||||
error = '';
|
error = '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -32,6 +36,11 @@
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
error = '';
|
error = '';
|
||||||
|
|
||||||
|
if (password && password !== confirmPassword) {
|
||||||
|
error = 'Passwords do not match.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!onSave) {
|
if (!onSave) {
|
||||||
error = 'The application has not configured its profile update handler.';
|
error = 'The application has not configured its profile update handler.';
|
||||||
return;
|
return;
|
||||||
@@ -39,7 +48,7 @@
|
|||||||
|
|
||||||
saving = true;
|
saving = true;
|
||||||
try {
|
try {
|
||||||
await onSave({ username, email });
|
await onSave({ username, email, password: password || undefined });
|
||||||
open = false;
|
open = false;
|
||||||
} catch (caught) {
|
} catch (caught) {
|
||||||
error = caught instanceof Error ? caught.message : 'Profile update failed.';
|
error = caught instanceof Error ? caught.message : 'Profile update failed.';
|
||||||
@@ -68,6 +77,32 @@
|
|||||||
<input autocomplete="email" class="sc-input" required type="email" bind:value={email} />
|
<input autocomplete="email" class="sc-input" required type="email" bind:value={email} />
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<label class="sc-field">
|
||||||
|
<span class="sc-label">New password</span>
|
||||||
|
<input
|
||||||
|
autocomplete="new-password"
|
||||||
|
class="sc-input"
|
||||||
|
minlength="8"
|
||||||
|
placeholder="Leave blank to keep the current password"
|
||||||
|
type="password"
|
||||||
|
bind:value={password}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
{#if password}
|
||||||
|
<label class="sc-field">
|
||||||
|
<span class="sc-label">Confirm new password</span>
|
||||||
|
<input
|
||||||
|
autocomplete="new-password"
|
||||||
|
class="sc-input"
|
||||||
|
minlength="8"
|
||||||
|
required
|
||||||
|
type="password"
|
||||||
|
bind:value={confirmPassword}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if error}
|
{#if error}
|
||||||
<p aria-live="polite" class="sc-error">{error}</p>
|
<p aria-live="polite" class="sc-error">{error}</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export interface AuthLoginInput {
|
|||||||
export interface ProfileUpdateInput {
|
export interface ProfileUpdateInput {
|
||||||
username: string;
|
username: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
password?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AboutLink {
|
export interface AboutLink {
|
||||||
|
|||||||
Reference in new issue
Block a user