refactor(layout): extract canUpload derived for the upload-button gate (#696)
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 3m18s
CI / OCR Service Tests (pull_request) Successful in 21s
CI / Backend Unit Tests (pull_request) Successful in 3m27s
CI / fail2ban Regex (pull_request) Successful in 43s
CI / Semgrep Security Scan (pull_request) Successful in 19s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m2s
CI / Unit & Component Tests (push) Successful in 3m18s
CI / OCR Service Tests (push) Successful in 19s
CI / Backend Unit Tests (push) Successful in 3m19s
CI / fail2ban Regex (push) Successful in 43s
CI / Semgrep Security Scan (push) Successful in 19s
CI / Compose Bucket Idempotency (push) Successful in 1m1s

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 <noreply@anthropic.com>
This commit was merged in pull request #699.
This commit is contained in:
Marcel
2026-05-31 11:22:09 +02:00
parent 5edefdd082
commit 944370dcfd

View File

@@ -43,6 +43,8 @@ const isAdmin = $derived(
data?.user?.groups?.some((g: { permissions: string[] }) => g.permissions.includes('ADMIN')) 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 // Set after client-side hydration completes. Used by E2E tests to know the
// page is interactive (event handlers registered) before they interact with it. // page is interactive (event handlers registered) before they interact with it.
let hydrated = $state(false); let hydrated = $state(false);
@@ -75,7 +77,7 @@ const userInitials = $derived.by(() => {
<!-- Right Side --> <!-- Right Side -->
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
{#if data?.user && data.canWrite} {#if canUpload}
<a <a
href="/documents/new" href="/documents/new"
aria-label={m.upload_action()} aria-label={m.upload_action()}