Migrate shared UI and backend components
Lint / Lint (push) Failing after 7s
Tests / Go backend (push) Failing after 6s
Tests / Dashboard checks (push) Failing after 4s
Docker / Docker Build & Push (push) Failing after 10s

This commit is contained in:
Gabriel20xx committed 2026-08-04 17:05:37 +02:00
1 parent 64d22d0aac
commit ac08be0248
16 files changed
+236 -395

No files matched your search

+10 -111
View File
@@ -1,119 +1,18 @@
<script>
import { Table2 } from '@lucide/svelte';
import Button from '$lib/components/ui/button.svelte';
import { AuthPage as SharedAuthPage } from '@gabriel20xx/shared-code/web-ui';
import { useAuth } from '$lib/features/auth/auth.svelte.js';
let { setupRequired } = $props();
const auth = useAuth();
let username = $state('');
let email = $state('');
let identifier = $state('');
let password = $state('');
let confirmPassword = $state('');
let submitting = $state(false);
let error = $state('');
async function submit(event) {
event.preventDefault();
error = '';
if (setupRequired && password !== confirmPassword) {
error = 'Passwords do not match.';
return;
}
submitting = true;
try {
if (setupRequired) {
await auth.setup(username, email, password);
} else {
await auth.login(identifier, password);
}
} catch (submitError) {
error = submitError instanceof Error ? submitError.message : 'Request failed.';
} finally {
submitting = false;
}
}
const onLogin = (input) => auth.login(input.identifier, input.password);
const onSetup = (input) => auth.setup(input.username, input.email, input.password);
</script>
<main class="flex min-h-screen items-center justify-center bg-bg px-4 py-8">
<section class="w-full max-w-sm rounded-lg border border-border bg-surface p-6 shadow-sm">
<div class="mb-6 flex flex-col items-center gap-2 text-center">
<Table2 class="size-8 text-primary" />
<h1 class="text-xl font-semibold">CollabTable</h1>
<p class="text-sm text-muted-fg">
{setupRequired ? 'Create the admin account for this dashboard.' : 'Sign in to view this dashboard.'}
</p>
</div>
<form class="space-y-4" onsubmit={submit}>
{#if setupRequired}
<label for="auth-username" class="mb-1 block text-sm font-medium">Username</label>
<!-- svelte-ignore a11y_autofocus -->
<input
id="auth-username"
class="h-9 w-full rounded-md border border-border bg-bg px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"
bind:value={username}
autocomplete="username"
required
autofocus
/>
<label for="auth-email" class="mb-1 block text-sm font-medium">Email</label>
<input
id="auth-email"
type="email"
class="h-9 w-full rounded-md border border-border bg-bg px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"
bind:value={email}
autocomplete="email"
required
/>
{:else}
<label for="auth-identifier" class="mb-1 block text-sm font-medium">Username or email</label>
<!-- svelte-ignore a11y_autofocus -->
<input
id="auth-identifier"
class="h-9 w-full rounded-md border border-border bg-bg px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"
bind:value={identifier}
autocomplete="username"
required
autofocus
/>
{/if}
<div>
<label for="auth-password" class="mb-1 block text-sm font-medium">Password</label>
<input
id="auth-password"
type="password"
class="h-9 w-full rounded-md border border-border bg-bg px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"
bind:value={password}
autocomplete={setupRequired ? 'new-password' : 'current-password'}
minlength={8}
required
/>
</div>
{#if setupRequired}
<div>
<label for="auth-confirm-password" class="mb-1 block text-sm font-medium">Confirm password</label>
<input
id="auth-confirm-password"
type="password"
class="h-9 w-full rounded-md border border-border bg-bg px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"
bind:value={confirmPassword}
autocomplete="new-password"
minlength={8}
required
/>
</div>
{/if}
{#if error}
<p class="text-sm text-danger">{error}</p>
{/if}
<Button type="submit" class="w-full" disabled={submitting}>
{submitting ? 'Working…' : setupRequired ? 'Create account' : 'Sign in'}
</Button>
</form>
</section>
</main>
<SharedAuthPage
brand="CollabTable"
tagline="Collaborative tables for your team"
{setupRequired}
{onLogin}
{onSetup}
/>
@@ -1,111 +0,0 @@
<script>
import Button from '$lib/components/ui/button.svelte';
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '$lib/components/ui/dialog';
import { useAuth } from '$lib/features/auth/auth.svelte.js';
let { open = $bindable(false), currentUsername, currentEmail } = $props();
const auth = useAuth();
let username = $state('');
let email = $state('');
let newPassword = $state('');
let confirmPassword = $state('');
let error = $state('');
let saving = $state(false);
$effect(() => {
if (open) {
username = currentUsername;
email = currentEmail;
}
});
async function submit(event) {
event.preventDefault();
error = '';
if (newPassword !== confirmPassword) {
error = 'Passwords do not match.';
return;
}
saving = true;
try {
await auth.updateCredentials({
newUsername: username.trim() || undefined,
newEmail: email.trim() || undefined,
newPassword: newPassword || undefined,
});
newPassword = '';
confirmPassword = '';
open = false;
} catch (saveError) {
error = saveError instanceof Error ? saveError.message : 'Request failed.';
} finally {
saving = false;
}
}
</script>
<Dialog bind:open>
<DialogContent>
<DialogHeader>
<DialogTitle>Account</DialogTitle>
</DialogHeader>
<form class="space-y-4" onsubmit={submit}>
<p class="text-sm text-muted-fg">Changing your credentials will sign you out everywhere.</p>
<div>
<label for="credentials-username" class="mb-1 block text-sm font-medium">Username</label>
<input
id="credentials-username"
class="h-9 w-full rounded-md border border-border bg-bg px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"
bind:value={username}
autocomplete="username"
/>
</div>
<div>
<label for="credentials-email" class="mb-1 block text-sm font-medium">Email</label>
<input
id="credentials-email"
type="email"
class="h-9 w-full rounded-md border border-border bg-bg px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"
bind:value={email}
autocomplete="email"
required
/>
</div>
<div>
<label for="credentials-new-password" class="mb-1 block text-sm font-medium">New password</label>
<input
id="credentials-new-password"
type="password"
class="h-9 w-full rounded-md border border-border bg-bg px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"
bind:value={newPassword}
autocomplete="new-password"
minlength={8}
placeholder="Leave blank to keep your password"
/>
</div>
<div>
<label for="credentials-confirm-password" class="mb-1 block text-sm font-medium">Confirm new password</label>
<input
id="credentials-confirm-password"
type="password"
class="h-9 w-full rounded-md border border-border bg-bg px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"
bind:value={confirmPassword}
autocomplete="new-password"
minlength={8}
/>
</div>
{#if error}
<p class="text-sm text-danger">{error}</p>
{/if}
<DialogFooter>
<Button type="submit" disabled={saving}>
{saving ? 'Saving…' : 'Save'}
</Button>
<Button type="button" variant="secondary" onclick={() => (open = false)}>Dismiss</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
@@ -1,12 +1,27 @@
<script>
import { page } from '$app/state';
import { AppShell as SharedAppShell, ProfileDialog } from '@gabriel20xx/shared-code/web-ui';
import { Tooltip } from 'bits-ui';
import Header from '$lib/components/Header.svelte';
import AuthPage from '$lib/features/auth/AuthPage.svelte';
import { createAuthStore } from '$lib/features/auth/auth.svelte.js';
import SettingsDialog from './SettingsDialog.svelte';
let { children } = $props();
const auth = createAuthStore();
const navItems = [
{ href: '/', label: 'Overview' },
{ href: '/about', label: 'About' },
];
let settingsOpen = $state(false);
let credentialsOpen = $state(false);
async function saveProfile(input) {
await auth.updateCredentials({
newUsername: input.username.trim() || undefined,
newEmail: input.email.trim() || undefined,
newPassword: input.password || undefined,
});
}
</script>
<Tooltip.Provider delayDuration={300}>
@@ -19,11 +34,27 @@
{:else if !auth.status || auth.status.setupRequired || !auth.status.authenticated}
<AuthPage setupRequired={auth.status?.setupRequired ?? true} />
{:else}
<div class="flex min-h-screen flex-col">
<Header />
<main class="flex min-w-0 flex-1 flex-col">
<SharedAppShell
brand="CollabTable"
currentPath={page.url.pathname}
{navItems}
theme="system"
username={auth.status.username ?? ''}
onLogout={() => auth.logout()}
onProfile={() => (credentialsOpen = true)}
onSettings={() => (settingsOpen = true)}
>
{#snippet children()}
{@render children?.()}
</main>
</div>
{/snippet}
</SharedAppShell>
{/if}
</Tooltip.Provider>
<SettingsDialog bind:open={settingsOpen} />
<ProfileDialog
bind:open={credentialsOpen}
currentUsername={auth.status?.username ?? ''}
currentEmail={auth.status?.email ?? ''}
onSave={saveProfile}
/>
@@ -1,7 +1,7 @@
<script>
import { Moon, Sun, SunMoon } from '@lucide/svelte';
import Button from '$lib/components/ui/button.svelte';
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '$lib/components/ui/dialog';
import { SettingsDialog as SharedSettingsDialog } from '@gabriel20xx/shared-code/web-ui';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '$lib/components/ui/select';
import { currentLanguage, languages, setLanguage } from '$lib/language.svelte.js';
import { themeState } from '$lib/theme.svelte.js';
@@ -11,11 +11,7 @@
const languageItems = languages.map((language) => ({ value: language.id, label: language.label }));
</script>
<Dialog bind:open>
<DialogContent>
<DialogHeader>
<DialogTitle>Settings</DialogTitle>
</DialogHeader>
<SharedSettingsDialog bind:open title="Settings">
<div>
<span class="mb-2 block text-sm font-medium">Theme</span>
<div class="flex w-full rounded-md border border-border p-1">
@@ -69,8 +65,7 @@
</SelectContent>
</Select>
</div>
<DialogFooter>
<Button type="button" variant="secondary" onclick={() => (open = false)}>Dismiss</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<div class="sc-form-actions">
<Button type="button" variant="secondary" onclick={() => (open = false)}>Dismiss</Button>
</div>
</SharedSettingsDialog>