feat(timeline): add the "Ereignis hinzufügen" CTA to the Zeitstrahl header

Wrap the heading in a flex-wrap header so the gated add-event link drops
below the title at narrow widths instead of overflowing; the CTA targets
#781's /zeitstrahl/events/new and only shows for a WRITE_ALL viewer. Also
thread canWrite into TimelineView so a curator sees the edit pencils on
the real page. New i18n key timeline_add_event in de/en/es.

Refs #842
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-15 08:12:52 +02:00
parent 11bcaf7cdb
commit 9118a10e4b
5 changed files with 70 additions and 2 deletions

View File

@@ -1035,6 +1035,7 @@
"nav_geschichten": "Geschichten", "nav_geschichten": "Geschichten",
"nav_zeitstrahl": "Zeitstrahl", "nav_zeitstrahl": "Zeitstrahl",
"timeline_heading": "Zeitstrahl", "timeline_heading": "Zeitstrahl",
"timeline_add_event": "Ereignis hinzufügen",
"timeline_empty_state": "Noch keine Ereignisse.", "timeline_empty_state": "Noch keine Ereignisse.",
"timeline_undated_section": "Ohne Datum", "timeline_undated_section": "Ohne Datum",
"timeline_unknown_person": "Unbekannt", "timeline_unknown_person": "Unbekannt",

View File

@@ -1035,6 +1035,7 @@
"nav_geschichten": "Stories", "nav_geschichten": "Stories",
"nav_zeitstrahl": "Timeline", "nav_zeitstrahl": "Timeline",
"timeline_heading": "Timeline", "timeline_heading": "Timeline",
"timeline_add_event": "Add event",
"timeline_empty_state": "No events yet.", "timeline_empty_state": "No events yet.",
"timeline_undated_section": "Without Date", "timeline_undated_section": "Without Date",
"timeline_unknown_person": "Unknown", "timeline_unknown_person": "Unknown",

View File

@@ -1035,6 +1035,7 @@
"nav_geschichten": "Historias", "nav_geschichten": "Historias",
"nav_zeitstrahl": "Línea de tiempo", "nav_zeitstrahl": "Línea de tiempo",
"timeline_heading": "Línea de tiempo", "timeline_heading": "Línea de tiempo",
"timeline_add_event": "Añadir evento",
"timeline_empty_state": "Aún no hay eventos.", "timeline_empty_state": "Aún no hay eventos.",
"timeline_undated_section": "Sin Fecha", "timeline_undated_section": "Sin Fecha",
"timeline_unknown_person": "Desconocido", "timeline_unknown_person": "Desconocido",

View File

@@ -74,7 +74,20 @@ const metaLine = $derived.by(() => {
border is intentionally omitted (the page is already bg-canvas), per the border is intentionally omitted (the page is already bg-canvas), per the
review of REQ-001 — the sheet reads through its padding, not a frame line. --> review of REQ-001 — the sheet reads through its padding, not a frame line. -->
<div data-testid="timeline-canvas" class="rounded-[10px] bg-canvas p-6"> <div data-testid="timeline-canvas" class="rounded-[10px] bg-canvas p-6">
<h1 class="font-serif text-2xl font-bold text-brand-navy">{m.timeline_heading()}</h1> <!-- Wrapping header so the CTA drops below the heading at narrow widths
(≤360px) instead of overflowing — #842 REQ-001. -->
<header class="flex flex-wrap items-center justify-between gap-3">
<h1 class="font-serif text-2xl font-bold text-brand-navy">{m.timeline_heading()}</h1>
{#if data.canWrite}
<a
data-testid="timeline-add-event"
href="/zeitstrahl/events/new"
class="inline-flex h-11 items-center rounded bg-primary px-4 font-sans text-sm font-medium text-primary-fg hover:opacity-90 focus:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring"
>
{m.timeline_add_event()}
</a>
{/if}
</header>
{#if hasContent} {#if hasContent}
<p data-testid="timeline-meta" class="mt-1 mb-6 font-sans text-xs text-ink-3">{metaLine}</p> <p data-testid="timeline-meta" class="mt-1 mb-6 font-sans text-xs text-ink-3">{metaLine}</p>
<TimelineFilters <TimelineFilters
@@ -99,7 +112,7 @@ const metaLine = $derived.by(() => {
</button> </button>
</div> </div>
{:else} {:else}
<TimelineView timeline={filteredTimeline} /> <TimelineView timeline={filteredTimeline} canWrite={data.canWrite} />
{/if} {/if}
</div> </div>
</div> </div>

View File

@@ -213,3 +213,55 @@ describe('/zeitstrahl layer filter (#780)', () => {
await expect.element(meta).toHaveTextContent(m.timeline_events_count({ count: 2 })); await expect.element(meta).toHaveTextContent(m.timeline_events_count({ count: 2 }));
}); });
}); });
describe('/zeitstrahl curator affordances (#842)', () => {
const curated = (eventId: string) =>
makeEntry({
kind: 'EVENT',
type: 'PERSONAL',
derived: false,
eventId,
title: 'Auswanderung',
senderName: '',
receiverName: '',
documentId: undefined
});
const withWrite = (timeline: ReturnType<typeof makeTimelineDTO>) => ({
...pageData(timeline),
canWrite: true
});
it('renders the add-event CTA in a wrapping header when the viewer can write (REQ-001)', () => {
render(Page, { data: withWrite(makeTimelineDTO({ years: [makeYear(1909, [makeEntry()])] })) });
const add = document.querySelector(
'[data-testid="timeline-add-event"]'
) as HTMLAnchorElement | null;
expect(add).not.toBeNull();
expect(add?.getAttribute('href')).toBe('/zeitstrahl/events/new');
// The header wraps so the CTA drops below the heading at narrow widths (≤360px)
// rather than overflowing — REQ-001.
expect(add?.closest('header')?.classList.contains('flex-wrap')).toBe(true);
});
it('renders no add-event CTA when the viewer cannot write (REQ-002)', () => {
render(Page, {
data: pageData(makeTimelineDTO({ years: [makeYear(1909, [makeEntry()])] }))
});
expect(document.querySelector('[data-testid="timeline-add-event"]')).toBeNull();
});
it('threads canWrite to the timeline so a curator sees an event edit link (REQ-001/009)', () => {
render(Page, {
data: withWrite(makeTimelineDTO({ years: [makeYear(1924, [curated('p9')])] }))
});
expect(document.querySelector('a[href="/zeitstrahl/events/p9/edit"]')).not.toBeNull();
});
it('shows no event edit link to a reader (REQ-007)', () => {
render(Page, {
data: pageData(makeTimelineDTO({ years: [makeYear(1924, [curated('p9')])] }))
});
expect(document.querySelector('[data-testid="event-edit"]')).toBeNull();
});
});