From ce5aaa8706516eeddef2504fbb221fc00e62cdf1 Mon Sep 17 00:00:00 2001 From: Timothy Date: Wed, 15 Jul 2026 22:34:19 +0200 Subject: [PATCH] refactor(web): extract app shell and routing Refs #247 Co-Authored-By: OpenAI Codex --- web/src/App.tsx | 1185 +-------------------------------- web/src/app/AppShell.tsx | 364 ++++++++++ web/src/app/ScreenContent.tsx | 225 +++++++ web/src/app/routes.tsx | 524 +++++++++++++++ 4 files changed, 1148 insertions(+), 1150 deletions(-) create mode 100644 web/src/app/AppShell.tsx create mode 100644 web/src/app/ScreenContent.tsx create mode 100644 web/src/app/routes.tsx diff --git a/web/src/App.tsx b/web/src/App.tsx index 7d649f881..e2df509a9 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -3,1137 +3,23 @@ import { useMemo, useRef, useState, - type KeyboardEvent, - type MouseEvent, - type ReactNode + type MouseEvent } from 'react'; +import { useDashboardHealthQuery } from './api'; +import { AppShell } from './app/AppShell'; +import { ScreenContent } from './app/ScreenContent'; import { - Bell, - Boxes, - Palette, - CalendarClock, - CalendarDays, - CalendarRange, - Cast, - Check, - ChevronDown, - Clapperboard, - CircleHelp, - ClipboardCopy, - Film, - FolderTree, - Info, - Layers, - KeyRound, - LayoutDashboard, - LayoutGrid, - Library, - Link2, - ListChecks, - ListMusic, - ListVideo, - Plus, - Repeat, - ScrollText, - Search, - Settings, - SlidersHorizontal, - Stamp, - Stethoscope, - Trash2, - Tv -} from 'lucide-react'; -import chicoryMarkUrl from '../../design-system/assets/chicory-mark.svg'; -import { ChannelBuilderScreen } from './builder/ChannelBuilder'; -import { ChannelEditScreen } from './screens/ChannelEditScreen'; -import { CollectionsScreen } from './screens/CollectionsScreen'; -import { FFmpegProfilesScreen } from './screens/FFmpegProfilesScreen'; -import { FillerPresetsScreen } from './screens/FillerPresetsScreen'; -import { LogsScreen } from './screens/LogsScreen'; -import { MediaBrowseScreen } from './screens/MediaBrowseScreen'; -import { MultiCollectionsScreen } from './screens/MultiCollectionsScreen'; -import { PlaylistsScreen } from './screens/PlaylistsScreen'; -import { RerunCollectionsScreen } from './screens/RerunCollectionsScreen'; -import { ChannelsScreen } from './screens/ChannelsScreen'; -import { LibrariesScreen } from './screens/LibrariesScreen'; -import { LocalLibraryEditScreen } from './screens/LocalLibraryEditScreen'; -import { PlexSourceScreen } from './screens/PlexSourceScreen'; -import { RemoteSourceScreen } from './screens/RemoteSourceScreen'; -import { RemoteConnectionEditScreen } from './screens/RemoteConnectionEditScreen'; -import { RemoteLibrariesEditScreen } from './screens/RemoteLibrariesEditScreen'; -import { PathReplacementsEditScreen } from './screens/PathReplacementsEditScreen'; -import { SchedulesScreen } from './screens/SchedulesScreen'; -import { canLeaveCurrentScreen } from './navigationGuard'; -import { dispatchPrimaryAction } from './primaryAction'; -import { - ArtistDetailScreen, - MovieDetailScreen, - SeasonDetailScreen, - ShowDetailScreen -} from './screens/MediaDetailScreen'; -import { ImageBrowserScreen } from './screens/ImageBrowserScreen'; -import { SearchScreen } from './screens/SearchScreen'; -import { SettingsScreen } from './screens/SettingsScreen'; -import { ApiKeyScreen } from './screens/ApiKeyScreen'; -import { UnauthorizedBanner } from './UnauthorizedBanner'; -import { UserMenu } from './UserMenu'; -import { TraktListsScreen } from './screens/TraktListsScreen'; -import { TrashScreen } from './screens/TrashScreen'; -import { TroubleshootingScreen } from './screens/TroubleshootingScreen'; -import { BlockPlayoutTroubleshootingScreen } from './screens/BlockPlayoutTroubleshootingScreen'; -import { PlaybackTroubleshootingScreen } from './screens/PlaybackTroubleshootingScreen'; -import { YamlValidatorScreen } from './screens/YamlValidatorScreen'; -import { WatermarksScreen } from './screens/WatermarksScreen'; -import { BlocksScreen } from './screens/BlocksScreen'; -import { DecosScreen } from './screens/DecosScreen'; -import { DecoTemplatesScreen } from './screens/DecoTemplatesScreen'; -import { TemplatesScreen } from './screens/TemplatesScreen'; -import { PlayoutsRouteScreen } from './screens/PlayoutsScreen'; -import { DashboardHealthSummary, DashboardScreen } from './screens/DashboardScreen'; -import { GuideScreen } from './screens/GuideScreen'; -import { - navigateToPath, - parseLibrariesSubRoute, - parseMediaSubRoute -} from './routing'; -import { - Badge, - Button, - Card, - IconButton, - NavItem, - NavSection -} from './components'; -import { - useChannelsQuery, - useDashboardHealthQuery, - useDashboardVersionQuery, - type DashboardHealthQueryState -} from './api'; + routeFromLocation, + routeHref, + type ScreenRoute +} from './app/routes'; import { applyDesignSystemTheme, - designSystemThemes, getStoredDesignSystemTheme, type DesignSystemThemeId } from './designSystem'; - -type ScreenId = - | 'dashboard' - | 'channels' - | 'builder' - | 'editChannel' - | 'guide' - | 'schedules' - | 'blocks' - | 'templates' - | 'decos' - | 'decoTemplates' - | 'playouts' - | 'media' - | 'search' - | 'trash' - | 'collections' - | 'multiCollections' - | 'rerunCollections' - | 'playlists' - | 'fillerPresets' - | 'libraries' - | 'traktLists' - | 'ffmpegProfiles' - | 'watermarks' - | 'settings' - | 'apiKey' - | 'logs' - | 'troubleshooting' - | 'blockPlayoutTroubleshooting' - | 'playbackTroubleshooting' - | 'yamlValidator'; - -interface ScreenRoute { - id: ScreenId; - path: string; - label: string; - title: string; - kicker: string; - description: string; - icon: ReactNode; - primaryAction: string; - placeholder: string; - badge?: number; - // Screens that own linkable sub-sections (e.g. /app/settings/streaming) opt in here; - // the sub-path is otherwise unowned and 404s (see routeFromLocation). - allowSubPaths?: boolean; -} - -const routes: ScreenRoute[] = [ - { - id: 'dashboard', - path: '/app', - label: 'Dashboard', - title: 'Dashboard', - kicker: 'Overview', - description: 'On-air status, health checks, and recent server activity.', - icon: