Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Hide overview-only platform section tabs

rcourtmanf1a29681ce9a
diff --git a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.navigation.test.tsx b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.navigation.test.tsx
new file mode 100644
index 0000000000..8e58b0f43b
--- /dev/null
+++ b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.navigation.test.tsx
@@ -0,0 +1,63 @@
+import { cleanup, render, screen, within } from '@solidjs/testing-library';
+import { Route, Router } from '@solidjs/router';
+import { afterEach, describe, expect, it } from 'vitest';
+import { PlatformSectionTabs } from '../sharedPlatformPage';
+
+afterEach(() => {
+ cleanup();
+ window.history.replaceState({}, '', '/');
+});
+
+describe('PlatformSectionTabs', () => {
+ it('hides overview-only section navigation', () => {
+ render(() => (
+ <Router>
+ <Route
+ path="/"
+ component={() => (
+ <PlatformSectionTabs
+ tabs={[{ id: 'overview', label: 'Overview', path: '/agents/overview' }] as const}
+ active="overview"
+ ariaLabel="Agents sections"
+ />
+ )}
+ />
+ </Router>
+ ));
+
+ expect(screen.queryByRole('navigation', { name: 'Agents sections' })).toBeNull();
+ expect(screen.queryByRole('link', { name: 'Overview' })).toBeNull();
+ });
+
+ it('keeps section navigation visible when there are alternate destinations', () => {
+ render(() => (
+ <Router>
+ <Route
+ path="/"
+ component={() => (
+ <PlatformSectionTabs
+ tabs={
+ [
+ { id: 'overview', label: 'Overview', path: '/truenas/overview' },
+ { id: 'storage', label: 'Storage', path: '/truenas/storage' },
+ ] as const
+ }
+ active="storage"
+ ariaLabel="TrueNAS sections"
+ />
+ )}
+ />
+ </Router>
+ ));
+
+ const navigation = screen.getByRole('navigation', { name: 'TrueNAS sections' });
+ expect(within(navigation).getByRole('link', { name: 'Overview' })).toHaveAttribute(
+ 'href',
+ '/truenas/overview',
+ );
+ expect(within(navigation).getByRole('link', { name: 'Storage' })).toHaveAttribute(
+ 'aria-current',
+ 'page',
+ );
+ });
+});
diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
index 56ea781d80..82eaa4a7aa 100644
--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
@@ -27,26 +27,28 @@ export function PlatformSectionTabs<TabId extends string>(props: {
ariaLabel: string;
}) {
return (
- <nav
- class="flex flex-wrap items-center gap-1 border-b border-border"
- aria-label={props.ariaLabel}
- >
- <For each={props.tabs}>
- {(tab) => (
- <A
- href={tab.path}
- class={`inline-flex min-h-10 items-center border-b-2 px-3 text-sm font-medium transition-colors ${
- props.active === tab.id
- ? 'border-blue-500 text-blue-600 dark:text-blue-300'
- : 'border-transparent text-muted hover:border-border hover:text-base-content'
- }`}
- aria-current={props.active === tab.id ? 'page' : undefined}
- >
- {tab.label}
- </A>
- )}
- </For>
- </nav>
+ <Show when={props.tabs.length > 1}>
+ <nav
+ class="flex flex-wrap items-center gap-1 border-b border-border"
+ aria-label={props.ariaLabel}
+ >
+ <For each={props.tabs}>
+ {(tab) => (
+ <A
+ href={tab.path}
+ class={`inline-flex min-h-10 items-center border-b-2 px-3 text-sm font-medium transition-colors ${
+ props.active === tab.id
+ ? 'border-blue-500 text-blue-600 dark:text-blue-300'
+ : 'border-transparent text-muted hover:border-border hover:text-base-content'
+ }`}
+ aria-current={props.active === tab.id ? 'page' : undefined}
+ >
+ {tab.label}
+ </A>
+ )}
+ </For>
+ </nav>
+ </Show>
);
}