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.

Register shared toggle governance

rcourtman7b251f5651cb
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 1020be362c..7bec132f7c 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2281,6 +2281,12 @@ plus the synthetic toggle change-event runtime, and
track/knob/container class policy, and the canonical toggle event type.
Future toggle work should extend those owners instead of pushing synthetic
event behavior or size/class policy back into the shell.
+Binary on/off controls are registry-backed too. Product surfaces must compose
+`Toggle` or `TogglePrimitive` for shared track/knob styling, disabled behavior,
+label/description wiring, and synthetic checked events instead of recreating
+local `role="switch"` buttons with `aria-checked` and page-local classes.
+Ordinary checkboxes, radio groups, and row-selection controls are separate
+affordances and must not be forced through this toggle primitive.
The shared status badge now follows that same owner split.
`frontend-modern/src/components/shared/StatusBadge.tsx` stays the render shell,
`frontend-modern/src/components/shared/useStatusBadgeState.ts` owns disabled
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index bde84f6b82..26c75ea662 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -247,6 +247,46 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "toggle-shell",
+ "category": "toggle-control",
+ "summary": "Binary on/off controls must compose Toggle or TogglePrimitive for shared track/knob styling, disabled behavior, label/description wiring, and synthetic checked events instead of recreating local switch buttons.",
+ "canonical": {
+ "path": "src/components/shared/Toggle.tsx",
+ "export": "Toggle"
+ },
+ "requiredConsumers": [
+ { "path": "src/components/Alerts/AlertResourceTableDesktop.tsx" },
+ { "path": "src/components/Alerts/AlertResourceTableMobile.tsx" },
+ { "path": "src/components/Alerts/AlertResourceTableRow.tsx" },
+ { "path": "src/components/Alerts/ThresholdsTableDockerServiceGapSection.tsx" },
+ { "path": "src/components/Alerts/ThresholdsTableProxmoxBackupsSection.tsx" },
+ { "path": "src/components/Infrastructure/ResourceOperatorStateSection.tsx" },
+ { "path": "src/components/Settings/AIRuntimeControlsSection.tsx" },
+ { "path": "src/components/Settings/AISettings.tsx" },
+ { "path": "src/components/Settings/AuditLogPanel.tsx" },
+ { "path": "src/components/Settings/DiscoverySettingsForm.tsx" },
+ { "path": "src/components/Settings/DockerRuntimeSettingsCard.tsx" },
+ { "path": "src/components/Settings/GeneralSettingsPanel.tsx" },
+ { "path": "src/components/Settings/NodeModalMonitoringSection.tsx" },
+ { "path": "src/components/Settings/RelaySettingsPanel.tsx" },
+ { "path": "src/components/Settings/SSOProvidersPanel.tsx" },
+ { "path": "src/components/Settings/SecurityAuthPanel.tsx" },
+ { "path": "src/features/alerts/AlertAppriseDestinationsSection.tsx" },
+ { "path": "src/features/alerts/AlertCooldownSection.tsx" },
+ { "path": "src/features/alerts/AlertEmailDestinationsSection.tsx" },
+ { "path": "src/features/alerts/AlertEscalationSection.tsx" },
+ { "path": "src/features/alerts/AlertGroupingSection.tsx" },
+ { "path": "src/features/alerts/AlertQuietHoursSection.tsx" },
+ { "path": "src/features/alerts/AlertRecoverySection.tsx" },
+ { "path": "src/features/patrol/PatrolIntelligenceHeader.tsx" }
+ ],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/shared/Toggle.test.tsx",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "platform-table-loading-state",
"category": "platform-table-loading-state",
@@ -807,7 +847,10 @@
"src/components/Alerts/AlertResourceTableMobile.tsx",
"src/components/Alerts/AlertResourceTableRow.tsx"
],
- "ignoredPaths": ["src/components/shared/SharedPrimitives.guardrails.test.ts"],
+ "ignoredPaths": [
+ "src/components/Alerts/EmailProviderSelect.test.tsx",
+ "src/components/shared/SharedPrimitives.guardrails.test.ts"
+ ],
"proof": [
"src/components/shared/SharedPrimitives.guardrails.test.ts",
"scripts/shared-template-audit.mjs"
@@ -826,7 +869,10 @@
"allPatterns": ["<textarea"],
"legacyReason": "Bounded residual. SSO provider metadata textareas still require a dedicated editor migration; new settings textareas must use FormTextarea.",
"allowedPaths": ["src/components/Settings/SSOProvidersPanel.tsx"],
- "ignoredPaths": ["src/components/shared/SharedPrimitives.guardrails.test.ts"],
+ "ignoredPaths": [
+ "src/components/Settings/__tests__/ProLicensePanel.test.tsx",
+ "src/components/shared/SharedPrimitives.guardrails.test.ts"
+ ],
"proof": [
"src/components/shared/SharedPrimitives.guardrails.test.ts",
"scripts/shared-template-audit.mjs"
@@ -851,6 +897,30 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "toggle-local-role-switch",
+ "category": "toggle-control",
+ "summary": "Binary switch-looking controls must compose Toggle or TogglePrimitive instead of hand-rolling local role=switch buttons with aria-checked and custom track/knob classes.",
+ "canonical": {
+ "path": "src/components/shared/Toggle.tsx",
+ "export": "Toggle"
+ },
+ "scopes": ["src/components", "src/features"],
+ "extensions": [".tsx"],
+ "allPatterns": ["role=\"switch\"", "aria-checked"],
+ "legacyReason": "Retired migration debt. Local switch role buttons must route through the shared Toggle primitive; radios, checkboxes, and selection controls are governed separately.",
+ "allowedPaths": [],
+ "ignoredPaths": [
+ "src/components/Alerts/ResourceTable.test.tsx",
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/shared/Toggle.test.tsx"
+ ],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/shared/Toggle.test.tsx",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "filter-chip-status-dot-local-factory",
"category": "filter-bar",
diff --git a/frontend-modern/src/components/Settings/DockerRuntimeSettingsCard.tsx b/frontend-modern/src/components/Settings/DockerRuntimeSettingsCard.tsx
index 297e1f4df3..e673d22275 100644
--- a/frontend-modern/src/components/Settings/DockerRuntimeSettingsCard.tsx
+++ b/frontend-modern/src/components/Settings/DockerRuntimeSettingsCard.tsx
@@ -1,5 +1,6 @@
import { Component, Accessor, Show } from 'solid-js';
import { EnvironmentLockBadge } from '@/components/shared/EnvironmentLockBadge';
+import { TogglePrimitive } from '@/components/shared/Toggle';
import { ENVIRONMENT_LOCK_BUTTON_TITLE } from '@/utils/environmentLockPresentation';
import {
DOCKER_UPDATE_ACTIONS_ENV_VAR,
@@ -29,7 +30,7 @@ export const DockerRuntimeSettingsCard: Component<DockerRuntimeSettingsCardProps
<div class="flex items-start justify-between gap-4 rounded-md border border-border bg-surface-hover p-4">
<div class="flex-1 space-y-1">
<div class="flex items-center gap-2">
- <span class="text-sm font-medium text-base-content">
+ <span id="docker-update-actions-toggle-label" class="text-sm font-medium text-base-content">
{DOCKER_UPDATE_ACTIONS_TOGGLE_LABEL}
</span>
<Show when={props.disableDockerUpdateActionsLocked()}>
@@ -53,7 +54,9 @@ export const DockerRuntimeSettingsCard: Component<DockerRuntimeSettingsCardProps
/>
</Show>
</div>
- <p class="text-xs text-muted">{DOCKER_UPDATE_ACTIONS_TOGGLE_DESCRIPTION}</p>
+ <p id="docker-update-actions-toggle-description" class="text-xs text-muted">
+ {DOCKER_UPDATE_ACTIONS_TOGGLE_DESCRIPTION}
+ </p>
<p class="text-xs text-muted mt-1">
Can also be set via environment variable:{' '}
<code class="px-1 py-0.5 rounded bg-surface-hover text-base-content">
@@ -62,27 +65,18 @@ export const DockerRuntimeSettingsCard: Component<DockerRuntimeSettingsCardProps
</p>
</div>
<div class="flex-shrink-0">
- <button
- type="button"
- onClick={() =>
- props.handleDisableDockerUpdateActionsChange(!props.disableDockerUpdateActions())
+ <TogglePrimitive
+ checked={props.disableDockerUpdateActions()}
+ onChange={(event) =>
+ props.handleDisableDockerUpdateActionsChange(event.currentTarget.checked)
}
disabled={props.disableDockerUpdateActionsLocked() || props.savingDockerUpdateActions()}
- class={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ${
- props.disableDockerUpdateActions() ? 'bg-blue-600' : 'bg-surface-alt'
- } ${props.disableDockerUpdateActionsLocked() ? 'opacity-50 cursor-not-allowed' : ''}`}
- role="switch"
- aria-checked={props.disableDockerUpdateActions()}
+ ariaLabelledBy="docker-update-actions-toggle-label"
+ ariaDescribedBy="docker-update-actions-toggle-description"
title={
props.disableDockerUpdateActionsLocked() ? ENVIRONMENT_LOCK_BUTTON_TITLE : undefined
}
- >
- <span
- class={`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${
- props.disableDockerUpdateActions() ? 'translate-x-6' : 'translate-x-1'
- }`}
- />
- </button>
+ />
</div>
</div>
</div>
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index 2adf61cdb7..c66f8a018c 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -466,6 +466,9 @@ describe('settings architecture guardrails', () => {
it('keeps Docker and Podman update-action copy on the system settings presentation owner', () => {
expect(dockerRuntimeSettingsCardSource).toContain('DOCKER_UPDATE_ACTIONS_SECTION_TITLE');
expect(dockerRuntimeSettingsCardSource).toContain('DOCKER_UPDATE_ACTIONS_ENV_VAR');
+ expect(dockerRuntimeSettingsCardSource).toContain('TogglePrimitive');
+ expect(dockerRuntimeSettingsCardSource).not.toContain('role="switch"');
+ expect(dockerRuntimeSettingsCardSource).not.toContain('aria-checked');
expect(dockerRuntimeSettingsCardSource).not.toContain('Container Updates');
expect(dockerRuntimeSettingsCardSource).not.toContain('container update actions');
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 5efbbc0757..712ca56cb1 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -162,6 +162,7 @@ import aiSettingsDialogsSource from '@/components/Settings/AISettingsDialogs.tsx
import agentProfilesPanelSource from '@/components/Settings/AgentProfilesPanel.tsx?raw';
import apiTokenManagerSource from '@/components/Settings/APITokenManager.tsx?raw';
import diagnosticsResultsPanelSource from '@/components/Settings/DiagnosticsResultsPanel.tsx?raw';
+import dockerRuntimeSettingsCardSource from '@/components/Settings/DockerRuntimeSettingsCard.tsx?raw';
import generalSettingsPanelSource from '@/components/Settings/GeneralSettingsPanel.tsx?raw';
import organizationAccessMembersSectionSource from '@/components/Settings/OrganizationAccessMembersSection.tsx?raw';
import organizationIncomingSharesSectionSource from '@/components/Settings/OrganizationIncomingSharesSection.tsx?raw';
@@ -1255,6 +1256,65 @@ describe('shared primitive guardrails', () => {
});
it('keeps toggle on shell, runtime, and model owners', () => {
+ const registry = JSON.parse(sharedTemplateRegistrySource) as {
+ rules?: Array<{
+ id: string;
+ canonical?: { path?: string; export?: string };
+ requiredConsumers?: Array<{ path?: string }>;
+ }>;
+ patternGuards?: Array<{
+ id: string;
+ canonical?: { path?: string; export?: string };
+ allPatterns?: string[];
+ scopes?: string[];
+ allowedPaths?: string[];
+ ignoredPaths?: string[];
+ }>;
+ };
+ const registeredRule = registry.rules?.find((rule) => rule.id === 'toggle-shell');
+ const registeredGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'toggle-local-role-switch',
+ );
+
+ expect(registeredRule?.canonical?.path).toBe('src/components/shared/Toggle.tsx');
+ expect(registeredRule?.canonical?.export).toBe('Toggle');
+ expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual([
+ 'src/components/Alerts/AlertResourceTableDesktop.tsx',
+ 'src/components/Alerts/AlertResourceTableMobile.tsx',
+ 'src/components/Alerts/AlertResourceTableRow.tsx',
+ 'src/components/Alerts/ThresholdsTableDockerServiceGapSection.tsx',
+ 'src/components/Alerts/ThresholdsTableProxmoxBackupsSection.tsx',
+ 'src/components/Infrastructure/ResourceOperatorStateSection.tsx',
+ 'src/components/Settings/AIRuntimeControlsSection.tsx',
+ 'src/components/Settings/AISettings.tsx',
+ 'src/components/Settings/AuditLogPanel.tsx',
+ 'src/components/Settings/DiscoverySettingsForm.tsx',
+ 'src/components/Settings/DockerRuntimeSettingsCard.tsx',
+ 'src/components/Settings/GeneralSettingsPanel.tsx',
+ 'src/components/Settings/NodeModalMonitoringSection.tsx',
+ 'src/components/Settings/RelaySettingsPanel.tsx',
+ 'src/components/Settings/SSOProvidersPanel.tsx',
+ 'src/components/Settings/SecurityAuthPanel.tsx',
+ 'src/features/alerts/AlertAppriseDestinationsSection.tsx',
+ 'src/features/alerts/AlertCooldownSection.tsx',
+ 'src/features/alerts/AlertEmailDestinationsSection.tsx',
+ 'src/features/alerts/AlertEscalationSection.tsx',
+ 'src/features/alerts/AlertGroupingSection.tsx',
+ 'src/features/alerts/AlertQuietHoursSection.tsx',
+ 'src/features/alerts/AlertRecoverySection.tsx',
+ 'src/features/patrol/PatrolIntelligenceHeader.tsx',
+ ]);
+ expect(registeredGuard?.canonical?.path).toBe('src/components/shared/Toggle.tsx');
+ expect(registeredGuard?.canonical?.export).toBe('Toggle');
+ expect(registeredGuard?.allPatterns).toEqual(['role="switch"', 'aria-checked']);
+ expect(registeredGuard?.scopes).toEqual(['src/components', 'src/features']);
+ expect(registeredGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(registeredGuard?.ignoredPaths).toEqual([
+ 'src/components/Alerts/ResourceTable.test.tsx',
+ 'src/components/shared/SharedPrimitives.guardrails.test.ts',
+ 'src/components/shared/Toggle.test.tsx',
+ ]);
+
expect(toggleSource).toContain('useToggleState');
expect(toggleSource).toContain('getToggleTrackClass');
expect(toggleSource).toContain('getToggleKnobClass');
@@ -1273,6 +1333,12 @@ describe('shared primitive guardrails', () => {
expect(toggleModelSource).toContain('getToggleTrackClass');
expect(toggleModelSource).toContain('getToggleKnobClass');
expect(toggleModelSource).toContain('ToggleChangeEvent');
+
+ expect(dockerRuntimeSettingsCardSource).toContain('TogglePrimitive');
+ expect(dockerRuntimeSettingsCardSource).toContain('ariaLabelledBy');
+ expect(dockerRuntimeSettingsCardSource).toContain('ariaDescribedBy');
+ expect(dockerRuntimeSettingsCardSource).not.toContain('role="switch"');
+ expect(dockerRuntimeSettingsCardSource).not.toContain('aria-checked');
});
it('keeps status badge on shell, runtime, and model owners', () => {