The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(plugins): show a trip page that replaces a core tab while that tab's addon is off
Mauricefd10ce2876be
diff --git a/client/src/pages/tripPlanner/useTripPlanner.tripAddons.test.tsx b/client/src/pages/tripPlanner/useTripPlanner.tripAddons.test.tsxindex a49deae55..9a578ccf7 100644--- a/client/src/pages/tripPlanner/useTripPlanner.tripAddons.test.tsx+++ b/client/src/pages/tripPlanner/useTripPlanner.tripAddons.test.tsx@@ -149,7 +149,7 @@ describe('useTripPlanner — the trip’s own addons', () => {expect(tabIds(result)).toContain('tour-planner');});- it('FE-TP-TRIPADDONS-004: a plugin page that replaces Costs follows the Costs addon of the trip', async () => {+ it('FE-TP-TRIPADDONS-004: a plugin page that replaces Costs stays while the trip has Costs off', async () => {seedInstanceAddons(['budget']);usePluginStore.setState({plugins: [@@ -162,7 +162,8 @@ describe('useTripPlanner — the trip’s own addons', () => {const { result } = await renderPlanner();- await waitFor(() => expect(tabIds(result)).not.toContain('plugin:ledger'));+ await waitFor(() => expect(useTripAddonsStore.getState().trips['1:42']?.status).toBe('ready'));+ expect(tabIds(result)).toContain('plugin:ledger');expect(tabIds(result)).toContain('plugin:notes');expect(tabIds(result)).not.toContain('finanzplan');});diff --git a/client/src/pages/tripPlanner/useTripPlanner.ts b/client/src/pages/tripPlanner/useTripPlanner.tsindex bd7ec9760..5d62632b9 100644--- a/client/src/pages/tripPlanner/useTripPlanner.ts+++ b/client/src/pages/tripPlanner/useTripPlanner.ts@@ -71,7 +71,6 @@ import { TRIP_SPLASH_AFTER_MS } from '../../components/shared/useTripSplashBeatsimport { useFlightLiveSync } from '../../components/Planner/flightLive/useFlightLiveSync'import { useMailPrefillLink } from '../../components/MailIngest/useMailPrefillLink'import { usePlannerAddons } from './usePlannerAddons'-import { pluginPageShown } from '../../utils/tripAddons'/*** The trip's roster from the server: the owner and the members. Null offline@@ -214,8 +213,7 @@ export function useTripPlanner() {}, [])- // A plugin page that replaces a core tab follows that tab's addon on this trip.- const tripPagePlugins = allPlugins.filter(p => p.type === 'trip-page' && pluginPageShown(p.tripPage?.replaces, id => !!enabledAddons[id]))+ const tripPagePlugins = allPlugins.filter(p => p.type === 'trip-page')const tripPluginIds = tripPagePlugins.map(p => p.id).join(',')// A trip-page plugin may replace core tabs while it's active (its manifest namesdiff --git a/client/src/utils/tripAddons.test.ts b/client/src/utils/tripAddons.test.tsindex 8abe608eb..7343f889c 100644--- a/client/src/utils/tripAddons.test.ts+++ b/client/src/utils/tripAddons.test.ts@@ -1,7 +1,7 @@-// FE-UTIL-TRIPADDONS-001 to FE-UTIL-TRIPADDONS-003+// FE-UTIL-TRIPADDONS-001 to FE-UTIL-TRIPADDONS-002import type { TripAddon } from '@trek/shared';import { describe, expect, it } from 'vitest';-import { pluginPageShown, tripAddonEnabled } from './tripAddons';+import { tripAddonEnabled } from './tripAddons';const addon = (id: string, enabled: boolean): TripAddon => ({id,@@ -25,17 +25,3 @@ describe('tripAddonEnabled', () => {expect(tripAddonEnabled([], 'packing', false)).toBe(false);});});--describe('pluginPageShown', () => {- it('FE-UTIL-TRIPADDONS-003: a page that replaces core tabs shows while one of their addons is on', () => {- const on = (ids: string[]) => (id: string) => ids.includes(id);- expect(pluginPageShown(undefined, on([]))).toBe(true);- expect(pluginPageShown([], on([]))).toBe(true);- expect(pluginPageShown(['finanzplan'], on(['budget']))).toBe(true);- expect(pluginPageShown(['finanzplan'], on(['packing']))).toBe(false);- expect(pluginPageShown(['finanzplan', 'listen'], on(['packing']))).toBe(true);- expect(pluginPageShown(['dateien', 'collab'], on([]))).toBe(false);- // A tab no addon owns does not hide the page.- expect(pluginPageShown(['plan'], on([]))).toBe(true);- });-});diff --git a/client/src/utils/tripAddons.ts b/client/src/utils/tripAddons.tsindex f812bdcf1..d69b90e2a 100644--- a/client/src/utils/tripAddons.ts+++ b/client/src/utils/tripAddons.ts@@ -17,25 +17,3 @@ export function tripAddonEnabled(const own = tripAddons?.find((addon) => addon.id === addonId);return own ? own.enabled : instanceEnabled;}--/** The trip addon a core trip tab belongs to; a plugin page that replaces the tab follows it. */-const TRIP_TAB_ADDON: Readonly<Record<string, string>> = {- listen: 'packing',- finanzplan: 'budget',- dateien: 'documents',- collab: 'collab',-};--/**- * Whether a plugin's trip page shows on a trip. A page that replaces core tabs- * stands in for them, so it shows while the addon of at least one of those tabs- * is on for the trip; a page that replaces none (or only tabs no addon owns)- * always shows.- */-export function pluginPageShown(- replaces: readonly string[] | undefined,- addonOn: (addonId: string) => boolean-): boolean {- const owned = (replaces ?? []).flatMap((tab) => (TRIP_TAB_ADDON[tab] ? [TRIP_TAB_ADDON[tab]] : []));- return owned.length === 0 || owned.some(addonOn);-}