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:
@@ -74,7 +74,20 @@ const metaLine = $derived.by(() => {
|
||||
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. -->
|
||||
<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}
|
||||
<p data-testid="timeline-meta" class="mt-1 mb-6 font-sans text-xs text-ink-3">{metaLine}</p>
|
||||
<TimelineFilters
|
||||
@@ -99,7 +112,7 @@ const metaLine = $derived.by(() => {
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
<TimelineView timeline={filteredTimeline} />
|
||||
<TimelineView timeline={filteredTimeline} canWrite={data.canWrite} />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -213,3 +213,55 @@ describe('/zeitstrahl layer filter (#780)', () => {
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user