Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Split mobile nav runtime owners
rcourtman162ca62c56a8
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 306ed02655..bbab3a7ac0 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -239,6 +239,15 @@ popover-position lifecycle, and global click/escape listeners, andresolution, icon sizing, missing-content warnings, and popover-position math.Future help-icon work should extend those owners instead of pushing registrylookups or DOM listener lifecycle back into the shared shell.+The shared mobile nav now follows that same owner split.+`frontend-modern/src/components/shared/MobileNavBar.tsx` stays the render+shell, `frontend-modern/src/components/shared/useMobileNavBarState.ts` owns+fade signals, scroll and resize listeners, active-tab centering, and click+handoff lifecycle, and+`frontend-modern/src/components/shared/mobileNavBarModel.ts` owns platform and+utility tab ordering, alert badge counts, fade-state derivation, and tab+button class policy. Future mobile-nav work should extend those owners instead+of pushing tab-order or DOM lifecycle logic back into the shared shell.The audit log settings surface now follows that same owner split.`frontend-modern/src/components/Settings/AuditLogPanel.tsx` stays the canonicaldiff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex 286faaef0f..f83af1a871 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -2199,6 +2199,7 @@"frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx","frontend-modern/src/components/shared/__tests__/InfrastructureSelector.test.tsx","frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx",+ "frontend-modern/src/components/shared/__tests__/MobileNavBar.test.tsx","frontend-modern/src/components/shared/__tests__/PulseDataGrid.test.tsx","frontend-modern/src/components/shared/__tests__/SearchField.test.tsx","frontend-modern/src/components/shared/__tests__/SearchInput.test.tsx",diff --git a/frontend-modern/src/components/shared/MobileNavBar.tsx b/frontend-modern/src/components/shared/MobileNavBar.tsxindex cdfd6ca7f9..2a41dbd6cc 100644--- a/frontend-modern/src/components/shared/MobileNavBar.tsx+++ b/frontend-modern/src/components/shared/MobileNavBar.tsx@@ -1,161 +1,40 @@-import { createEffect, createMemo, createSignal, For, Show, onCleanup } from 'solid-js';-import type { JSX } from 'solid-js';--type PlatformTab = {- id: string;- label: string;- route: string;- settingsRoute: string;- tooltip: string;- enabled: boolean;- live: boolean;- icon: JSX.Element;- alwaysShow: boolean;- badge?: string;-};--type UtilityTab = {- id: 'alerts' | 'ai' | 'operations' | 'settings';- label: string;- route: string;- tooltip: string;- badge: 'update' | 'pro' | null;- count: number | undefined;- breakdown: { warning: number; critical: number } | undefined;- icon: JSX.Element;-};--type MobileNavBarProps = {- activeTab: () => string;- platformTabs: () => PlatformTab[];- utilityTabs: () => UtilityTab[];- onPlatformClick: (platform: PlatformTab) => void;- onUtilityClick: (tab: UtilityTab) => void;-};+import { For, Show } from 'solid-js';+import { type MobileNavBarProps, useMobileNavBarState } from './useMobileNavBarState';+import {+ getMobileNavAlertBadgeCounts,+ getMobileNavTabButtonClass,+} from './mobileNavBarModel';++export type {+ MobileNavBarPlatformTab,+ MobileNavBarProps,+ MobileNavBarUtilityTab,+} from './mobileNavBarModel';export function MobileNavBar(props: MobileNavBarProps) {- let navRef: HTMLDivElement | undefined;- const [showFade, setShowFade] = createSignal(false);- const [showLeftFade, setShowLeftFade] = createSignal(false);-- const orderedPlatformTabs = createMemo(() => {- const tabs = props.platformTabs();- const priority = ['dashboard', 'infrastructure', 'workloads', 'storage', 'recovery'];- const prioritySet = new Set(priority);- const byId = new Map(tabs.map((tab) => [tab.id, tab]));- const ordered: PlatformTab[] = [];- priority.forEach((id) => {- const tab = byId.get(id);- if (tab) ordered.push(tab);- });- tabs.forEach((tab) => {- if (!prioritySet.has(tab.id)) ordered.push(tab);- });- return ordered;- });-- const orderedUtilityTabs = createMemo(() => {- const tabs = props.utilityTabs();- const priority = ['alerts', 'ai', 'operations', 'settings'];- const prioritySet = new Set(priority);- const byId = new Map(tabs.map((tab) => [tab.id, tab]));- const ordered: UtilityTab[] = [];- priority.forEach((id) => {- const tab = byId.get(id as UtilityTab['id']);- if (tab) ordered.push(tab);- });- tabs.forEach((tab) => {- if (!prioritySet.has(tab.id)) ordered.push(tab);- });- return ordered;- });-- const updateFadeIndicator = () => {- if (!navRef) {- setShowFade(false);- return;- }- const maxScrollLeft = navRef.scrollWidth - navRef.clientWidth;- setShowFade(maxScrollLeft > 1 && navRef.scrollLeft < maxScrollLeft - 1);- setShowLeftFade(navRef.scrollLeft > 1);- };-- createEffect(() => {- if (!navRef) return;- updateFadeIndicator();- const handleScroll = () => updateFadeIndicator();- navRef.addEventListener('scroll', handleScroll, { passive: true });- window.addEventListener('resize', handleScroll);- onCleanup(() => {- navRef?.removeEventListener('scroll', handleScroll);- window.removeEventListener('resize', handleScroll);- });- });-- createEffect(() => {- if (!navRef) return;- const activeId = props.activeTab();- if (!activeId) return;- const activeEl = navRef.querySelector<HTMLElement>(`[data-tab-id="${activeId}"]`);- if (!activeEl) return;- requestAnimationFrame(() => {- activeEl.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });- updateFadeIndicator();- });- });-- const handlePlatformClick = (platform: PlatformTab) => {- props.onPlatformClick(platform);- };-- const handleUtilityClick = (tab: UtilityTab) => {- props.onUtilityClick(tab);- };-- const renderAlertsBadge = (tab: UtilityTab) => {- if (tab.id !== 'alerts') return null;- if (!tab || !tab.count || tab.count <= 0) return null;- const critical = tab.breakdown?.critical ?? 0;- const warning = tab.breakdown?.warning ?? 0;- return (- <span class="absolute -right-2 -top-1 flex items-center gap-1">- {critical > 0 && (- <span class="inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-red-600 px-1 text-[10px] font-bold text-white">- {critical}- </span>- )}- {warning > 0 && (- <span class="inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-amber-200 px-1 text-[10px] font-semibold text-amber-900">- {warning}- </span>- )}- </span>- );- };+ const mobileNav = useMobileNavBarState(props);return (<>- {/* Bottom navigation bar */}- <nav class="fixed inset-x-0 bottom-0 z-40 border-t border-border bg-surface md:hidden pb-safe">+ <nav class="fixed inset-x-0 bottom-0 z-40 border-t border-border bg-surface pb-safe md:hidden"><div class="relative"><div- ref={(el) => (navRef = el)}+ ref={mobileNav.setNavRef}class="flex items-center gap-1 overflow-x-auto scrollbar-hide px-2 py-1.5"role="tablist"aria-label="Mobile navigation">- <For each={orderedPlatformTabs()}>+ <For each={mobileNav.orderedPlatformTabs()}>{(platform) => (<buttontype="button"data-tab-id={platform.id}- onClick={() => handlePlatformClick(platform)}+ onClick={() => mobileNav.handlePlatformClick(platform)}title={platform.tooltip}- class={`relative flex min-h-10 shrink-0 flex-col items-center gap-1 rounded-md px-2 py-1.5 text-[11px] font-medium transition-colors ${- props.activeTab() === platform.id- ? 'bg-blue-50 text-blue-700 dark:bg-blue-900 dark:text-blue-300'- : 'text-muted'- } ${platform.enabled ? '' : 'opacity-70'}`}+ class={getMobileNavTabButtonClass({+ active: props.activeTab() === platform.id,+ enabled: platform.enabled,+ })}><span class="relative flex items-center justify-center">{platform.icon}</span><span class="whitespace-nowrap">{platform.label}</span>@@ -173,41 +52,58 @@ export function MobileNavBar(props: MobileNavBarProps) {)}</For>- <For each={orderedUtilityTabs()}>- {(tab) => (- <button- type="button"- data-tab-id={tab.id}- onClick={() => handleUtilityClick(tab)}- title={tab.tooltip}- class={`relative flex min-h-10 shrink-0 flex-col items-center gap-1 rounded-md px-2 py-1.5 text-[11px] font-medium transition-colors ${- props.activeTab() === tab.id- ? 'bg-blue-50 text-blue-700 dark:bg-blue-900 dark:text-blue-300'- : 'text-muted'- }`}- >- <span class="relative flex items-center justify-center">- {tab.icon}- {renderAlertsBadge(tab)}- </span>- <span class="whitespace-nowrap">{tab.label}</span>- <Show when={tab.badge === 'update'}>- <span class="mt-0.5 h-1.5 w-1.5 rounded-full bg-red-500"></span>- </Show>- <Show when={tab.badge === 'pro'}>- <span class="rounded-full bg-blue-100 px-1.5 py-0.5 text-[9px] font-semibold text-blue-700 dark:bg-blue-900 dark:text-blue-300">- Pro+ <For each={mobileNav.orderedUtilityTabs()}>+ {(tab) => {+ const alertBadges = () => getMobileNavAlertBadgeCounts(tab);++ return (+ <button+ type="button"+ data-tab-id={tab.id}+ onClick={() => mobileNav.handleUtilityClick(tab)}+ title={tab.tooltip}+ class={getMobileNavTabButtonClass({+ active: props.activeTab() === tab.id,+ })}+ >+ <span class="relative flex items-center justify-center">+ {tab.icon}+ <Show when={alertBadges()}>+ {(badges) => (+ <span class="absolute -right-2 -top-1 flex items-center gap-1">+ <Show when={badges().critical > 0}>+ <span class="inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-red-600 px-1 text-[10px] font-bold text-white">+ {badges().critical}+ </span>+ </Show>+ <Show when={badges().warning > 0}>+ <span class="inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-amber-200 px-1 text-[10px] font-semibold text-amber-900">+ {badges().warning}+ </span>+ </Show>+ </span>+ )}+ </Show></span>- </Show>- </button>- )}+ <span class="whitespace-nowrap">{tab.label}</span>+ <Show when={tab.badge === 'update'}>+ <span class="mt-0.5 h-1.5 w-1.5 rounded-full bg-red-500"></span>+ </Show>+ <Show when={tab.badge === 'pro'}>+ <span class="rounded-full bg-blue-100 px-1.5 py-0.5 text-[9px] font-semibold text-blue-700 dark:bg-blue-900 dark:text-blue-300">+ Pro+ </span>+ </Show>+ </button>+ );+ }}</For></div>- <Show when={showLeftFade()}>+ <Show when={mobileNav.showLeftFade()}><div class="pointer-events-none absolute inset-y-0 left-0 w-8 bg-gradient-to-r from-surface to-transparent"></div></Show>- <Show when={showFade()}>+ <Show when={mobileNav.showFade()}><div class="pointer-events-none absolute inset-y-0 right-0 w-8 bg-gradient-to-l from-surface to-transparent"></div></Show></div>diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.tsindex f512cd5bfe..83f4ecb2d4 100644--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts@@ -9,6 +9,8 @@ import helpIconSource from '@/components/shared/HelpIcon.tsx?raw';import helpIconModelSource from '@/components/shared/helpIconModel.ts?raw';import historyChartSource from '@/components/shared/HistoryChart.tsx?raw';import historyChartModelSource from '@/components/shared/historyChartModel.ts?raw';+import mobileNavBarSource from '@/components/shared/MobileNavBar.tsx?raw';+import mobileNavBarModelSource from '@/components/shared/mobileNavBarModel.ts?raw';import infrastructureSelectorSource from '@/components/shared/InfrastructureSelector.tsx?raw';import interactiveSparklineSource from '@/components/shared/InteractiveSparkline.tsx?raw';import interactiveSparklineModelSource from '@/components/shared/interactiveSparklineModel.ts?raw';@@ -24,6 +26,7 @@ import containerUpdateButtonStateSource from '@/components/shared/useContainerUpimport densityMapStateSource from '@/components/shared/useDensityMapState.ts?raw';import helpIconStateSource from '@/components/shared/useHelpIconState.ts?raw';import historyChartStateSource from '@/components/shared/useHistoryChartState.ts?raw';+import mobileNavBarStateSource from '@/components/shared/useMobileNavBarState.ts?raw';import infrastructureSelectorStateSource from '@/components/shared/useInfrastructureSelectorState.ts?raw';import interactiveSparklineStateSource from '@/components/shared/useInteractiveSparklineState.ts?raw';import webInterfaceUrlFieldSource from '@/components/shared/WebInterfaceUrlField.tsx?raw';@@ -287,4 +290,23 @@ describe('shared primitive guardrails', () => {expect(helpIconModelSource).toContain('calculateHelpPopoverPosition');expect(helpIconModelSource).toContain('helpIconSizeClasses');});++ it('keeps mobile nav on shell, runtime, and model owners', () => {+ expect(mobileNavBarSource).toContain('useMobileNavBarState');+ expect(mobileNavBarSource).toContain('getMobileNavTabButtonClass');+ expect(mobileNavBarSource).not.toContain('createSignal');+ expect(mobileNavBarSource).not.toContain('requestAnimationFrame');+ expect(mobileNavBarSource).not.toContain('new Set(priority)');++ expect(mobileNavBarStateSource).toContain('createSignal');+ expect(mobileNavBarStateSource).toContain('window.addEventListener');+ expect(mobileNavBarStateSource).toContain('requestAnimationFrame');+ expect(mobileNavBarStateSource).toContain('scrollIntoView');+ expect(mobileNavBarStateSource).toContain('export function useMobileNavBarState');++ expect(mobileNavBarModelSource).toContain('buildOrderedMobileNavPlatformTabs');+ expect(mobileNavBarModelSource).toContain('buildOrderedMobileNavUtilityTabs');+ expect(mobileNavBarModelSource).toContain('getMobileNavAlertBadgeCounts');+ expect(mobileNavBarModelSource).toContain('getMobileNavFadeState');+ });});diff --git a/frontend-modern/src/components/shared/__tests__/MobileNavBar.test.tsx b/frontend-modern/src/components/shared/__tests__/MobileNavBar.test.tsxnew file mode 100644index 0000000000..3f40403b61--- /dev/null+++ b/frontend-modern/src/components/shared/__tests__/MobileNavBar.test.tsx@@ -0,0 +1,118 @@+import { fireEvent, render, screen, waitFor } from '@solidjs/testing-library';+import { describe, expect, it, vi } from 'vitest';+import mobileNavBarSource from '@/components/shared/MobileNavBar.tsx?raw';+import mobileNavBarModelSource from '@/components/shared/mobileNavBarModel.ts?raw';+import mobileNavBarStateSource from '@/components/shared/useMobileNavBarState.ts?raw';+import { MobileNavBar } from '@/components/shared/MobileNavBar';++HTMLElement.prototype.scrollIntoView = vi.fn();+window.requestAnimationFrame = ((callback: FrameRequestCallback) => {+ callback(0);+ return 1;+}) as typeof window.requestAnimationFrame;++describe('MobileNavBar', () => {+ it('keeps the mobile nav on shell, runtime, and model owners', () => {+ expect(mobileNavBarSource).toContain('useMobileNavBarState');+ expect(mobileNavBarSource).toContain('getMobileNavTabButtonClass');+ expect(mobileNavBarSource).not.toContain('createSignal');+ expect(mobileNavBarSource).not.toContain('requestAnimationFrame');+ expect(mobileNavBarSource).not.toContain('new Set(priority)');++ expect(mobileNavBarStateSource).toContain('createSignal');+ expect(mobileNavBarStateSource).toContain('window.addEventListener');+ expect(mobileNavBarStateSource).toContain('requestAnimationFrame');+ expect(mobileNavBarStateSource).toContain('scrollIntoView');+ expect(mobileNavBarStateSource).toContain('export function useMobileNavBarState');++ expect(mobileNavBarModelSource).toContain('buildOrderedMobileNavPlatformTabs');+ expect(mobileNavBarModelSource).toContain('buildOrderedMobileNavUtilityTabs');+ expect(mobileNavBarModelSource).toContain('getMobileNavAlertBadgeCounts');+ expect(mobileNavBarModelSource).toContain('getMobileNavFadeState');+ });++ it('orders tabs, renders alert badges, and shows fades from scroll state', async () => {+ const onPlatformClick = vi.fn();+ const onUtilityClick = vi.fn();++ const { container } = render(() => (+ <MobileNavBar+ activeTab={() => 'dashboard'}+ platformTabs={() => [+ {+ id: 'storage',+ label: 'Storage',+ route: '/storage',+ settingsRoute: '/settings/storage',+ tooltip: 'Storage',+ enabled: true,+ live: true,+ icon: <span>ST</span>,+ alwaysShow: true,+ },+ {+ id: 'dashboard',+ label: 'Dashboard',+ route: '/dashboard',+ settingsRoute: '/settings/dashboard',+ tooltip: 'Dashboard',+ enabled: true,+ live: true,+ icon: <span>DB</span>,+ alwaysShow: true,+ },+ ]}+ utilityTabs={() => [+ {+ id: 'settings',+ label: 'Settings',+ route: '/settings',+ tooltip: 'Settings',+ badge: 'pro',+ count: undefined,+ breakdown: undefined,+ icon: <span>SE</span>,+ },+ {+ id: 'alerts',+ label: 'Alerts',+ route: '/alerts',+ tooltip: 'Alerts',+ badge: null,+ count: 5,+ breakdown: { critical: 2, warning: 3 },+ icon: <span>AL</span>,+ },+ ]}+ onPlatformClick={onPlatformClick}+ onUtilityClick={onUtilityClick}+ />+ ));++ const navList = screen.getByRole('tablist', { name: 'Mobile navigation' });+ Object.defineProperty(navList, 'scrollWidth', { configurable: true, value: 400 });+ Object.defineProperty(navList, 'clientWidth', { configurable: true, value: 200 });+ Object.defineProperty(navList, 'scrollLeft', { configurable: true, value: 20, writable: true });++ fireEvent.scroll(navList);++ const buttons = container.querySelectorAll('button[data-tab-id]');+ expect(buttons[0]).toHaveAttribute('data-tab-id', 'dashboard');+ expect(buttons[1]).toHaveAttribute('data-tab-id', 'storage');++ expect(screen.getByText('2')).toBeInTheDocument();+ expect(screen.getByText('3')).toBeInTheDocument();+ expect(screen.getByText('Pro')).toBeInTheDocument();++ fireEvent.click(screen.getByTitle('Storage'));+ expect(onPlatformClick).toHaveBeenCalledWith(expect.objectContaining({ id: 'storage' }));++ fireEvent.click(screen.getByTitle('Alerts'));+ expect(onUtilityClick).toHaveBeenCalledWith(expect.objectContaining({ id: 'alerts' }));++ await waitFor(() => {+ expect(container.querySelector('.bg-gradient-to-r')).toBeTruthy();+ expect(container.querySelector('.bg-gradient-to-l')).toBeTruthy();+ });+ });+});diff --git a/frontend-modern/src/components/shared/mobileNavBarModel.ts b/frontend-modern/src/components/shared/mobileNavBarModel.tsnew file mode 100644index 0000000000..3d2818b747--- /dev/null+++ b/frontend-modern/src/components/shared/mobileNavBarModel.ts@@ -0,0 +1,113 @@+import type { JSX } from 'solid-js';++export type MobileNavBarPlatformTab = {+ id: string;+ label: string;+ route: string;+ settingsRoute: string;+ tooltip: string;+ enabled: boolean;+ live: boolean;+ icon: JSX.Element;+ alwaysShow: boolean;+ badge?: string;+};++export type MobileNavBarUtilityTab = {+ id: 'alerts' | 'ai' | 'operations' | 'settings';+ label: string;+ route: string;+ tooltip: string;+ badge: 'update' | 'pro' | null;+ count: number | undefined;+ breakdown: { warning: number; critical: number } | undefined;+ icon: JSX.Element;+};++export type MobileNavBarProps = {+ activeTab: () => string;+ platformTabs: () => MobileNavBarPlatformTab[];+ utilityTabs: () => MobileNavBarUtilityTab[];+ onPlatformClick: (platform: MobileNavBarPlatformTab) => void;+ onUtilityClick: (tab: MobileNavBarUtilityTab) => void;+};++const MOBILE_NAV_PLATFORM_PRIORITY = [+ 'dashboard',+ 'infrastructure',+ 'workloads',+ 'storage',+ 'recovery',+] as const;++const MOBILE_NAV_UTILITY_PRIORITY = ['alerts', 'ai', 'operations', 'settings'] as const;++export function buildOrderedMobileNavTabs<T extends { id: string }>(+ tabs: T[],+ priority: readonly string[],+): T[] {+ const prioritySet = new Set(priority);+ const byId = new Map(tabs.map((tab) => [tab.id, tab]));+ const ordered: T[] = [];++ priority.forEach((id) => {+ const tab = byId.get(id);+ if (tab) ordered.push(tab);+ });++ tabs.forEach((tab) => {+ if (!prioritySet.has(tab.id)) ordered.push(tab);+ });++ return ordered;+}++export function buildOrderedMobileNavPlatformTabs(+ tabs: MobileNavBarPlatformTab[],+): MobileNavBarPlatformTab[] {+ return buildOrderedMobileNavTabs(tabs, MOBILE_NAV_PLATFORM_PRIORITY);+}++export function buildOrderedMobileNavUtilityTabs(+ tabs: MobileNavBarUtilityTab[],+): MobileNavBarUtilityTab[] {+ return buildOrderedMobileNavTabs(tabs, MOBILE_NAV_UTILITY_PRIORITY);+}++export function getMobileNavAlertBadgeCounts(+ tab: MobileNavBarUtilityTab,+): { critical: number; warning: number } | null {+ if (tab.id !== 'alerts') return null;+ if (!tab.count || tab.count <= 0) return null;++ return {+ critical: tab.breakdown?.critical ?? 0,+ warning: tab.breakdown?.warning ?? 0,+ };+}++export function getMobileNavTabButtonClass(options: {+ active: boolean;+ enabled?: boolean;+}): string {+ return `relative flex min-h-10 shrink-0 flex-col items-center gap-1 rounded-md px-2 py-1.5 text-[11px] font-medium transition-colors ${+ options.active+ ? 'bg-blue-50 text-blue-700 dark:bg-blue-900 dark:text-blue-300'+ : 'text-muted'+ } ${options.enabled === false ? 'opacity-70' : ''}`.trim();+}++export function getMobileNavFadeState(element: HTMLDivElement | undefined): {+ showLeftFade: boolean;+ showRightFade: boolean;+} {+ if (!element) {+ return { showLeftFade: false, showRightFade: false };+ }++ const maxScrollLeft = element.scrollWidth - element.clientWidth;+ return {+ showLeftFade: element.scrollLeft > 1,+ showRightFade: maxScrollLeft > 1 && element.scrollLeft < maxScrollLeft - 1,+ };+}diff --git a/frontend-modern/src/components/shared/useMobileNavBarState.ts b/frontend-modern/src/components/shared/useMobileNavBarState.tsnew file mode 100644index 0000000000..3c6f41e48d--- /dev/null+++ b/frontend-modern/src/components/shared/useMobileNavBarState.ts@@ -0,0 +1,84 @@+import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js';+import {+ buildOrderedMobileNavPlatformTabs,+ buildOrderedMobileNavUtilityTabs,+ getMobileNavFadeState,+ type MobileNavBarPlatformTab,+ type MobileNavBarProps,+ type MobileNavBarUtilityTab,+} from './mobileNavBarModel';++export type {+ MobileNavBarPlatformTab,+ MobileNavBarProps,+ MobileNavBarUtilityTab,+} from './mobileNavBarModel';++export function useMobileNavBarState(props: MobileNavBarProps) {+ const [showFade, setShowFade] = createSignal(false);+ const [showLeftFade, setShowLeftFade] = createSignal(false);+ const [navRef, setNavRef] = createSignal<HTMLDivElement>();++ const orderedPlatformTabs = createMemo(() =>+ buildOrderedMobileNavPlatformTabs(props.platformTabs()),+ );+ const orderedUtilityTabs = createMemo(() =>+ buildOrderedMobileNavUtilityTabs(props.utilityTabs()),+ );++ const updateFadeIndicator = () => {+ const fadeState = getMobileNavFadeState(navRef());+ setShowFade(fadeState.showRightFade);+ setShowLeftFade(fadeState.showLeftFade);+ };++ createEffect(() => {+ const nav = navRef();+ if (!nav) return;++ updateFadeIndicator();+ const handleScroll = () => updateFadeIndicator();+ nav.addEventListener('scroll', handleScroll, { passive: true });+ window.addEventListener('resize', handleScroll);+ onCleanup(() => {+ nav.removeEventListener('scroll', handleScroll);+ window.removeEventListener('resize', handleScroll);+ });+ });++ createEffect(() => {+ const nav = navRef();+ if (!nav) return;++ const activeId = props.activeTab();+ if (!activeId) return;++ const activeEl = nav.querySelector<HTMLElement>(`[data-tab-id="${activeId}"]`);+ if (!activeEl) return;++ requestAnimationFrame(() => {+ activeEl.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });+ updateFadeIndicator();+ });+ });++ const handlePlatformClick = (platform: MobileNavBarPlatformTab) => {+ props.onPlatformClick(platform);+ };++ const handleUtilityClick = (tab: MobileNavBarUtilityTab) => {+ props.onUtilityClick(tab);+ };++ return {+ handlePlatformClick,+ handleUtilityClick,+ orderedPlatformTabs,+ orderedUtilityTabs,+ setNavRef,+ showFade,+ showLeftFade,+ };+}++export type MobileNavBarState = ReturnType<typeof useMobileNavBarState>;diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex f84d89bb19..28f9d0e0f4 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -16,6 +16,8 @@ import helpIconSource from '@/components/shared/HelpIcon.tsx?raw';import helpIconModelSource from '@/components/shared/helpIconModel.ts?raw';import historyChartSource from '@/components/shared/HistoryChart.tsx?raw';import historyChartModelSource from '@/components/shared/historyChartModel.ts?raw';+import mobileNavBarSource from '@/components/shared/MobileNavBar.tsx?raw';+import mobileNavBarModelSource from '@/components/shared/mobileNavBarModel.ts?raw';import infrastructureSelectorSource from '@/components/shared/InfrastructureSelector.tsx?raw';import infrastructureSummaryTableSource from '@/components/shared/InfrastructureSummaryTable.tsx?raw';import infrastructureSummaryTableRowSource from '@/components/shared/InfrastructureSummaryTableRow.tsx?raw';@@ -26,6 +28,7 @@ import sharedInfrastructureSummaryTableModelSource from '@/components/shared/infimport containerUpdateButtonStateSource from '@/components/shared/useContainerUpdateButtonState.ts?raw';import helpIconStateSource from '@/components/shared/useHelpIconState.ts?raw';import historyChartStateSource from '@/components/shared/useHistoryChartState.ts?raw';+import mobileNavBarStateSource from '@/components/shared/useMobileNavBarState.ts?raw';import infrastructureSelectorStateSource from '@/components/shared/useInfrastructureSelectorState.ts?raw';import interactiveSparklineStateSource from '@/components/shared/useInteractiveSparklineState.ts?raw';import infrastructureSummaryTableStateSource from '@/components/shared/useInfrastructureSummaryTableState.ts?raw';@@ -2703,6 +2706,19 @@ describe('frontend resource type boundaries', () => {expect(helpIconStateSource).toContain('document.addEventListener');expect(helpIconModelSource).toContain('resolveHelpContent');expect(helpIconModelSource).toContain('calculateHelpPopoverPosition');+ expect(mobileNavBarSource).toContain('useMobileNavBarState');+ expect(mobileNavBarSource).toContain('getMobileNavTabButtonClass');+ expect(mobileNavBarSource).not.toContain('createSignal');+ expect(mobileNavBarSource).not.toContain('requestAnimationFrame');+ expect(mobileNavBarSource).not.toContain('new Set(priority)');+ expect(mobileNavBarStateSource).toContain('createSignal');+ expect(mobileNavBarStateSource).toContain('window.addEventListener');+ expect(mobileNavBarStateSource).toContain('requestAnimationFrame');+ expect(mobileNavBarStateSource).toContain('scrollIntoView');+ expect(mobileNavBarModelSource).toContain('buildOrderedMobileNavPlatformTabs');+ expect(mobileNavBarModelSource).toContain('buildOrderedMobileNavUtilityTabs');+ expect(mobileNavBarModelSource).toContain('getMobileNavAlertBadgeCounts');+ expect(mobileNavBarModelSource).toContain('getMobileNavFadeState');expect(useUnifiedResourcesSource).not.toContain('normalizeResourcePolicyAISafeSummary(');expect(useUnifiedResourcesSource).not.toContain('normalizeResourcePolicy(');expect(useUnifiedResourcesSource).not.toContain('const resolvePolicySensitivity =');