Skip to content

Modern Docker Management, Designed for Everyone

refactor: add updated error page

Kyle Mendell708bf4240e66
diff --git a/frontend/src/lib/components/error.svelte b/frontend/src/lib/components/error.svelte
new file mode 100644
index 000000000..7e7696119
--- /dev/null
+++ b/frontend/src/lib/components/error.svelte
@@ -0,0 +1,47 @@
+<script lang="ts">
+ import { Button } from '$lib/components/ui/button';
+ import { XCircle } from '@lucide/svelte';
+
+ let {
+ message,
+ status,
+ title = 'Uh‑oh, something went wrong',
+ showButton = true,
+ actionHref = '/dashboard',
+ actionLabel = 'Go to Dashboard'
+ }: {
+ message: string;
+ status?: number;
+ title?: string;
+ showButton?: boolean;
+ actionHref?: string;
+ actionLabel?: string;
+ } = $props();
+</script>
+
+<div class="grid h-full min-h-screen place-items-center px-6">
+ <div class="w-full max-w-md text-center">
+ <div
+ class="mx-auto mb-4 flex size-14 items-center justify-center rounded-full bg-destructive/10"
+ >
+ <XCircle class="text-destructive size-7" aria-hidden="true" />
+ </div>
+
+ <h1 class="text-2xl font-semibold">{title}</h1>
+ {#if status !== undefined && status !== null}
+ <p class="text-muted-foreground mt-2 max-w-md text-sm">
+ <span class="font-semibold">{status}</span>
+ <span class="mx-1">-</span>
+ <span>{message}</span>
+ </p>
+ {:else}
+ <p class="text-muted-foreground mt-2 max-w-md">{message}</p>
+ {/if}
+
+ {#if showButton}
+ <div class="mt-5 flex items-center justify-center gap-2">
+ <Button size="sm" href={actionHref}>{actionLabel}</Button>
+ </div>
+ {/if}
+ </div>
+</div>
diff --git a/frontend/src/lib/utils/redirect.util.ts b/frontend/src/lib/utils/redirect.util.ts
index 9923c86ba..62be7fe29 100644
--- a/frontend/src/lib/utils/redirect.util.ts
+++ b/frontend/src/lib/utils/redirect.util.ts
@@ -17,7 +17,7 @@ export function getAuthRedirectPath(path: string, user: User | null, settings: S
path.startsWith('/img') ||
path === '/favicon.ico';
- const isPublicPath = ['/authorize', '/device', '/health', '/healthz'].includes(path);
+ const isPublicPath = ['/health', '/healthz'].includes(path);
const isOnboardingPath = path === '/onboarding' || path.startsWith('/onboarding');
if (!isSignedIn && !isUnauthenticatedOnlyPath && !isPublicPath) {
@@ -34,5 +34,9 @@ export function getAuthRedirectPath(path: string, user: User | null, settings: S
return '/dashboard';
}
+ if (path === '/' && isSignedIn) {
+ return '/dashboard';
+ }
+
return null;
}
diff --git a/frontend/src/routes/+error.svelte b/frontend/src/routes/+error.svelte
new file mode 100644
index 000000000..ed5374625
--- /dev/null
+++ b/frontend/src/routes/+error.svelte
@@ -0,0 +1,16 @@
+<script lang="ts">
+ import ErrorView from '$lib/components/error.svelte';
+ import { page } from '$app/state';
+
+ // Props can be missing in some cases (e.g., 404 on client nav)
+ const props = $props<{ error?: any; status?: number }>();
+
+ const status = $derived(props.status ?? page.status ?? 500);
+ const message = $derived(
+ props.error?.message ??
+ page.error?.message ??
+ (status === 404 ? 'Not Found' : 'Something went wrong')
+ );
+</script>
+
+<ErrorView {status} {message} />
diff --git a/frontend/src/routes/+layout.ts b/frontend/src/routes/+layout.ts
index bb948f8ac..230e603e2 100644
--- a/frontend/src/routes/+layout.ts
+++ b/frontend/src/routes/+layout.ts
@@ -4,7 +4,6 @@ import { settingsAPI, userAPI, environmentManagementAPI } from '$lib/services/ap
import { environmentStore } from '$lib/stores/environment.store';
import { versionService } from '$lib/services/app-version-service';
import { tryCatch } from '$lib/utils/try-catch';
-import { redirect } from '@sveltejs/kit';
export const ssr = false;
diff --git a/frontend/src/routes/auth/oidc/callback/+page.svelte b/frontend/src/routes/auth/oidc/callback/+page.svelte
index eef26d991..b1dbf08ac 100644
--- a/frontend/src/routes/auth/oidc/callback/+page.svelte
+++ b/frontend/src/routes/auth/oidc/callback/+page.svelte
@@ -17,10 +17,9 @@
const errorParam = page.url.searchParams.get('error');
const errorDescription = page.url.searchParams.get('error_description');
- const finalRedirectTo = localStorage.getItem('oidc_redirect') || '/dashboard';
+ const redirectTo = localStorage.getItem('oidc_redirect') || '/dashboard';
localStorage.removeItem('oidc_redirect');
- // Handle OIDC provider errors
if (errorParam) {
let userMessage = 'Authentication was cancelled or failed.';
if (errorParam === 'access_denied') {
@@ -77,7 +76,7 @@
userStore.setUser(user);
await invalidateAll();
toast.success('Successfully logged in!');
- goto(finalRedirectTo);
+ goto(redirectTo);
} else {
error = 'Authentication succeeded but user information is missing.';
setTimeout(() => goto('/auth/login?error=oidc_user_info_missing'), 3000);
diff --git a/frontend/src/routes/auth/oidc/login/+page.svelte b/frontend/src/routes/auth/oidc/login/+page.svelte
index 01cd4c6b1..0becd3218 100644
--- a/frontend/src/routes/auth/oidc/login/+page.svelte
+++ b/frontend/src/routes/auth/oidc/login/+page.svelte
@@ -9,9 +9,8 @@
onMount(async () => {
try {
- const redirectParam = page.url.searchParams.get('redirect') || '/dashboard';
+ const redirect = page.url.searchParams.get('redirect') || '/dashboard';
- // Check if OIDC is properly configured first
const status = await oidcAPI.getStatus();
if (!status.dbEnabled || !status.dbConfigured) {
error =
@@ -21,7 +20,7 @@
return;
}
- const authUrl = await oidcAPI.getAuthUrl(redirectParam);
+ const authUrl = await oidcAPI.getAuthUrl(redirect);
if (!authUrl) {
error =
'Unable to generate authentication URL. Please try again or contact your administrator.';
@@ -30,12 +29,11 @@
return;
}
- localStorage.setItem('oidc_redirect', redirectParam);
+ localStorage.setItem('oidc_redirect', redirect);
window.location.href = authUrl;
} catch (err: any) {
console.error('OIDC login initiation error:', err);
- // Parse the error message to provide better user feedback
let userMessage = 'Failed to initiate OIDC login. Please try again.';
if (err.message?.includes('discovery')) {
userMessage = 'OIDC provider configuration error. Please contact your administrator.';