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
Align alerts demo shell with read-only policy
rcourtman0b9801710f0f
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.mdindex 5ac6a1090f..d3e57ecf63 100644--- a/docs/release-control/v6/internal/subsystems/alerts.md+++ b/docs/release-control/v6/internal/subsystems/alerts.md@@ -129,6 +129,12 @@ upgrade/trial posture must come from the dedicated commercial-posturecontract, and public-demo suppression must flow from the shared resolved`presentationPolicy` contract instead of alert-local demo checks orentitlement reads.+That same shared read-only presentation contract now also owns the public-demo+alerts shell posture. When `presentationPolicy.readOnly` is true, the alerts+page must behave as a reporting surface: overview/history remain available,+alert activation controls stay hidden, configuration tabs must not render or+remain navigable, and the overview empty state must not tell public demo users+to toggle alerting back on when demo mode already blocks write requests.That shared alert presentation boundary now also has explicit alerts ownership.`frontend-modern/src/utils/alertWebhookPresentation.ts` is the canonical ownerfor webhook setup copy, service labels, mention-help phrasing, custom-fielddiff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 5f05dca3e4..43747c9d3b 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -175,6 +175,10 @@ work extends shared components instead of creating new local variants.session presentation policy says the operator cannot manage setup, `/settings`and sidebar navigation must land on the canonical reporting/control surfaceinstead of setup-oriented install routes.+ That same shared session-presentation boundary also owns alerts read-only+ posture: `/alerts` may continue exposing reporting tabs such as overview and+ history, but activation controls plus configuration routes must collapse out+ of the public-demo shell instead of advertising blocked management actions.3. Add feature-specific presentation only when no shared primitive should own it4. Add guardrail tests when a new shared pattern is introduced5. Keep shared platform-connections shell state on the reusable settings boundary: `frontend-modern/src/components/Settings/useSettingsInfrastructurePanelProps.ts`, `frontend-modern/src/components/Settings/InfrastructurePlatformConnectionsSummaryCard.tsx`, and `frontend-modern/src/components/Settings/PlatformConnectionsWorkspace.tsx` must continue to derive provider counts, availability, and shared subtab copy from one infrastructure-settings source instead of creating provider-local summary fetches or VMware-only shell vocabulary.diff --git a/frontend-modern/src/pages/Alerts.tsx b/frontend-modern/src/pages/Alerts.tsxindex 3c4715890e..581af1a969 100644--- a/frontend-modern/src/pages/Alerts.tsx+++ b/frontend-modern/src/pages/Alerts.tsx@@ -32,6 +32,7 @@ import {getAlertsMobileTabClass,getAlertsSidebarTabClass,getAlertsTabTitle,+ isAlertsConfigurationTab,} from '@/utils/alertTabsPresentation';import {getAlertsPageHeaderMeta,@@ -44,6 +45,7 @@ import LayoutDashboard from 'lucide-solid/icons/layout-dashboard';import History from 'lucide-solid/icons/history';import Gauge from 'lucide-solid/icons/gauge';import Send from 'lucide-solid/icons/send';+import { presentationPolicyIsReadOnly } from '@/stores/sessionPresentationPolicy';import { AlertsConfigurationSurface } from '@/features/alerts/AlertsConfigurationSurface';import { OverviewTab } from '@/features/alerts/OverviewTab';import { HistoryTab } from '@/features/alerts/tabs/HistoryTab';@@ -61,8 +63,12 @@ export function Alerts() {const location = useLocation();const alertsActivation = useAlertsActivation();const [isSwitchingActivation, setIsSwitchingActivation] = createSignal(false);+ const readOnlySession = createMemo(() => presentationPolicyIsReadOnly());const isAlertsActive = createMemo(() => alertsActivation.activationState() === 'active');const areAlertsDisabled = createMemo(() => !isAlertsActive());+ const alertsConfigurationLocked = createMemo(+ () => !readOnlySession() && areAlertsDisabled(),+ );const alertActivationPresentation = createMemo(() =>getAlertActivationPresentation({isActive: isAlertsActive(),@@ -126,7 +132,9 @@ export function Alerts() {createEffect(() => {const currentPath = location.pathname;- const tab = tabFromPath(currentPath);+ const requestedTab = tabFromPath(currentPath);+ const tab =+ readOnlySession() && isAlertsConfigurationTab(requestedTab) ? 'overview' : requestedTab;if (tab !== activeTab()) {setActiveTab(tab);@@ -145,7 +153,7 @@ export function Alerts() {createEffect(() => {const activation = alertsActivation.activationState();- if (activation === null) {+ if (activation === null || readOnlySession()) {return;}if (activation !== 'active' && activeTab() !== 'overview') {@@ -212,30 +220,34 @@ export function Alerts() {}});- const tabGroups = getAlertsTabGroups().map((group) => ({- ...group,- items: group.items.map((item) => ({- ...item,- icon:- item.id === 'overview' ? (- <LayoutDashboard class="w-4 h-4" strokeWidth={2} />- ) : item.id === 'history' ? (- <History class="w-4 h-4" strokeWidth={2} />- ) : item.id === 'thresholds' ? (- <Gauge class="w-4 h-4" strokeWidth={2} />- ) : item.id === 'destinations' ? (- <Send class="w-4 h-4" strokeWidth={2} />- ) : (- <Calendar class="w-4 h-4" strokeWidth={2} />- ),+ const tabGroups = createMemo<+ {+ id: 'status' | 'configuration';+ label: string;+ items: { id: AlertTab; label: string; icon: JSX.Element }[];+ }[]+ >(() =>+ getAlertsTabGroups({ readOnly: readOnlySession() }).map((group) => ({+ ...group,+ items: group.items.map((item) => ({+ ...item,+ icon:+ item.id === 'overview' ? (+ <LayoutDashboard class="w-4 h-4" strokeWidth={2} />+ ) : item.id === 'history' ? (+ <History class="w-4 h-4" strokeWidth={2} />+ ) : item.id === 'thresholds' ? (+ <Gauge class="w-4 h-4" strokeWidth={2} />+ ) : item.id === 'destinations' ? (+ <Send class="w-4 h-4" strokeWidth={2} />+ ) : (+ <Calendar class="w-4 h-4" strokeWidth={2} />+ ),+ })),})),- })) satisfies {- id: 'status' | 'configuration';- label: string;- items: { id: AlertTab; label: string; icon: JSX.Element }[];- }[];+ );- const flatTabs = tabGroups.flatMap((group) => group.items);+ const flatTabs = createMemo(() => tabGroups().flatMap((group) => group.items));// Sidebar always starts expanded for discoverability (consistent with Settings)// Users can collapse during session but it resets on page reloadconst [sidebarCollapsed, setSidebarCollapsed] = createSignal(false);@@ -250,7 +262,7 @@ export function Alerts() {description={headerMeta().description}size="lg"/>- <Show when={activeTab() === 'overview'}>+ <Show when={activeTab() === 'overview' && !readOnlySession()}><div class="flex items-center gap-3"><span class={`text-sm font-medium ${alertActivationPresentation().labelClass}`}>{alertActivationPresentation().label}@@ -332,7 +344,7 @@ export function Alerts() {</button></Show><div id="alerts-sidebar-menu" class="space-y-5">- <For each={tabGroups}>+ <For each={tabGroups()}>{(group) => (<div class="space-y-2"><Show when={!sidebarCollapsed()}>@@ -346,16 +358,16 @@ export function Alerts() {<buttontype="button"aria-current={activeTab() === item.id ? 'page' : undefined}- aria-disabled={areAlertsDisabled()}- disabled={areAlertsDisabled()}+ aria-disabled={alertsConfigurationLocked()}+ disabled={alertsConfigurationLocked()}class={getAlertsSidebarTabClass({isActive: activeTab() === item.id,- isDisabled: areAlertsDisabled(),+ isDisabled: alertsConfigurationLocked(),collapsed: sidebarCollapsed(),})}onClick={() => handleTabChange(item.id)}title={getAlertsTabTitle({- isDisabled: areAlertsDisabled(),+ isDisabled: alertsConfigurationLocked(),collapsed: sidebarCollapsed(),label: item.label,})}@@ -376,26 +388,26 @@ export function Alerts() {</div><div class="flex-1 overflow-hidden">- <Show when={flatTabs.length > 0}>+ <Show when={flatTabs().length > 0}><div class="lg:hidden border-b border-border"><div class="p-1"><divclass="flex rounded-md bg-surface-hover p-0.5 w-full overflow-x-auto"style="-webkit-overflow-scrolling: touch;">- <For each={flatTabs}>+ <For each={flatTabs()}>{(tab) => (<buttontype="button"- aria-disabled={areAlertsDisabled()}- disabled={areAlertsDisabled()}+ aria-disabled={alertsConfigurationLocked()}+ disabled={alertsConfigurationLocked()}class={getAlertsMobileTabClass({isActive: activeTab() === tab.id,- isDisabled: areAlertsDisabled(),+ isDisabled: alertsConfigurationLocked(),})}onClick={() => handleTabChange(tab.id)}title={getAlertsTabTitle({- isDisabled: areAlertsDisabled(),+ isDisabled: alertsConfigurationLocked(),label: tab.label,})}>@@ -419,25 +431,27 @@ export function Alerts() {dismissQuickTip={dismissQuickTip}showAcknowledged={showAcknowledged}setShowAcknowledged={setShowAcknowledged}- alertsDisabled={areAlertsDisabled}+ alertsDisabled={alertsConfigurationLocked}hasAIAlertsFeature={hasAIAlertsFeature}runtimeCapabilitiesLoading={runtimeCapabilitiesLoading}/></Show>- <AlertsConfigurationSurface- activeTab={activeTab}- allResources={allResources}- byType={byType}- children={children}- activeAlerts={activeAlerts}- removeAlerts={removeAlerts}- setOverviewOverrides={setOverviewOverrides}- hasUnsavedChanges={hasUnsavedChanges}- setHasUnsavedChanges={setHasUnsavedChanges}- alertsActivationState={alertsActivation.activationState}- alertsActivationConfig={alertsActivation.config}- />+ <Show when={!readOnlySession()}>+ <AlertsConfigurationSurface+ activeTab={activeTab}+ allResources={allResources}+ byType={byType}+ children={children}+ activeAlerts={activeAlerts}+ removeAlerts={removeAlerts}+ setOverviewOverrides={setOverviewOverrides}+ hasUnsavedChanges={hasUnsavedChanges}+ setHasUnsavedChanges={setHasUnsavedChanges}+ alertsActivationState={alertsActivation.activationState}+ alertsActivationConfig={alertsActivation.config}+ />+ </Show><Show when={activeTab() === 'history'}><HistoryTabdiff --git a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.tsindex ed942e0d61..0552f4736a 100644--- a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts+++ b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts@@ -220,9 +220,13 @@ describe('tab path helpers', () => {expect(alertsPageSource).toContain("import { AlertsConfigurationSurface } from '@/features/alerts/AlertsConfigurationSurface';",);+ expect(alertsPageSource).toContain(+ "import { presentationPolicyIsReadOnly } from '@/stores/sessionPresentationPolicy';",+ );expect(alertsPageSource).toContain("import { HistoryTab } from '@/features/alerts/tabs/HistoryTab';",);+ expect(alertsPageSource).toContain('getAlertsTabGroups({ readOnly: readOnlySession() })');expect(alertsPageSource).not.toContain('const loadAlertConfiguration = async');expect(alertsPageSource).not.toContain('const FACTORY_GUEST_DEFAULTS =');expect(alertsConfigurationSurfaceSource).toContain(diff --git a/frontend-modern/src/pages/__tests__/Alerts.readOnly.test.tsx b/frontend-modern/src/pages/__tests__/Alerts.readOnly.test.tsxnew file mode 100644index 0000000000..863a3d7977--- /dev/null+++ b/frontend-modern/src/pages/__tests__/Alerts.readOnly.test.tsx@@ -0,0 +1,169 @@+import { cleanup, render, screen, waitFor } from '@solidjs/testing-library';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { Alerts } from '@/pages/Alerts';++const navigateSpy = vi.hoisted(() => vi.fn());+const presentationPolicyIsReadOnlyMock = vi.hoisted(() => vi.fn(() => false));+const activationStateMock = vi.hoisted(() => vi.fn(() => 'active'));+const locationState = vi.hoisted(() => ({+ pathname: '/alerts',+ hash: '',+ search: '',+ query: {},+}));+const overviewTabSpy = vi.hoisted(() =>+ vi.fn((props: { alertsDisabled: () => boolean }) => (+ <div data-testid="overview-tab">{props.alertsDisabled() ? 'disabled' : 'enabled'}</div>+ )),+);+const historyTabSpy = vi.hoisted(() => vi.fn(() => <div data-testid="history-tab">History</div>));+const configurationSurfaceSpy = vi.hoisted(() =>+ vi.fn(() => <div data-testid="alerts-config-surface">Config</div>),+);++vi.mock('@solidjs/router', async () => {+ const actual = await vi.importActual<typeof import('@solidjs/router')>('@solidjs/router');+ return {+ ...actual,+ useLocation: () => locationState,+ useNavigate: () => navigateSpy,+ useBeforeLeave: () => undefined,+ };+});++vi.mock('@/contexts/appRuntime', () => ({+ useWebSocket: () => ({+ activeAlerts: {},+ updateAlert: vi.fn(),+ removeAlerts: vi.fn(),+ }),+}));++vi.mock('@/hooks/useResources', () => ({+ useResources: () => ({+ get: vi.fn(),+ resources: () => [],+ byType: () => [],+ children: () => [],+ }),+}));++vi.mock('@/stores/license', () => ({+ hasFeature: () => true,+ runtimeCapabilitiesLoaded: () => true,+ runtimeCapabilitiesLoading: () => false,+ loadRuntimeCapabilities: vi.fn(async () => undefined),+}));++vi.mock('@/stores/notifications', () => ({+ notificationStore: { success: vi.fn(), error: vi.fn() },+}));++vi.mock('@/stores/aiChat', () => ({+ aiChatStore: { enabled: false },+}));++vi.mock('@/stores/alertsActivation', () => ({+ useAlertsActivation: () => ({+ activationState: () => activationStateMock(),+ isLoading: () => false,+ activate: vi.fn(async () => true),+ deactivate: vi.fn(async () => true),+ refreshActiveAlerts: vi.fn(async () => undefined),+ refreshConfig: vi.fn(async () => undefined),+ config: () => null,+ }),+}));++vi.mock('@/stores/sessionPresentationPolicy', () => ({+ presentationPolicyIsReadOnly: () => presentationPolicyIsReadOnlyMock(),+}));++vi.mock('@/utils/logger', () => ({+ logger: { error: vi.fn() },+}));++vi.mock('@/utils/upgradeMetrics', () => ({+ trackPaywallViewed: vi.fn(),+}));++vi.mock('@/features/alerts/OverviewTab', () => ({+ OverviewTab: overviewTabSpy,+}));++vi.mock('@/features/alerts/tabs/HistoryTab', () => ({+ HistoryTab: historyTabSpy,+}));++vi.mock('@/features/alerts/AlertsConfigurationSurface', () => ({+ AlertsConfigurationSurface: configurationSurfaceSpy,+}));++describe('Alerts read-only presentation', () => {+ beforeEach(() => {+ cleanup();+ navigateSpy.mockReset();+ presentationPolicyIsReadOnlyMock.mockReset();+ presentationPolicyIsReadOnlyMock.mockReturnValue(false);+ activationStateMock.mockReset();+ activationStateMock.mockReturnValue('active');+ overviewTabSpy.mockClear();+ historyTabSpy.mockClear();+ configurationSurfaceSpy.mockClear();+ locationState.pathname = '/alerts';+ locationState.hash = '';+ locationState.search = '';+ });++ afterEach(() => cleanup());++ it('hides alerts management affordances in read-only sessions', async () => {+ presentationPolicyIsReadOnlyMock.mockReturnValue(true);+ activationStateMock.mockReturnValue('pending_review');++ render(() => <Alerts />);++ await waitFor(() => {+ expect(screen.getByTestId('overview-tab')).toBeInTheDocument();+ });++ expect(screen.queryByLabelText('Toggle alerts')).not.toBeInTheDocument();+ expect(screen.getAllByText('Overview').length).toBeGreaterThan(0);+ expect(screen.getAllByText('History').length).toBeGreaterThan(0);+ expect(screen.queryByText('Thresholds')).not.toBeInTheDocument();+ expect(screen.queryByText('Notifications')).not.toBeInTheDocument();+ expect(screen.queryByText('Schedule')).not.toBeInTheDocument();+ expect(screen.queryByTestId('alerts-config-surface')).not.toBeInTheDocument();+ expect(overviewTabSpy).toHaveBeenCalled();+ expect(overviewTabSpy.mock.calls.at(-1)?.[0].alertsDisabled()).toBe(false);+ });++ it('redirects read-only configuration routes back to overview', async () => {+ presentationPolicyIsReadOnlyMock.mockReturnValue(true);+ activationStateMock.mockReturnValue('pending_review');+ locationState.pathname = '/alerts/thresholds';++ render(() => <Alerts />);++ await waitFor(() => {+ expect(navigateSpy).toHaveBeenCalledWith('/alerts/overview', { replace: true });+ });+ expect(screen.queryByTestId('alerts-config-surface')).not.toBeInTheDocument();+ });++ it('keeps configuration surfaces available in writable sessions', async () => {+ presentationPolicyIsReadOnlyMock.mockReturnValue(false);+ activationStateMock.mockReturnValue('active');+ locationState.pathname = '/alerts/thresholds';++ render(() => <Alerts />);++ await waitFor(() => {+ expect(screen.getByTestId('alerts-config-surface')).toBeInTheDocument();+ });+ expect(screen.queryByLabelText('Toggle alerts')).not.toBeInTheDocument();+ expect(screen.getAllByText('Thresholds').length).toBeGreaterThan(0);+ expect(navigateSpy).not.toHaveBeenCalledWith('/alerts/overview', { replace: true });+ });+});diff --git a/frontend-modern/src/utils/__tests__/alertTabsPresentation.test.ts b/frontend-modern/src/utils/__tests__/alertTabsPresentation.test.tsindex c06dd0363a..5b2a7ec899 100644--- a/frontend-modern/src/utils/__tests__/alertTabsPresentation.test.ts+++ b/frontend-modern/src/utils/__tests__/alertTabsPresentation.test.ts@@ -11,6 +11,7 @@ import {getAlertsMobileTabClass,getAlertsSidebarTabClass,getAlertsTabTitle,+ isAlertsConfigurationTab,} from '@/utils/alertTabsPresentation';describe('alertTabsPresentation', () => {@@ -66,4 +67,25 @@ describe('alertTabsPresentation', () => {},]);});++ it('limits read-only sessions to reporting tabs', () => {+ expect(getAlertsTabGroups({ readOnly: true })).toEqual([+ {+ id: 'status',+ label: 'Status',+ items: [+ { id: 'overview', label: 'Overview' },+ { id: 'history', label: 'History' },+ ],+ },+ ]);+ });++ it('classifies configuration tabs through the shared helper', () => {+ expect(isAlertsConfigurationTab('overview')).toBe(false);+ expect(isAlertsConfigurationTab('history')).toBe(false);+ expect(isAlertsConfigurationTab('thresholds')).toBe(true);+ expect(isAlertsConfigurationTab('destinations')).toBe(true);+ expect(isAlertsConfigurationTab('schedule')).toBe(true);+ });});diff --git a/frontend-modern/src/utils/alertTabsPresentation.ts b/frontend-modern/src/utils/alertTabsPresentation.tsindex 1f588f74dd..8b0b6c6c4a 100644--- a/frontend-modern/src/utils/alertTabsPresentation.ts+++ b/frontend-modern/src/utils/alertTabsPresentation.ts@@ -1,9 +1,17 @@+import type { AlertTab } from '@/features/alerts/types';+export interface AlertTabPresentationOptions {isActive: boolean;isDisabled: boolean;collapsed?: boolean;}+export interface AlertTabGroup {+ id: 'status' | 'configuration';+ label: string;+ items: { id: AlertTab; label: string }[];+}+export const ALERT_TAB_GROUP_STATUS_LABEL = 'Status';export const ALERT_TAB_GROUP_CONFIGURATION_LABEL = 'Configuration';export const ALERT_TAB_OVERVIEW_LABEL = 'Overview';@@ -12,26 +20,41 @@ export const ALERT_TAB_THRESHOLDS_LABEL = 'Thresholds';export const ALERT_TAB_DESTINATIONS_LABEL = 'Notifications';export const ALERT_TAB_SCHEDULE_LABEL = 'Schedule';-export function getAlertsTabGroups() {- return [- {- id: 'status',- label: ALERT_TAB_GROUP_STATUS_LABEL,- items: [- { id: 'overview', label: ALERT_TAB_OVERVIEW_LABEL },- { id: 'history', label: ALERT_TAB_HISTORY_LABEL },- ],- },- {- id: 'configuration',- label: ALERT_TAB_GROUP_CONFIGURATION_LABEL,- items: [- { id: 'thresholds', label: ALERT_TAB_THRESHOLDS_LABEL },- { id: 'destinations', label: ALERT_TAB_DESTINATIONS_LABEL },- { id: 'schedule', label: ALERT_TAB_SCHEDULE_LABEL },- ],- },- ] as const;+const ALERT_TAB_GROUPS: AlertTabGroup[] = [+ {+ id: 'status',+ label: ALERT_TAB_GROUP_STATUS_LABEL,+ items: [+ { id: 'overview', label: ALERT_TAB_OVERVIEW_LABEL },+ { id: 'history', label: ALERT_TAB_HISTORY_LABEL },+ ],+ },+ {+ id: 'configuration',+ label: ALERT_TAB_GROUP_CONFIGURATION_LABEL,+ items: [+ { id: 'thresholds', label: ALERT_TAB_THRESHOLDS_LABEL },+ { id: 'destinations', label: ALERT_TAB_DESTINATIONS_LABEL },+ { id: 'schedule', label: ALERT_TAB_SCHEDULE_LABEL },+ ],+ },+];++export function isAlertsConfigurationTab(tab: AlertTab): boolean {+ return tab === 'thresholds' || tab === 'destinations' || tab === 'schedule';+}++export function getAlertsTabGroups(options?: { readOnly?: boolean }): AlertTabGroup[] {+ if (options?.readOnly) {+ return ALERT_TAB_GROUPS.filter((group) => group.id === 'status').map((group) => ({+ ...group,+ items: [...group.items],+ }));+ }+ return ALERT_TAB_GROUPS.map((group) => ({+ ...group,+ items: [...group.items],+ }));}export function getAlertsSidebarTabClass({