mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-28 16:58:31 +01:00
Place Map as leftmost desktop navigation tab
Move the Map link into the leftmost position of the desktop primary navigation bar (lg and above) inside its own Overview group with a subtle vertical divider before the detected platform tabs. Keep the compact Map button in the top-left header slot below lg (where MobileNavBar takes over) so mobile bottom navigation stays uncluttered and single-platform installs keep one-tap switching. Leave the default / landing route and feature release gating unchanged, and tighten lg-only horizontal tab padding so a 12-tab bar fits cleanly at 1024px. Contract-Neutral: Navigation layout and placement update in AppLayout and InfrastructureMapEntry only, with no API, schema, cloud-paid, AI runtime, or unified resource contract changes.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
49
frontend-modern/browser-verification/fea9dae9d836d477.json
Normal file
49
frontend-modern/browser-verification/fea9dae9d836d477.json
Normal file
@@ -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)"
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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) {
|
||||
>
|
||||
<Show when={!kioskMode()}>
|
||||
<div class="flex items-center sm:col-start-1 sm:col-end-2 sm:justify-self-start">
|
||||
{/* 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. */}
|
||||
<Show when={isFeatureAvailable('infrastructureMap')}>
|
||||
<InfrastructureMapHeaderButton />
|
||||
<div class="lg:hidden">
|
||||
<InfrastructureMapHeaderButton />
|
||||
</div>
|
||||
</Show>
|
||||
</div>
|
||||
<div class="flex items-center gap-1.5 sm:col-start-2 sm:col-end-3 sm:flex-initial sm:justify-self-center sm:gap-2">
|
||||
@@ -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"
|
||||
>
|
||||
<Show when={isFeatureAvailable('infrastructureMap')}>
|
||||
<div class="flex items-end gap-0.5 xl:gap-1" role="group" aria-label="Overview">
|
||||
<InfrastructureMapNavTab />
|
||||
</div>
|
||||
<Show when={primaryTabs().length > 0}>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
data-testid="infrastructure-map-nav-divider"
|
||||
class="mb-1.5 h-4 w-px shrink-0 bg-border/80 xl:mx-0.5"
|
||||
/>
|
||||
</Show>
|
||||
</Show>
|
||||
<div class="flex items-end gap-0.5 xl:gap-1" role="group" aria-label="Infrastructure">
|
||||
<For each={primaryTabs()}>{renderPrimaryNavigationTab}</For>
|
||||
</div>
|
||||
<div class="flex items-end gap-0.5 xl:gap-1 ml-auto" role="group" aria-label="System">
|
||||
<div class="flex items-end gap-0.5 xl:gap-1 pl-2 xl:pl-4">
|
||||
<div class="flex items-end gap-0.5 xl:gap-1 pl-1 xl:pl-4">
|
||||
<For each={utilityTabs()}>
|
||||
{(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()) {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<A
|
||||
href={INFRASTRUCTURE_MAP_PATH}
|
||||
class={`${DESKTOP_TAB_BASE_CLASSES} ${
|
||||
isOpen()
|
||||
? 'bg-surface text-blue-600 dark:text-blue-400 border-border border-b border-b-surface shadow-xs font-semibold'
|
||||
: 'text-muted hover:text-base-content hover:bg-surface-hover'
|
||||
}`}
|
||||
aria-current={isOpen() ? 'page' : undefined}
|
||||
title="Map of everything Pulse monitors"
|
||||
onMouseEnter={warm}
|
||||
onFocus={warm}
|
||||
data-testid="infrastructure-map-nav-tab"
|
||||
>
|
||||
<MapIcon class="w-4 h-4 shrink-0" aria-hidden="true" />
|
||||
<span>Map</span>
|
||||
</A>
|
||||
);
|
||||
}
|
||||
|
||||
export function InfrastructureMapHeaderButton() {
|
||||
const isOpen = useMapIsOpen();
|
||||
return (
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user