fix(ci): repair Journey route registration and shared client behavior

Register the public view route, align generated entities and test fixtures, and share the scoped reads and access switches. Keep gallery and notification writes in order, and submit the email subscription from the dialog footer.
This commit is contained in:
Maurice
2026-11-30 17:32:50 +01:00
parent 6d14eb6677
commit 0c08a6dcb9
50 changed files with 531 additions and 417 deletions
@@ -98,7 +98,7 @@ describe('the journal entries card', () => {
expect(screen.getByText('4 photos')).toBeInTheDocument();
expect(screen.getByText('Opens with a video')).toBeInTheDocument();
expect(screen.getByText('Berlin 2026')).toBeInTheDocument();
expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/7/preview');
expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/7/thumbnail');
});
it('FE-AI-JOURNEY-002: an entry without a photo takes the width, and a known mood and weather are named', () => {
@@ -236,7 +236,7 @@ describe('a change row of a journal entry', () => {
expect(screen.getByText('Tue, Oct 21')).toBeInTheDocument();
expect(screen.getByText('Museum Island')).toBeInTheDocument();
expect(screen.queryByText('Not a fact')).toBeNull();
expect(document.querySelector('img')).toHaveAttribute('src', '/api/photos/7/preview');
expect(document.querySelector('img')).toHaveAttribute('src', '/api/photos/7/thumbnail');
first.unmount();
const second = inView(<AssistantChangeCard items={[item('applied', held)]} />, { onOpen });
@@ -108,66 +108,21 @@ export default function JourneyDayRecordingButton({
}
if (gpx?.day) {
const { distance, label } = keptLabel(gpx.day);
const full = `${label} ${t('journey.recording.gpx.source')}`;
return (
<>
{fileInput}
<Tooltip label={full} placement="top" disabled={!!menu.menu}>
<button
type="button"
onClick={
canImportGpx
? (e) =>
menu.open(
e,
[
{ label: t('journey.recording.replace'), icon: RefreshCw, onClick: pickFile },
{ label: t('journey.recording.remove'), icon: Trash2, onClick: gpx.onRemove, danger: true },
],
true
)
: undefined
}
aria-disabled={!canImportGpx || gpx.busy}
aria-label={full}
aria-haspopup={canImportGpx ? 'menu' : undefined}
data-testid="journey-day-recording"
className={PILL}
style={{ ...fs(10.5), background: 'var(--vg-surf2)', color: 'var(--vg-ink)' }}
>
<FileUp size={12} strokeWidth={2.4} aria-hidden="true" />
{distance}
</button>
</Tooltip>
<ContextMenu menu={menu.menu} onClose={menu.close} />
</>
<GpxRecordingPill
gpx={gpx}
detail={keptLabel(gpx.day)}
canImport={canImportGpx}
fileInput={fileInput}
pickFile={pickFile}
/>
);
}
if (!canTakeOver && !needsConnection && !canImportGpx) return null;
// Only a file to read: the button opens the file picker straight away.
if (canImportGpx && !canTakeOver) {
const label = t('journey.recording.gpx.import');
return (
<>
{fileInput}
<Tooltip label={label} placement="top">
<button
type="button"
onClick={gpx?.busy ? undefined : pickFile}
aria-disabled={!!gpx?.busy}
aria-label={label}
data-testid="journey-day-recording"
className={ROUND}
style={{ background: 'var(--vg-surf2)', color: 'var(--vg-ink3)' }}
>
<Route size={14} strokeWidth={2.2} />
</button>
</Tooltip>
</>
);
return <ImportGpxButton busy={!!gpx?.busy} fileInput={fileInput} pickFile={pickFile} />;
}
const label = canTakeOver ? t('journey.recording.takeOver') : t('dawarich.error.offline');
@@ -190,11 +145,9 @@ export default function JourneyDayRecordingButton({
true
)
: onOpen
: canImportGpx
? pickFile
: undefined
: undefined
}
aria-disabled={!canTakeOver && !canImportGpx}
aria-disabled={!canTakeOver}
aria-label={label}
aria-haspopup={canTakeOver && canImportGpx ? 'menu' : undefined}
data-testid="journey-day-recording"
@@ -208,3 +161,87 @@ export default function JourneyDayRecordingButton({
</>
);
}
function ImportGpxButton({
busy,
fileInput,
pickFile,
}: {
busy: boolean;
fileInput: React.ReactNode;
pickFile: () => void;
}) {
const { t } = useTranslation();
const label = t('journey.recording.gpx.import');
return (
<>
{fileInput}
<Tooltip label={label} placement="top">
<button
type="button"
onClick={busy ? undefined : pickFile}
aria-disabled={busy}
aria-label={label}
data-testid="journey-day-recording"
className={ROUND}
style={{ background: 'var(--vg-surf2)', color: 'var(--vg-ink3)' }}
>
<Route size={14} strokeWidth={2.2} />
</button>
</Tooltip>
</>
);
}
function GpxRecordingPill({
gpx,
detail,
canImport,
fileInput,
pickFile,
}: {
gpx: DayGpx;
detail: { distance: string; label: string };
canImport: boolean;
fileInput: React.ReactNode;
pickFile: () => void;
}) {
const { t } = useTranslation();
const menu = useContextMenu();
const { distance, label } = detail;
const actionable = canImport && !gpx.busy;
const full = `${label} ${t('journey.recording.gpx.source')}`;
return (
<>
{fileInput}
<Tooltip label={full} placement="top" disabled={!!menu.menu}>
<button
type="button"
onClick={
actionable
? (e) =>
menu.open(
e,
[
{ label: t('journey.recording.replace'), icon: RefreshCw, onClick: pickFile },
{ label: t('journey.recording.remove'), icon: Trash2, onClick: gpx.onRemove, danger: true },
],
true
)
: undefined
}
aria-disabled={!actionable}
aria-label={full}
aria-haspopup={actionable ? 'menu' : undefined}
data-testid="journey-day-recording"
className={PILL}
style={{ ...fs(10.5), background: 'var(--vg-surf2)', color: 'var(--vg-ink)' }}
>
<FileUp size={12} strokeWidth={2.4} aria-hidden="true" />
{distance}
</button>
</Tooltip>
<ContextMenu menu={menu.menu} onClose={menu.close} />
</>
);
}
@@ -181,7 +181,7 @@ export function EntryCard({ entry, readOnly, onEdit, onDelete, onPhotoClick, com
</div>
)}
{comments && <div className="pt-3 mt-3 border-t border-zinc-100 dark:border-zinc-800">{comments}</div>}
{comments && <div className="pt-3 mt-3 border-t border-edge-faint">{comments}</div>}
</div>
</div>
)
@@ -8,10 +8,10 @@ import { Tooltip } from '../shared/Tooltip';
/** One comment as the thread draws it: in the app and on the shared page alike. */
export interface EntryCommentItem {
id: number;
author_name: string | null;
author_name?: string | null;
is_guest: boolean;
body: string;
created_at: string | null;
created_at?: string | null;
hidden?: boolean;
own?: boolean;
}
@@ -99,7 +99,7 @@ export default function JourneyEntryComments({
setBody('');
};
const dateOf = (iso: string | null) =>
const dateOf = (iso: string | null | undefined) =>
iso ? new Date(iso).toLocaleDateString(locale || undefined, { day: 'numeric', month: 'short' }) : '';
const toggle = (
@@ -158,7 +158,7 @@ export default function JourneyEntryComments({
<button
type="button"
aria-label={c.hidden ? t('journey.comments.show') : t('journey.comments.hide')}
onClick={() => void onHide!(c.id, !c.hidden)}
onClick={() => void onHide?.(c.id, !c.hidden)}
className="flex h-7 w-7 items-center justify-center rounded-full text-content-faint hover:bg-surface-secondary hover:text-content"
>
{c.hidden ? <Eye size={13} /> : <EyeOff size={13} />}
@@ -170,7 +170,7 @@ export default function JourneyEntryComments({
<button
type="button"
aria-label={t('common.delete')}
onClick={() => void onDelete!(c.id)}
onClick={() => void onDelete?.(c.id)}
className="flex h-7 w-7 items-center justify-center rounded-full text-content-faint hover:bg-danger-soft hover:text-danger"
>
<Trash2 size={13} />
@@ -56,6 +56,36 @@ function ShareFollowers({ access }: { access: ShareAccess }) {
)
}
function ShareDetailToggle({ icon: Icon, label, hint, on, disabledReason, toggle }: {
icon: typeof MessageCircle
label: string
hint: string
on: boolean
disabledReason: string
toggle: () => void
}) {
return (
<Tooltip label={disabledReason} placement="top">
<button
type="button"
aria-pressed={on}
disabled={!!disabledReason}
onClick={toggle}
className={`flex w-full items-start gap-2.5 rounded-xl border px-3 py-2 text-start transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${
on ? 'border-accent bg-accent text-accent-text' : 'border-edge text-content-muted hover:border-content-faint'
}`}
>
<Icon size={13} className="mt-0.5 flex-none" />
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
<span className="font-medium" style={fs(12, 'body')}>{label}</span>
<span className={on ? 'text-accent-text opacity-80' : 'text-content-faint'} style={fs(11)}>{hint}</span>
</span>
{on && <Check size={12} className="mt-0.5 flex-none" />}
</button>
</Tooltip>
)
}
/** What readers of the link may do besides reading (#1702, #1669): each off until switched on. */
function ShareReaders({ link, access, onToggle }: { link: JourneyShareLink; access: ShareAccess; onToggle: (key: JourneyShareInteraction) => void }) {
const { t } = useTranslation()
@@ -66,24 +96,15 @@ function ShareReaders({ link, access, onToggle }: { link: JourneyShareLink; acce
const blocked = key === 'allow_comments' && !link.share_timeline
const on = !blocked && !!link[key]
return (
<Tooltip key={key} label={blocked ? t('journey.share.needsTimeline') : ''} placement="top">
<button
type="button"
aria-pressed={on}
disabled={blocked}
onClick={() => onToggle(key)}
className={`flex w-full items-start gap-2.5 rounded-xl border px-3 py-2 text-start transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${
on ? 'border-accent bg-accent text-accent-text' : 'border-edge text-content-muted hover:border-content-faint'
}`}
>
<Icon size={13} className="mt-0.5 flex-none" />
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
<span className="font-medium" style={fs(12, 'body')}>{t(labelKey)}</span>
<span className={on ? 'text-accent-text opacity-80' : 'text-content-faint'} style={fs(11)}>{t(hintKey)}</span>
</span>
{on && <Check size={12} className="mt-0.5 flex-none" />}
</button>
</Tooltip>
<ShareDetailToggle
key={key}
icon={Icon}
label={t(labelKey)}
hint={t(hintKey)}
on={on}
disabledReason={blocked ? t('journey.share.needsTimeline') : ''}
toggle={() => onToggle(key)}
/>
)
})}
{link.allow_subscriptions && <ShareFollowers access={access} />}
@@ -149,24 +170,15 @@ function ShareMapExtras({ link, onToggle }: { link: JourneyShareLink; onToggle:
const Icon = EXTRA_ICONS[key]
const on = mapShared && !!link[key]
return (
<Tooltip key={key} label={mapShared ? '' : t('journey.share.needsMap')} placement="top">
<button
type="button"
aria-pressed={on}
disabled={!mapShared}
onClick={() => onToggle(key)}
className={`flex w-full items-start gap-2.5 rounded-xl border px-3 py-2 text-start transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${
on ? 'border-accent bg-accent text-accent-text' : 'border-edge text-content-muted hover:border-content-faint'
}`}
>
<Icon size={13} className="mt-0.5 flex-none" />
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
<span className="font-medium" style={fs(12, 'body')}>{t(labelKey)}</span>
<span className={on ? 'text-accent-text opacity-80' : 'text-content-faint'} style={fs(11)}>{t(hintKey)}</span>
</span>
{on && <Check size={12} className="mt-0.5 flex-none" />}
</button>
</Tooltip>
<ShareDetailToggle
key={key}
icon={Icon}
label={t(labelKey)}
hint={t(hintKey)}
on={on}
disabledReason={mapShared ? '' : t('journey.share.needsMap')}
toggle={() => onToggle(key)}
/>
)
})}
</div>
@@ -295,7 +295,7 @@ export default function MobileEntryView({ entry, readOnly, publicPhotoUrl, onClo
</div>
)}
{comments && <div className="mt-6 border-t border-zinc-100 pt-4 dark:border-zinc-800">{comments}</div>}
{comments && <div className="mt-6 border-t border-edge-faint pt-4">{comments}</div>}
</div>
</div>
</div >
@@ -105,6 +105,6 @@ describe('journeyRecordingModel', () => {
expect(gpxImportErrorText(httpError('gpx_no_times'), t)).toBe('t:journey.recording.gpx.error.noTimes');
expect(gpxImportErrorText(httpError('recording_empty'), t)).toBe('t:journey.recording.gpx.error.emptyDay');
expect(gpxImportErrorText(httpError('gpx_too_many_days'), t)).toBe('t:journey.recording.gpx.error.tooManyDays');
expect(gpxImportErrorText(new Error('boom'), t)).toBe('t:common.errorTitle');
expect(gpxImportErrorText(new Error('boom'), t)).toBe('t:journey.recording.gpx.failed');
});
});
@@ -1,15 +1,8 @@
import type { JourneyComment } from '@trek/shared';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useCallback, useMemo } from 'react';
import { journeySocialRepo } from '../../repo/journeySocialRepo';
import { useServerPing } from '../../sync/useServerPing';
import { useJourneyLiveData } from './useJourneyLiveData';
interface Loaded {
journeyId: number | null;
comments: JourneyComment[];
canModerate: boolean;
}
const NOTHING: Loaded = { journeyId: null, comments: [], canModerate: false };
const NO_COMMENTS: JourneyComment[] = [];
interface JourneyCommentsState {
@@ -36,41 +29,8 @@ interface JourneyCommentsState {
* can say so.
*/
export function useJourneyComments(journeyId: number | null): JourneyCommentsState {
const [loaded, setLoaded] = useState<Loaded>(NOTHING);
const [failedFor, setFailedFor] = useState<number | null>(null);
const current = loaded.journeyId === journeyId ? loaded : null;
const comments = current?.comments ?? NO_COMMENTS;
const status = journeyId === null ? 'idle' : current ? 'ready' : failedFor === journeyId ? 'failed' : 'loading';
const read = useCallback(async (): Promise<Loaded | null> => {
if (journeyId === null) return null;
try {
const answer = await journeySocialRepo.comments(journeyId);
return { journeyId, comments: answer.comments, canModerate: answer.can_moderate };
} catch {
// What was read before stays: a thread does not vanish because one read failed.
return null;
}
}, [journeyId]);
useEffect(() => {
let cancelled = false;
void read().then((next) => {
if (cancelled) return;
if (next) setLoaded(next);
else setFailedFor(journeyId);
});
return () => {
cancelled = true;
};
}, [read, journeyId]);
const reload = useCallback(async () => {
const next = await read();
if (next) setLoaded(next);
}, [read]);
useServerPing('journey:entry:commented', journeyId !== null, reload);
const { data, status, update } = useJourneyLiveData(journeyId, 'journey:entry:commented', journeySocialRepo.comments);
const comments = data?.comments ?? NO_COMMENTS;
const byEntry = useMemo(() => {
const map = new Map<number, JourneyComment[]>();
@@ -83,13 +43,13 @@ export function useJourneyComments(journeyId: number | null): JourneyCommentsSta
if (journeyId === null || !body.trim()) return false;
try {
const comment = await journeySocialRepo.addComment(journeyId, entryId, body);
setLoaded((prev) => (prev.journeyId === journeyId ? { ...prev, comments: [...prev.comments, comment] } : prev));
update((prev) => (prev ? { ...prev, comments: [...prev.comments, comment] } : null));
return true;
} catch {
return false;
}
},
[journeyId]
[journeyId, update]
);
const setHidden = useCallback(
@@ -97,16 +57,15 @@ export function useJourneyComments(journeyId: number | null): JourneyCommentsSta
if (journeyId === null) return false;
try {
await journeySocialRepo.setCommentHidden(journeyId, commentId, hidden);
setLoaded((prev) => ({
...prev,
comments: prev.comments.map((c) => (c.id === commentId ? { ...c, hidden } : c)),
}));
update((prev) =>
prev ? { ...prev, comments: prev.comments.map((c) => (c.id === commentId ? { ...c, hidden } : c)) } : null
);
return true;
} catch {
return false;
}
},
[journeyId]
[journeyId, update]
);
const remove = useCallback(
@@ -114,14 +73,14 @@ export function useJourneyComments(journeyId: number | null): JourneyCommentsSta
if (journeyId === null) return false;
try {
await journeySocialRepo.deleteComment(journeyId, commentId);
setLoaded((prev) => ({ ...prev, comments: prev.comments.filter((c) => c.id !== commentId) }));
update((prev) => (prev ? { ...prev, comments: prev.comments.filter((c) => c.id !== commentId) } : null));
return true;
} catch {
return false;
}
},
[journeyId]
[journeyId, update]
);
return { comments, byEntry, canModerate: current?.canModerate ?? false, status, add, setHidden, remove };
return { comments, byEntry, canModerate: data?.can_moderate ?? false, status, add, setHidden, remove };
}
@@ -0,0 +1,54 @@
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
import { useServerPing } from '../../sync/useServerPing';
type LoadStatus = 'idle' | 'loading' | 'ready' | 'failed';
/** Read journey data on open and server updates. Keep the last good read when a refresh fails. */
export function useJourneyLiveData<T>(journeyId: number | null, eventName: string, read: (id: number) => Promise<T>) {
const [loaded, setLoaded] = useState<{ journeyId: number; data: T } | null>(null);
const [failedFor, setFailedFor] = useState<number | null>(null);
const activeId = useRef(journeyId);
const latestRead = useRef(0);
useLayoutEffect(() => {
activeId.current = journeyId;
return () => {
activeId.current = null;
latestRead.current++;
};
}, [journeyId]);
const refresh = useCallback(async () => {
if (journeyId === null) return;
const version = ++latestRead.current;
await read(journeyId).then(
(data) => {
if (latestRead.current === version) setLoaded({ journeyId, data });
},
() => {
if (latestRead.current === version) setFailedFor(journeyId);
}
);
}, [journeyId, read]);
useEffect(() => {
void refresh();
}, [refresh]);
useServerPing(eventName, journeyId !== null, refresh);
const update = useCallback(
(change: (data: T | null) => T | null) => {
if (journeyId === null || activeId.current !== journeyId) return;
setLoaded((previous) => {
const data = change(previous?.journeyId === journeyId ? previous.data : null);
return data === null ? previous : { journeyId, data };
});
},
[journeyId]
);
const current = loaded?.journeyId === journeyId ? loaded : null;
const status: LoadStatus =
journeyId === null ? 'idle' : current ? 'ready' : failedFor === journeyId ? 'failed' : 'loading';
return { data: current?.data ?? null, status, update };
}
@@ -4,11 +4,11 @@ import {
type JourneyRecordingSource,
type JourneyTrack,
} from '@trek/shared';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from '../../i18n';
import { journeyRecordingsRepo } from '../../repo/journeyRecordingsRepo';
import { useServerPing } from '../../sync/useServerPing';
import { DAWARICH_TRAIL_COLOR } from '../Map/dawarichTrail';
import { useJourneyLiveData } from './useJourneyLiveData';
import type { JourneyRecordingViewProps } from './useJourneyRecordingDay';
interface JourneyRecordingsState {
@@ -53,52 +53,15 @@ export function useJourneyRecordings(
const journeyId = journey?.id ?? null;
const journeyTitle = journey?.title ?? '';
const { t, locale } = useTranslation();
// Held with the journey they belong to, so a journey opened after another
// never shows the other one's days, and nothing has to be reset in an effect.
const [loaded, setLoaded] = useState<{ journeyId: number | null; days: JourneyRecordedDay[] }>(NOTHING_LOADED);
const { data, status, update } = useJourneyLiveData(
journeyId,
'journey:recording:updated',
journeyRecordingsRepo.list
);
const days = data ?? NO_DAYS;
const [opened, setOpened] = useState<{ journeyId: number | null; date: string | null }>(NOTHING_OPEN);
const [failedFor, setFailedFor] = useState<number | null>(null);
const days = loaded.journeyId === journeyId ? loaded.days : NO_DAYS;
const status =
journeyId === null
? 'idle'
: loaded.journeyId === journeyId
? 'ready'
: failedFor === journeyId
? 'failed'
: 'loading';
const openDate = opened.journeyId === journeyId ? opened.date : null;
const read = useCallback(async () => {
if (journeyId === null) return null;
try {
return { journeyId, days: await journeyRecordingsRepo.list(journeyId) };
} catch {
// What was read before stays on the map; a kept day does not vanish
// because one read of it failed.
return null;
}
}, [journeyId]);
useEffect(() => {
let cancelled = false;
void read().then((next) => {
if (cancelled) return;
if (next) setLoaded(next);
else setFailedFor(journeyId);
});
return () => {
cancelled = true;
};
}, [read, journeyId]);
const reload = useCallback(async () => {
const next = await read();
if (next) setLoaded(next);
}, [read]);
useServerPing('journey:recording:updated', journeyId !== null, reload);
const shown = useMemo(() => oneRecordingPerDay(days), [days]);
const byDate = useMemo(() => new Map(shown.map((day) => [day.date, day])), [shown]);
const bySource = useMemo(
@@ -131,16 +94,15 @@ export function useJourneyRecordings(
);
const keptMany = useCallback(
(fresh: readonly JourneyRecordedDay[]) =>
setLoaded((prev) => ({ journeyId, days: withKeptDays(prev.days, fresh) })),
[journeyId]
(fresh: readonly JourneyRecordedDay[]) => update((prev) => withKeptDays(prev ?? NO_DAYS, fresh)),
[update]
);
const kept = useCallback((day: JourneyRecordedDay) => keptMany([day]), [keptMany]);
const removed = useCallback(
(date: string, source: JourneyRecordingSource = 'dawarich') =>
setLoaded((prev) => ({ journeyId, days: prev.days.filter((d) => d.date !== date || d.source !== source) })),
[journeyId]
update((prev) => (prev ?? NO_DAYS).filter((d) => d.date !== date || d.source !== source)),
[update]
);
const open = useCallback((date: string) => setOpened({ journeyId, date }), [journeyId]);
@@ -178,5 +140,4 @@ export function withKeptDays(
/** Stable empty identity, so a journey without kept days never re-renders its map for nothing. */
const NO_DAYS: JourneyRecordedDay[] = [];
const NOTHING_LOADED = { journeyId: null, days: NO_DAYS };
const NOTHING_OPEN = { journeyId: null, date: null };
@@ -56,7 +56,9 @@ describe('owner access settings', () => {
expect(mocks.toast.success).toHaveBeenCalledWith('journey.share.passwordSaved');
await act(async () => result.current.removePassword());
expect(write).toHaveBeenLastCalledWith({ password: null });
act(() => result.current.setExpiry(''));
await act(async () => {
result.current.setExpiry('');
});
expect(write).toHaveBeenLastCalledWith({ expires_at: null });
});
@@ -162,7 +162,7 @@ export function useJourneyShareLink(journeyId: number) {
const setProtection = async (change: JourneyShareProtectionChange): Promise<boolean> => {
if (!link) return false;
try {
await journeyApi.createShareLink(journeyId, change);
await journeyApi.createShareLink(journeyId, { ...change });
setLink((current) => (current ? applyProtection(current, change) : current));
return true;
} catch {
@@ -368,18 +368,7 @@ function MapContent({ el, set, t, stats, journeyPath }: MapPropsInput) {
</Line>
</Section>
{el.countries.length > 0 && ((el.source === 'vector' && el.showLand) || el.clip === 'country') && (
<Section label={t('journey.studio.mapCoastDetail')} defaultOpen={false}>
<Choice
value={el.coastDetail ?? 'auto'}
options={BOOK_MAP_COAST_DETAILS.map(value => ({
value,
label: t(`journey.studio.mapCoastDetail.${value}`),
}))}
onPick={coastDetail => set({ coastDetail } as Partial<BookElement>)}
/>
</Section>
)}
<MapCoastSection el={el} set={set} t={t} />
{el.source === 'tiles' && (
<Section label={t('journey.studio.tileDetail')} defaultOpen={mapZoomInUse(el)}>
@@ -397,6 +386,23 @@ function MapContent({ el, set, t, stats, journeyPath }: MapPropsInput) {
)
}
function MapCoastSection({ el, set, t }: Props<BookMapElement>) {
const drawsCoast = (el.source === 'vector' && el.showLand) || el.clip === 'country'
if (!drawsCoast || el.countries.length === 0) return null
return (
<Section label={t('journey.studio.mapCoastDetail')} defaultOpen={false}>
<Choice
value={el.coastDetail ?? 'auto'}
options={BOOK_MAP_COAST_DETAILS.map(value => ({
value,
label: t(`journey.studio.mapCoastDetail.${value}`),
}))}
onPick={coastDetail => set({ coastDetail } as Partial<BookElement>)}
/>
</Section>
)
}
/**
* How a map looks: the line of the route, whether it follows the roads, and
* which layers are drawn. After the position, like the look of every kind.
@@ -77,7 +77,7 @@ async function fetchDetail(code: string): Promise<CountryShape | null> {
function loadOne(code: string): Promise<void> {
if (loaded.has(code)) return Promise.resolve();
const running = inFlight.get(code);
if (running) return running;
if (running !== undefined) return running;
const load = fetchDetail(code).then((shape) => {
loaded.set(code, shape);
inFlight.delete(code);
@@ -175,6 +175,7 @@ describe('the order of the groups', () => {
expect(groups(m.container)).toEqual([
'journey.studio.routeMap',
'journey.studio.mapFraming',
'journey.studio.mapCoastDetail',
'journey.studio.position',
'journey.studio.routeLook',
'journey.studio.mapLayers',