From 4fa86959047271894d97f368a5c6be212ef6565d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemek=20Wi=C4=99ch?= Date: Wed, 10 Jun 2026 19:37:54 +0200 Subject: [PATCH] make chart-specific props and event handlers optional --- docs/APP_REFACTORING_DESIGN.md | 2 +- src/menu/top_bar.tsx | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/docs/APP_REFACTORING_DESIGN.md b/docs/APP_REFACTORING_DESIGN.md index 4e7301b..92f66f1 100644 --- a/docs/APP_REFACTORING_DESIGN.md +++ b/docs/APP_REFACTORING_DESIGN.md @@ -83,7 +83,7 @@ To refactor `app.tsx` safely and maintain continuous code correctness, we will m * [x] **Step 1.1:** Create `src/components/error_display.tsx` and move `ErrorMessage` and `ErrorPopup` from `src/app.tsx`. Update imports in `src/app.tsx`. * [x] **Step 1.2:** Create `src/datasource/instances.ts` and move data source class instantiations. Update references in `src/app.tsx`. Refactor `EmbeddedDataSource` to clean up its message event listener when the loading promise resolves or rejects (or track listener state) to prevent duplicate event listener leaks on multiple page mounts. * [x] **Step 1.3:** Create `src/util/url_args.ts` (the parsing utility) and `src/util/url_args.spec.ts` (its Jest unit test suite) together. Extract URL query parameter parsing functions and types from `src/app.tsx`, write comprehensive tests, update imports in `src/app.tsx`, and run `npm test` to verify. -* [ ] **Step 1.4:** Modify `src/menu/top_bar.tsx` to make chart-specific props and event handlers optional (e.g. `data`, `allowAllRelativesChart`, `allowPrintAndDownload`, `eventHandlers`, etc.), preparing the component for rendering on the landing screen without dummy properties. +* [x] **Step 1.4:** Modify `src/menu/top_bar.tsx` to make chart-specific props and event handlers optional (e.g. `data`, `allowAllRelativesChart`, `allowPrintAndDownload`, `eventHandlers`, etc.), preparing the component for rendering on the landing screen without dummy properties. #### Phase 2: WebMCP Bridge Extraction * [ ] **Step 2.1:** Create `src/hooks/use_webmcp_bridge.ts` wrapping WebMCP registration and synchronization effects. diff --git a/src/menu/top_bar.tsx b/src/menu/top_bar.tsx index 4255e46..72b889b 100644 --- a/src/menu/top_bar.tsx +++ b/src/menu/top_bar.tsx @@ -32,13 +32,13 @@ interface Props { data?: JsonGedcomData; standalone: boolean; /** Whether to show the "All relatives" chart type in the menu. */ - allowAllRelativesChart: boolean; - allowPrintAndDownload: boolean; - eventHandlers: EventHandlers; + allowAllRelativesChart?: boolean; + allowPrintAndDownload?: boolean; + eventHandlers?: EventHandlers; /** Whether to show additional WikiTree menus. */ - showWikiTreeMenus: boolean; + showWikiTreeMenus?: boolean; /** Whether the user has authorized Google Drive and has an active token. */ - hasGoogleToken: boolean; + hasGoogleToken?: boolean; /** Callback to sign out of Google Drive. */ onGoogleSignOut?: () => void; /** Callback triggered when a new Google Drive token is acquired. */ @@ -101,7 +101,7 @@ export function TopBar(props: Props) { return ( <> @@ -122,19 +122,19 @@ export function TopBar(props: Props) { disabled={!props.allowPrintAndDownload} > - + - + - + undefined) + } {...props} /> @@ -165,28 +167,28 @@ export function TopBar(props: Props) { case ScreenSize.SMALL: return ( <> - + - + - + - + undefined)} {...props} /> )}