feat(client): let a trip URL open on a given tab

/trips/:id?tab=finanzplan opens the planner straight on that tab. Read in
the state initializer, not an effect, so the planner never paints the plan
view and swaps a frame later. The param is consumed on arrival; the
session memory keeps the choice across a reload.

Two things the tab machinery got away with while nothing ever started on a
tab other than plan:

- the guard evicted anything not in TRIP_TABS, but enabledAddons is an
  optimistic guess until the addon feed answers, and collab is guessed off
  - so a requested collab tab was thrown away a render before we knew the
  addon was on. It now waits for the feed, like it already did for plugins.
- the lazy loads hang off handleTabChange, which the tab we *start* on
  never goes through. Opening on Files showed an empty list, and that was
  already true for a tab restored from a previous visit.

Tab ids move to constants/tripTabs so the settings picker can name them
the way the tab bar does instead of keeping a second list.
This commit is contained in:
Maurice
2026-08-08 21:03:39 +02:00
committed by Maurice
parent 99ee307034
commit 688ce0fae2
3 changed files with 178 additions and 13 deletions
+50
View File
@@ -0,0 +1,50 @@
/**
* The trip planner's core tab ids, in the order the tab bar shows them.
*
* These are the German legacy names the planner has always used internally
* ('buchungen', 'finanzplan', 'dateien', 'listen') — not the English labels.
* They are what sessionStorage, the ?tab= deep link and the startup-destination
* setting persist, so renaming one would silently strand saved preferences.
*
* Addon-owned tabs are listed here even while their addon is off: useTripPlanner
* builds TRIP_TABS from what is actually enabled, and anything pointing at a tab
* that isn't there falls back to the plan view.
*/
export const TRIP_TAB_IDS = [
'plan',
'transports',
'buchungen',
'listen',
'finanzplan',
'dateien',
'collab',
] as const
export type TripTabId = (typeof TRIP_TAB_IDS)[number]
/**
* Translation key per tab, so the startup-destination picker in Settings names
* the tabs exactly as the planner's own tab bar does. useTripPlanner builds its
* TRIP_TABS from these too — one source, or the two would drift apart the first
* time a tab is renamed.
*/
export const TRIP_TAB_LABEL_KEYS: Record<TripTabId, string> = {
plan: 'trip.tabs.plan',
transports: 'trip.tabs.transports',
buchungen: 'trip.tabs.reservations',
listen: 'trip.tabs.lists',
finanzplan: 'trip.tabs.budget',
dateien: 'trip.tabs.files',
collab: 'admin.addons.catalog.collab.name',
}
export const isTripTabId = (value: unknown): value is TripTabId =>
typeof value === 'string' && (TRIP_TAB_IDS as readonly string[]).includes(value)
/**
* What `/trips/:id?tab=…` accepts. Trip-page plugins mount as tabs too and are
* addressable by their `plugin:<id>` form, so a shortcut can point at one — the
* planner's own guard still drops it if that plugin isn't installed.
*/
export const isDeepLinkableTripTab = (value: string): boolean =>
isTripTabId(value) || value.startsWith('plugin:')