refactor(web): Admin's Overview and the Collection draw a waiting queue with one row (DRY W9)
release / web (push) Successful in 1m42s
release / go (push) Successful in 2m13s
release / govulncheck (push) Successful in 20s
release / integration (push) Successful in 4m38s
release / android (push) Successful in 5m11s
release / Build signed APK (push) Successful in 5m29s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 27s
release / Verify release artifacts (tag releases only) (push) Skipped

The "what is waiting, how long, Open" row was written out four times: the
failed scan, each queue and each status problem on the Overview, and each
queue on the Collection. NeedsYouRow draws it once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 03:24:47 -05:00
co-authored by Claude Opus 5.5
parent 6152dacac3
commit ebb8e331a2
3 changed files with 54 additions and 36 deletions
+17 -27
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import NeedsYouRow from '#lib/components/NeedsYouRow.svelte';
import { plural } from '#lib/utils/plural.js';
import { pageTitle } from '#lib/branding.js';
import { createAdminStatusQuery, createAdminSummaryQuery, createScanStatusQuery } from '#lib/api/admin.js';
@@ -79,38 +80,27 @@
{#if problems > 0}
<ul class="divide-y divide-border rounded-lg border border-border bg-surface">
{#if scan?.error_message}
<li data-testid="needs-you">
<a href="/admin/library" class="flex flex-wrap items-baseline gap-x-3 gap-y-1 px-4 py-3 hover:bg-surface-hover">
<span class="text-sm text-error-fg">The last library scan failed: {scan.error_message}</span>
{#if scan.finished_at}
<span class="text-xs text-text-muted">{relativeTime(scan.finished_at)}</span>
{/if}
<span class="ml-auto text-sm text-accent-fg">Open</span>
</a>
</li>
<NeedsYouRow
href="/admin/library"
text={`The last library scan failed: ${scan.error_message}`}
when={scan.finished_at ? relativeTime(scan.finished_at) : undefined}
error
/>
{/if}
{#each waiting as d (d.key)}
{@const q = summary?.[d.key]}
<li data-testid="needs-you">
<a href={d.href} class="flex flex-wrap items-baseline gap-x-3 gap-y-1 px-4 py-3 hover:bg-surface-hover">
<span class="text-sm text-text-primary">{queueLabel(d, countOf(summary, d.key))}</span>
{#if q?.since}
<span class="text-xs text-text-muted">oldest {relativeTime(q.since)}</span>
{/if}
<span class="ml-auto text-sm text-accent-fg">Open</span>
</a>
</li>
<NeedsYouRow
href={d.href}
text={queueLabel(d, countOf(summary, d.key))}
when={q?.since ? `oldest ${relativeTime(q.since)}` : undefined}
/>
{/each}
{#each statusProblems as p (p.key)}
<li data-testid="needs-you">
<a href={p.href} class="flex flex-wrap items-baseline gap-x-3 gap-y-1 px-4 py-3 hover:bg-surface-hover">
<span class="text-sm text-text-primary">{p.text}</span>
{#if p.since}
<span class="text-xs text-text-muted">since {relativeTime(p.since)}</span>
{/if}
<span class="ml-auto text-sm text-accent-fg">Open</span>
</a>
</li>
<NeedsYouRow
href={p.href}
text={p.text}
when={p.since ? `since ${relativeTime(p.since)}` : undefined}
/>
{/each}
</ul>
{/if}
+7 -9
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import NeedsYouRow from '#lib/components/NeedsYouRow.svelte';
import { pageTitle } from '#lib/branding.js';
import { createAdminSummaryQuery } from '#lib/api/admin.js';
import { relativeTime } from '#lib/utils/relativeTime.js';
@@ -28,15 +29,12 @@
<ul class="divide-y divide-border rounded-lg border border-border bg-surface">
{#each waiting as d (d.key)}
{@const q = summary?.[d.key]}
<li data-testid="collection-queue">
<a href={d.href} class="flex flex-wrap items-baseline gap-x-3 gap-y-1 px-4 py-3 hover:bg-surface-hover">
<span class="text-sm text-text-primary">{queueLabel(d, countOf(summary, d.key))}</span>
{#if q?.since}
<span class="text-xs text-text-muted">oldest {relativeTime(q.since)}</span>
{/if}
<span class="ml-auto text-sm text-accent-fg">Open</span>
</a>
</li>
<NeedsYouRow
href={d.href}
text={queueLabel(d, countOf(summary, d.key))}
when={q?.since ? `oldest ${relativeTime(q.since)}` : undefined}
testid="collection-queue"
/>
{/each}
</ul>
{/if}