From 944370dcfd4b1ac4db14abf47b62cd7113217ebc Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 31 May 2026 11:22:09 +0200 Subject: [PATCH] refactor(layout): extract canUpload derived for the upload-button gate (#696) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the inline {#if data?.user && data.canWrite} condition into a named $derived, matching the existing isAdmin / isAuthPage derivations in the same file. No behaviour change — the 11 layout specs stay green. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/routes/+layout.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index 9dd0d37c..136eb060 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -43,6 +43,8 @@ const isAdmin = $derived( data?.user?.groups?.some((g: { permissions: string[] }) => g.permissions.includes('ADMIN')) ); +const canUpload = $derived(Boolean(data?.user && data.canWrite)); + // Set after client-side hydration completes. Used by E2E tests to know the // page is interactive (event handlers registered) before they interact with it. let hydrated = $state(false); @@ -75,7 +77,7 @@ const userInitials = $derived.by(() => {
- {#if data?.user && data.canWrite} + {#if canUpload}