diff --git a/docs/MAP.md b/docs/MAP.md index 426c6be28d..0af51c90cc 100644 --- a/docs/MAP.md +++ b/docs/MAP.md @@ -4,7 +4,7 @@ The map draws everything Pulse monitors on one screen: how traffic gets in, what runs, and the storage, backups and hardware underneath. It draws itself from what Pulse already collects. There is nothing to place by hand. -Open it with the map button at the top left of the header. +Open it from the **Map** tab on the left of the navigation bar (or the **Map** button at the top left of the header on narrower screens). ## Read the map diff --git a/frontend-modern/browser-verification/fea9dae9d836d477.json b/frontend-modern/browser-verification/fea9dae9d836d477.json new file mode 100644 index 0000000000..2913ed521b --- /dev/null +++ b/frontend-modern/browser-verification/fea9dae9d836d477.json @@ -0,0 +1,49 @@ +{ + "version": 1, + "base_sha": "39902fbe8d234d32620616f806b79d154e0d6445", + "verified_at": "2026-11-28T00:06:53Z", + "result": "passed", + "changed_paths": [ + "frontend-modern/src/AppLayout.tsx", + "frontend-modern/src/features/infrastructureMap/InfrastructureMapEntry.tsx" + ], + "content_sha256": { + "frontend-modern/src/AppLayout.tsx": "814ea8f02834fc4274f070cfb55da1a322331942711ce78cb3f96633512b5f80", + "frontend-modern/src/features/infrastructureMap/InfrastructureMapEntry.tsx": "6a0fa88676900e32b72b1a3bf37a2cb7d6dce56b9a687f7ad8c095027cbd88ce" + }, + "routes": [ + "/map", + "/proxmox/overview" + ], + "viewports": [ + { + "width": 1280, + "height": 800 + }, + { + "width": 1024, + "height": 768 + }, + { + "width": 1023, + "height": 768 + }, + { + "width": 390, + "height": 844 + } + ], + "states": [ + "Desktop 1280x800 dark and light with all 7 platforms plus Patrol and Map tab active before Proxmox", + "Desktop 1024x768 dark crowded 12-tab bar with zero horizontal overflow and Settings fully visible", + "Desktop 1280x800 dark empty estate with Map tab visible and no trailing divider", + "Narrow 1023x768 dark and mobile 390x844 dark and light with top-left Map header button visible and bottom MobileNavBar excluding Map", + "Kiosk mode (?kiosk=true) hiding both Map tab and header button", + "Held-back production build omitting both Map entries, divider, and /map links" + ], + "interactions": [ + "Clicked Proxmox tab from /map and clicked Map desktop tab back to /map, verifying aria-current toggles cleanly", + "Clicked top-left Map header button at 1023x768 and 390x844 from /proxmox/overview to /map, verifying active state and zero page errors", + "Verified lg breakpoint handoff between 1024px (desktop tab only) and 1023px (header button plus MobileNavBar only)" + ] +} diff --git a/frontend-modern/public/docs/MAP.md b/frontend-modern/public/docs/MAP.md index 426c6be28d..0af51c90cc 100644 --- a/frontend-modern/public/docs/MAP.md +++ b/frontend-modern/public/docs/MAP.md @@ -4,7 +4,7 @@ The map draws everything Pulse monitors on one screen: how traffic gets in, what runs, and the storage, backups and hardware underneath. It draws itself from what Pulse already collects. There is nothing to place by hand. -Open it with the map button at the top left of the header. +Open it from the **Map** tab on the left of the navigation bar (or the **Map** button at the top left of the header on narrower screens). ## Read the map diff --git a/frontend-modern/src/AppLayout.tsx b/frontend-modern/src/AppLayout.tsx index 16894ce168..35bf6af9ca 100644 --- a/frontend-modern/src/AppLayout.tsx +++ b/frontend-modern/src/AppLayout.tsx @@ -75,7 +75,10 @@ import { runtimeBranding } from '@/stores/systemSettings'; import { presentationPolicyHidesUpgradePrompts } from '@/stores/sessionPresentationPolicy'; import type { AppConnectionStatus, OrganizationListIssue } from '@/useAppRuntimeState'; import { buildInfrastructureWorkspacePath } from '@/components/Settings/infrastructureWorkspaceModel'; -import { InfrastructureMapHeaderButton } from '@/features/infrastructureMap/InfrastructureMapEntry'; +import { + InfrastructureMapHeaderButton, + InfrastructureMapNavTab, +} from '@/features/infrastructureMap/InfrastructureMapEntry'; import { PreviewTag } from '@/components/FeatureRelease'; import { isFeatureAvailable } from '@/utils/featureReleases'; @@ -356,7 +359,8 @@ export function AppLayout(props: AppLayoutProps) { createEffect(() => { const active = getNavigationActiveTab(); if (!active) { - // The map is reached from the window edge, not from a tab. + // Map stays outside the platform/utility tab enum so it remains + // independent of platform visibility and mobile bottom tabs. const onMap = isFeatureAvailable('infrastructureMap') && location.pathname.replace(/\/+$/, '') === INFRASTRUCTURE_MAP_PATH; @@ -719,7 +723,7 @@ export function AppLayout(props: AppLayoutProps) { const targetRoute = () => getPrimaryTargetRoute(tab); const Icon = tab.icon; const baseClasses = - 'tab relative px-1.5 xl:px-2 2xl:px-3 py-1.5 text-xs xl:text-sm font-medium flex items-center gap-1 2xl:gap-1.5 rounded-t border border-transparent transition-colors whitespace-nowrap cursor-pointer select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-blue-500'; + 'tab relative px-1 xl:px-2 2xl:px-3 py-1.5 text-xs xl:text-sm font-medium flex items-center gap-1 2xl:gap-1.5 rounded-t border border-transparent transition-colors whitespace-nowrap cursor-pointer select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-blue-500'; const className = () => { if (isActive()) { @@ -819,9 +823,13 @@ export function AppLayout(props: AppLayoutProps) { >
- {/* The slot stays, so the brand mark does not move when the map arrives. */} + {/* The slot stays so the brand mark remains centered across viewports. + Desktop (`lg`+) surfaces Map in the primary tab bar, while narrower screens + keep the header button so mobile bottom nav stays uncluttered. */} - +
+ +
@@ -950,17 +958,29 @@ export function AppLayout(props: AppLayoutProps) { class="tabs mb-2 hidden lg:flex items-end gap-1 xl:gap-2 overflow-x-auto whitespace-nowrap border-b border-border scrollbar-hide" aria-label="Primary navigation" > + +
+ +
+ 0}> + +
{renderPrimaryNavigationTab}
-
+
{(tab) => { const isActive = () => getActiveTabDesktop() === tab.id; const Icon = tab.icon; const baseClasses = - 'tab relative px-1.5 xl:px-2 2xl:px-3 py-1.5 text-xs xl:text-sm font-medium flex items-center gap-1 2xl:gap-1.5 rounded-t border border-transparent transition-colors whitespace-nowrap cursor-pointer select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-blue-500'; + 'tab relative px-1 xl:px-2 2xl:px-3 py-1.5 text-xs xl:text-sm font-medium flex items-center gap-1 2xl:gap-1.5 rounded-t border border-transparent transition-colors whitespace-nowrap cursor-pointer select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-blue-500'; const className = () => { if (isActive()) { diff --git a/frontend-modern/src/__tests__/AppLayout.test.tsx b/frontend-modern/src/__tests__/AppLayout.test.tsx index 618aaddce2..066641674c 100644 --- a/frontend-modern/src/__tests__/AppLayout.test.tsx +++ b/frontend-modern/src/__tests__/AppLayout.test.tsx @@ -740,45 +740,80 @@ describe('AppLayout map entry', () => { window.sessionStorage.clear(); }); - it('offers one labeled map button in the top-left header slot, not on the edge or among the tabs', () => { - renderLayout([], '/settings/infrastructure'); + it('places Map as the leftmost desktop tab before platform tabs and keeps the header button only below lg', () => { + renderLayout( + [makeResource({ id: 'pve-node-1', type: 'agent', platformType: 'proxmox-pve' })], + '/proxmox/overview', + ); expect(screen.queryByTestId('infrastructure-map-edge-tab')).toBeNull(); + const tabs = screen.getByRole('navigation', { name: 'Primary navigation' }); + const navTab = within(tabs).getByTestId('infrastructure-map-nav-tab'); + const proxmoxTab = within(tabs).getByRole('link', { name: 'Proxmox' }); + expect(navTab).toHaveAttribute('href', '/map'); + expect(navTab).toHaveAccessibleName('Map'); + expect(navTab).toHaveTextContent('Map'); + expect(navTab).not.toHaveAttribute('aria-current'); + expect( + Boolean(navTab.compareDocumentPosition(proxmoxTab) & Node.DOCUMENT_POSITION_FOLLOWING), + ).toBe(true); + expect(within(tabs).getByTestId('infrastructure-map-nav-divider')).toBeInTheDocument(); + const button = screen.getByTestId('infrastructure-map-header-button'); expect(button).toHaveAttribute('href', '/map'); expect(button).toHaveAccessibleName('Map'); expect(button).toHaveTextContent('Map'); expect(button).not.toHaveAttribute('aria-current'); expect(button.closest('.header-controls')).toBeNull(); + expect(button.parentElement).toHaveClass('lg:hidden'); const brand = screen.getByTestId('pulse-brand-lockup'); expect(Boolean(button.compareDocumentPosition(brand) & Node.DOCUMENT_POSITION_FOLLOWING)).toBe( true, ); - const tabs = screen.getByRole('navigation', { name: 'Primary navigation' }); - expect(within(tabs).queryByRole('link', { name: 'Map' })).toBeNull(); + const mobileNav = screen.getByRole('navigation', { name: 'Mobile navigation' }); + expect(within(mobileNav).queryByRole('link', { name: 'Map' })).toBeNull(); }); - it('marks the header map button as the current page when on /map and preloads on hover/focus', () => { - preloadRouteModuleMock.mockReset(); - preloadRouteModuleMock.mockResolvedValue(undefined); + it('still renders the desktop Map tab without a trailing divider when no platform tabs are visible', () => { + renderLayout([], '/settings/infrastructure'); + + const tabs = screen.getByRole('navigation', { name: 'Primary navigation' }); + const navTab = within(tabs).getByTestId('infrastructure-map-nav-tab'); + expect(navTab).toHaveAttribute('href', '/map'); + expect(within(tabs).queryByTestId('infrastructure-map-nav-divider')).toBeNull(); + }); + + it('marks both desktop Map tab and narrow header button as the current page on /map and preloads on hover/focus', () => { renderLayout([], '/map'); + const navTab = screen.getByTestId('infrastructure-map-nav-tab'); const button = screen.getByTestId('infrastructure-map-header-button'); + expect(navTab).toHaveAttribute('aria-current', 'page'); expect(button).toHaveAttribute('aria-current', 'page'); - fireEvent.mouseEnter(button); - fireEvent.focus(button); - expect(preloadRouteModuleMock).toHaveBeenCalledWith('/map'); + for (const trigger of [ + () => fireEvent.mouseEnter(navTab), + () => fireEvent.focus(navTab), + () => fireEvent.mouseEnter(button), + () => fireEvent.focus(button), + ]) { + preloadRouteModuleMock.mockReset(); + preloadRouteModuleMock.mockResolvedValue(undefined); + trigger(); + expect(preloadRouteModuleMock).toHaveBeenCalledTimes(1); + expect(preloadRouteModuleMock).toHaveBeenCalledWith('/map'); + } }); - it('hides the map entry with the rest of the navigation in kiosk mode', () => { + it('hides both map entries with the rest of the navigation in kiosk mode', () => { setKioskMode(true); renderLayout([], '/settings/infrastructure'); expect(screen.queryByTestId('infrastructure-map-edge-tab')).toBeNull(); + expect(screen.queryByTestId('infrastructure-map-nav-tab')).toBeNull(); expect(screen.queryByTestId('infrastructure-map-header-button')).toBeNull(); }); diff --git a/frontend-modern/src/features/infrastructureMap/InfrastructureMapEntry.tsx b/frontend-modern/src/features/infrastructureMap/InfrastructureMapEntry.tsx index 9634ff6ce0..7d1d350cc0 100644 --- a/frontend-modern/src/features/infrastructureMap/InfrastructureMapEntry.tsx +++ b/frontend-modern/src/features/infrastructureMap/InfrastructureMapEntry.tsx @@ -4,9 +4,12 @@ import { INFRASTRUCTURE_MAP_PATH } from '@/routing/resourceLinks'; import { preloadRouteModule } from '@/routing/routePreload'; /** - * The way into the map. It is not a platform tab, because the map is every - * platform at once: it sits in the top-left header slot across all viewports, - * beside the centered brand mark rather than mixed into individual platform tabs. + * The way into the map. On desktop (`lg` and above) it sits at the leftmost + * position of the primary navigation bar so whole-estate overview leads into + * individual platforms. On narrower screens (`< lg`, where bottom navigation + * takes over) it stays as a compact button in the top-left header slot so it + * remains one tap away without crowding the mobile bottom bar or turning a + * single-platform install into a two-item switcher. */ const warm = () => void preloadRouteModule(INFRASTRUCTURE_MAP_PATH).catch(() => undefined); @@ -16,6 +19,31 @@ const useMapIsOpen = () => { return () => location.pathname.replace(/\/+$/, '') === INFRASTRUCTURE_MAP_PATH; }; +const DESKTOP_TAB_BASE_CLASSES = + 'tab relative px-1 xl:px-2 2xl:px-3 py-1.5 text-xs xl:text-sm font-medium flex items-center gap-1 2xl:gap-1.5 rounded-t border border-transparent transition-colors whitespace-nowrap cursor-pointer select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-blue-500'; + +export function InfrastructureMapNavTab() { + const isOpen = useMapIsOpen(); + return ( + + + ); +} + export function InfrastructureMapHeaderButton() { const isOpen = useMapIsOpen(); return ( diff --git a/tests/integration/tests/71-infrastructure-map.spec.ts b/tests/integration/tests/71-infrastructure-map.spec.ts index d96582515a..b5b7db72ef 100644 --- a/tests/integration/tests/71-infrastructure-map.spec.ts +++ b/tests/integration/tests/71-infrastructure-map.spec.ts @@ -40,9 +40,21 @@ const MAP_STAGE = featureReleases.infrastructureMap?.stage; const MAP = 'svg[aria-label="Infrastructure map"]'; const TILE = `${MAP} [data-map-hit]`; +const NAV_TAB = "infrastructure-map-nav-tab"; const HEADER_BUTTON = "infrastructure-map-header-button"; +const DESKTOP_NAV_BREAKPOINT = 1024; const FOCUS_RING = "rgb(59, 130, 246)"; +const mapEntryForViewport = (page: Page) => { + const isDesktopNav = + (page.viewportSize()?.width ?? DESKTOP_NAV_BREAKPOINT) >= + DESKTOP_NAV_BREAKPOINT; + return { + visibleEntry: page.getByTestId(isDesktopNav ? NAV_TAB : HEADER_BUTTON), + hiddenEntry: page.getByTestId(isDesktopNav ? HEADER_BUTTON : NAV_TAB), + }; +}; + type WorkerFixtures = { authStorageStatePath: string; }; @@ -140,7 +152,9 @@ test.describe("Infrastructure map", () => { await openMap(page); const heading = page.getByRole("heading", { level: 1, name: "Map" }); await expect(heading).toBeVisible(); - await expect(page.getByTestId(HEADER_BUTTON)).toBeVisible(); + const { visibleEntry, hiddenEntry } = mapEntryForViewport(page); + await expect(visibleEntry).toBeVisible(); + await expect(hiddenEntry).toBeHidden(); // A feature in preview says so beside its title. const tag = page .locator('[data-testid="infrastructure-map"] [data-page-header]') @@ -158,6 +172,7 @@ test.describe("Infrastructure map", () => { ).toBeVisible({ timeout: 60_000 }); await expect(page.locator(MAP)).toHaveCount(0); await expect(page).not.toHaveTitle(/^Map\b/); + await expect(page.getByTestId(NAV_TAB)).toHaveCount(0); await expect(page.getByTestId(HEADER_BUTTON)).toHaveCount(0); await expect(page.locator('a[href="/map"]')).toHaveCount(0); @@ -175,15 +190,16 @@ test.describe("Infrastructure map", () => { await expect(page.locator('a[href*="/docs/MAP"]')).toHaveCount(0); }); - test("a development build reaches the map from the header and draws the estate", async ({ + test("a development build reaches the map from the navigation and draws the estate", async ({ page, }, testInfo) => { await asDevelopmentBuild(page); await page.goto("/proxmox/overview", { waitUntil: "domcontentloaded" }); - const button = page.getByTestId(HEADER_BUTTON); - await expect(button).toBeVisible({ timeout: 60_000 }); - await button.click(); + const { visibleEntry, hiddenEntry } = mapEntryForViewport(page); + await expect(visibleEntry).toBeVisible({ timeout: 60_000 }); + await expect(hiddenEntry).toBeHidden(); + await visibleEntry.click(); await expect(page).toHaveURL(/\/map$/); await expect(page.locator(TILE).first()).toBeVisible({ timeout: 60_000 }); await expect(