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 form select governance

rcourtman6ca91d47e6e7
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index ebd8a048c8..ff5d18b96e 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2430,6 +2430,13 @@ semantics. Storage linked-disk health rows must derive a `StatusDot` variant
through `getLinkedDiskHealthDotVariant` and must not recreate local rounded
green/yellow span classes in storage components or storage-backup presentation
helpers.
+Native select controls are registry-backed too. `FormSelect` owns label/id
+wiring, helper-text description merging, value synchronization, default select
+chrome, and compact styling hooks for native selects. Workloads guest and node
+history range controls must compose `FormSelect` rather than recreating a
+screen-reader label plus raw `<select>` shell locally, and future native-select
+migrations should extend that primitive instead of forking labelled select
+wrappers.
Search controls are registry-backed too. `SearchField` owns simple search
input chrome, clear affordance, keyboard forwarding, focus handling, aria
labels, and trailing-control padding, while `SearchInput` owns resource-list
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index 879c596609..9eee6594bd 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -180,6 +180,48 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "form-select-shell",
+ "category": "form-control",
+ "summary": "Native select controls must compose FormSelect for shared label/id/help wiring, value synchronization, and select chrome instead of recreating labelled select wrappers locally.",
+ "canonical": {
+ "path": "src/components/shared/FormSelect.tsx",
+ "export": "FormSelect"
+ },
+ "requiredConsumers": [
+ { "path": "src/components/AI/FindingsPanel.tsx" },
+ { "path": "src/components/Alerts/EmailProviderSelect.tsx" },
+ { "path": "src/components/Alerts/WebhookConfigForm.tsx" },
+ { "path": "src/components/Settings/AIChatMaintenanceSection.tsx" },
+ { "path": "src/components/Settings/AIModelSelectionSection.tsx" },
+ { "path": "src/components/Settings/AIRuntimeControlsSection.tsx" },
+ { "path": "src/components/Settings/AgentProfilesPanel.tsx" },
+ { "path": "src/components/Settings/AuditLogPanel.tsx" },
+ { "path": "src/components/Settings/ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsx" },
+ { "path": "src/components/Settings/ConnectionEditor/CredentialSlots/TrueNASCredentialSlot.tsx" },
+ { "path": "src/components/Settings/InfrastructureInstallerSection.tsx" },
+ { "path": "src/components/Settings/NodeModalMonitoringSection.tsx" },
+ { "path": "src/components/Settings/OrganizationAccessManagementSection.tsx" },
+ { "path": "src/components/Settings/OrganizationAccessMembersSection.tsx" },
+ { "path": "src/components/Settings/OrganizationSharingCreateSection.tsx" },
+ { "path": "src/components/Settings/RecoverySettingsPanel.tsx" },
+ { "path": "src/components/Settings/RolesEditorDialog.tsx" },
+ { "path": "src/components/Settings/SystemLogsPanel.tsx" },
+ { "path": "src/components/Settings/UpdatesSettingsPanel.tsx" },
+ { "path": "src/components/Storage/DiskDetail.tsx" },
+ { "path": "src/components/Storage/StoragePoolDetail.tsx" },
+ { "path": "src/components/Workloads/GuestDrawerHistory.tsx" },
+ { "path": "src/features/alerts/AlertAppriseDestinationsSection.tsx" },
+ { "path": "src/features/alerts/AlertEscalationSection.tsx" },
+ { "path": "src/features/alerts/AlertQuietHoursSection.tsx" },
+ { "path": "src/features/patrol/PatrolIntelligenceHeader.tsx" }
+ ],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/shared/FormSelect.test.tsx",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "platform-table-loading-state",
"category": "platform-table-loading-state",
@@ -705,6 +747,25 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "form-select-local-guest-history-range-select",
+ "category": "form-control",
+ "summary": "Guest and node drawer history range controls must compose FormSelect instead of recreating the labelled native select locally.",
+ "canonical": {
+ "path": "src/components/shared/FormSelect.tsx",
+ "export": "FormSelect"
+ },
+ "scopes": ["src/components/Workloads"],
+ "extensions": [".tsx"],
+ "allPatterns": ["<select", "guest-history-range"],
+ "legacyReason": "Retired migration debt. Guest history range controls must use FormSelect for label/id/select chrome wiring.",
+ "allowedPaths": [],
+ "ignoredPaths": ["src/components/shared/SharedPrimitives.guardrails.test.ts"],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "filter-chip-status-dot-local-factory",
"category": "filter-bar",
diff --git a/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx b/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx
index c88851e138..e557bef044 100644
--- a/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx
+++ b/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx
@@ -8,6 +8,7 @@ import {
type ResourceType,
type SingleMetricHistoryResponse,
} from '@/api/charts';
+import { FormSelect } from '@/components/shared/FormSelect';
import { filterSelectClass } from '@/components/shared/FilterToolbar';
import {
HISTORY_CHART_RANGES,
@@ -98,22 +99,20 @@ const formatRangeLabel = (range: HistoryTimeRange): string => {
export const GuestDrawerHistoryRangeSelect: Component<GuestDrawerHistoryRangeSelectProps> = (
props,
) => (
- <>
- <label class="sr-only" for="guest-history-range">
- History range
- </label>
- <select
- id="guest-history-range"
- class={`${filterSelectClass} h-7 py-0 text-[11px]`}
- data-testid="guest-history-range-control"
- value={props.range}
- onChange={(event) => props.onRangeChange(event.currentTarget.value as HistoryTimeRange)}
- >
- <For each={HISTORY_CHART_RANGES}>
- {(option) => <option value={option}>{formatRangeLabel(option)}</option>}
- </For>
- </select>
- </>
+ <FormSelect
+ id="guest-history-range"
+ label="History range"
+ labelClass="sr-only"
+ fieldBaseClass="contents"
+ selectBaseClass={`${filterSelectClass} h-7 py-0 text-[11px]`}
+ data-testid="guest-history-range-control"
+ value={props.range}
+ onChange={(event) => props.onRangeChange(event.currentTarget.value as HistoryTimeRange)}
+ >
+ <For each={HISTORY_CHART_RANGES}>
+ {(option) => <option value={option}>{formatRangeLabel(option)}</option>}
+ </For>
+ </FormSelect>
);
const normalizeHistoryResponse = (
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 2795d97066..c224335038 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -107,6 +107,7 @@ import truenasProtectionTableSource from '@/features/truenas/TrueNASProtectionTa
import vmwarePageSurfaceSource from '@/features/vmware/VmwarePageSurface.tsx?raw';
import upgradeNavigationSource from '@/utils/upgradeNavigation.ts?raw';
import guestRowSource from '@/components/Workloads/GuestRow.tsx?raw';
+import guestDrawerHistorySource from '@/components/Workloads/GuestDrawerHistory.tsx?raw';
import workloadsSurfaceSource from '@/components/Workloads/WorkloadsSurface.tsx?raw';
import workloadsTableSource from '@/components/Workloads/WorkloadsTable.tsx?raw';
import workloadPanelSource from '@/components/Workloads/WorkloadPanel.tsx?raw';
@@ -296,6 +297,65 @@ describe('shared primitive guardrails', () => {
});
it('keeps native form selects on the shared labelled primitive', () => {
+ 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 === 'form-select-shell');
+ const registeredGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'form-select-local-guest-history-range-select',
+ );
+
+ expect(registeredRule?.canonical?.path).toBe('src/components/shared/FormSelect.tsx');
+ expect(registeredRule?.canonical?.export).toBe('FormSelect');
+ expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual([
+ 'src/components/AI/FindingsPanel.tsx',
+ 'src/components/Alerts/EmailProviderSelect.tsx',
+ 'src/components/Alerts/WebhookConfigForm.tsx',
+ 'src/components/Settings/AIChatMaintenanceSection.tsx',
+ 'src/components/Settings/AIModelSelectionSection.tsx',
+ 'src/components/Settings/AIRuntimeControlsSection.tsx',
+ 'src/components/Settings/AgentProfilesPanel.tsx',
+ 'src/components/Settings/AuditLogPanel.tsx',
+ 'src/components/Settings/ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsx',
+ 'src/components/Settings/ConnectionEditor/CredentialSlots/TrueNASCredentialSlot.tsx',
+ 'src/components/Settings/InfrastructureInstallerSection.tsx',
+ 'src/components/Settings/NodeModalMonitoringSection.tsx',
+ 'src/components/Settings/OrganizationAccessManagementSection.tsx',
+ 'src/components/Settings/OrganizationAccessMembersSection.tsx',
+ 'src/components/Settings/OrganizationSharingCreateSection.tsx',
+ 'src/components/Settings/RecoverySettingsPanel.tsx',
+ 'src/components/Settings/RolesEditorDialog.tsx',
+ 'src/components/Settings/SystemLogsPanel.tsx',
+ 'src/components/Settings/UpdatesSettingsPanel.tsx',
+ 'src/components/Storage/DiskDetail.tsx',
+ 'src/components/Storage/StoragePoolDetail.tsx',
+ 'src/components/Workloads/GuestDrawerHistory.tsx',
+ 'src/features/alerts/AlertAppriseDestinationsSection.tsx',
+ 'src/features/alerts/AlertEscalationSection.tsx',
+ 'src/features/alerts/AlertQuietHoursSection.tsx',
+ 'src/features/patrol/PatrolIntelligenceHeader.tsx',
+ ]);
+ expect(registeredGuard?.canonical?.path).toBe('src/components/shared/FormSelect.tsx');
+ expect(registeredGuard?.canonical?.export).toBe('FormSelect');
+ expect(registeredGuard?.allPatterns).toEqual(['<select', 'guest-history-range']);
+ expect(registeredGuard?.scopes).toEqual(['src/components/Workloads']);
+ expect(registeredGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(registeredGuard?.ignoredPaths).toEqual([
+ 'src/components/shared/SharedPrimitives.guardrails.test.ts',
+ ]);
+
expect(formSelectSource).toContain("from '@/components/shared/Form'");
expect(formSelectSource).toContain('createUniqueId');
expect(formSelectSource).toContain('splitProps');
@@ -310,6 +370,11 @@ describe('shared primitive guardrails', () => {
expect(formSelectSource).toContain('selectElement.value = nextValue');
expect(formSelectSource).toContain('local.selectBaseClass ?? formSelect');
expect(formSelectSource).toContain('local.fieldBaseClass ?? formField');
+
+ expect(guestDrawerHistorySource).toContain('FormSelect');
+ expect(guestDrawerHistorySource).toContain('id="guest-history-range"');
+ expect(guestDrawerHistorySource).toContain('data-testid="guest-history-range-control"');
+ expect(guestDrawerHistorySource).not.toContain('<select');
});
it('routes selectable settings cards through SelectionCardGroup', () => {