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.

Canonicalize ResourcePicker controls

rcourtman39585aa65ac7
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index eea2aef2c0..1787416c27 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -473,6 +473,9 @@ not a replacement status card, CTA band, or page-local nested card.
settings/action `px-3 py-2 text-sm` shape, the shared `xs` size owns the
compact settings row-action `px-2.5 py-1 text-xs` shape, and the shared
`iconMd` size owns the settings dialog close-button `h-9 w-9` icon shape.
+ Settings selection helpers such as `ResourcePicker` must use the same
+ `Button` primitive for select-all, clear, and chip remove actions instead of
+ restoring footer-local action shells.
If a new surface needs a variant that the shared primitive does not expose,
extend the primitive and registry guard rather than adding a page-local
class string.
@@ -2507,12 +2510,18 @@ labels, and trailing-control padding, while `SearchInput` owns resource-list
search enhancements such as history, tips, and type-to-search wiring. Product
surfaces must compose those primitives instead of rendering native
`type="search"` inputs or recreating search icon/clear/input classes locally.
+Settings resource selectors must use `SearchField` for both primary text
+search and secondary tag/resource filters instead of restoring native
+`type="text"` filter inputs beside a shared search field.
Segmented selectors are registry-backed too. `FilterButtonGroup` owns the
settings, prominent, compact, and equal segmented selector shells, including
active-button tone, disabled-option behavior, pressed-state semantics,
compact labels, and horizontal scroll treatment through the shared
shell/state/model split. Settings and compact feature surfaces must compose
that primitive instead of copying active-button selector styling locally.
+`ResourcePicker` report-domain filters are part of that boundary: the picker
+owns the reportable resource categories and labels, but the type selector shell
+must come from `FilterButtonGroup`.
Chart visibility display actions are registry-backed too.
`ChartVisibilityToggleButton` owns the `Show charts` / `Hide charts` label,
pressed-state, title, icon, and toolbar action styling for summary-bearing
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index c2da990107..b98d9d16dd 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -259,9 +259,19 @@
{ "path": "src/components/Settings/InfrastructureInstallerSection.tsx" },
{ "path": "src/components/Settings/InfrastructureSourceManager.tsx" },
{ "path": "src/components/Settings/InfrastructureWorkspace.tsx" },
+ { "path": "src/components/Settings/ResourcePicker.tsx" },
{ "path": "src/features/patrol/PatrolIntelligenceWorkspace.tsx" },
{ "path": "src/features/standalone/StandalonePageSurface.tsx" }
],
+ "forbiddenPatterns": [
+ {
+ "path": "src/components/Settings/ResourcePicker.tsx",
+ "patterns": [
+ "hover:border-red-500 hover:text-red-400",
+ "w-full sm:w-auto min-h-10 sm:min-h-9 flex items-center justify-center gap-1.5 px-3 py-2.5 text-sm rounded-md border border-border"
+ ]
+ }
+ ],
"proof": [
"src/components/shared/SharedPrimitives.guardrails.test.ts",
"src/components/shared/Button.test.tsx",
@@ -607,6 +617,12 @@
{ "path": "src/components/shared/CommandPaletteModal.tsx" },
{ "path": "src/components/shared/SearchInput.tsx" }
],
+ "forbiddenPatterns": [
+ {
+ "path": "src/components/Settings/ResourcePicker.tsx",
+ "patterns": ["type=\"text\"", "onInput={(e) => setTagFilter"]
+ }
+ ],
"proof": [
"src/components/shared/SharedPrimitives.guardrails.test.ts",
"src/components/shared/__tests__/SearchField.test.tsx",
@@ -644,9 +660,19 @@
},
"requiredConsumers": [
{ "path": "src/components/Settings/GeneralSettingsPanel.tsx" },
+ { "path": "src/components/Settings/ResourcePicker.tsx" },
{ "path": "src/components/Settings/ReportingPanel.tsx" },
{ "path": "src/features/patrol/PatrolIntelligenceHeader.tsx" }
],
+ "forbiddenPatterns": [
+ {
+ "path": "src/components/Settings/ResourcePicker.tsx",
+ "patterns": [
+ "min-h-10 sm:min-h-9 min-w-10 px-3 py-2 rounded-md text-sm font-medium transition-all",
+ "<For each={RESOURCE_PICKER_TYPE_FILTERS}>"
+ ]
+ }
+ ],
"proof": [
"src/components/shared/SharedPrimitives.guardrails.test.ts",
"src/components/shared/FilterButtonGroup.test.tsx",
diff --git a/frontend-modern/src/components/Settings/ResourcePicker.tsx b/frontend-modern/src/components/Settings/ResourcePicker.tsx
index c3f9783671..c324640169 100644
--- a/frontend-modern/src/components/Settings/ResourcePicker.tsx
+++ b/frontend-modern/src/components/Settings/ResourcePicker.tsx
@@ -4,6 +4,8 @@ import CheckSquare from 'lucide-solid/icons/check-square';
import XSquare from 'lucide-solid/icons/x-square';
import { formControl } from '@/components/shared/Form';
import { SearchField } from '@/components/shared/SearchField';
+import { FilterButtonGroup, type FilterOption } from '@/components/shared/FilterButtonGroup';
+import { Button } from '@/components/shared/Button';
import { StatusDot } from '@/components/shared/StatusDot';
import { useResources } from '@/hooks/useResources';
import type { Resource, ResourceType } from '@/types/resource';
@@ -41,6 +43,12 @@ export function ResourcePicker(props: ResourcePickerProps) {
const [typeFilter, setTypeFilter] = createSignal<TypeFilter>('all');
const [tagFilter, setTagFilter] = createSignal('');
const maxSelection = () => props.maxSelection ?? DEFAULT_MAX_SELECTION;
+ const typeFilterOptions = createMemo<FilterOption<TypeFilter>[]>(() =>
+ RESOURCE_PICKER_TYPE_FILTERS.map((type) => ({
+ value: type,
+ label: getResourcePickerTypeFilterLabel(type),
+ })),
+ );
// Filter to reportable resource types across infrastructure, workloads, storage, and recovery.
const reportableResources = createMemo(() => {
@@ -123,10 +131,7 @@ export function ResourcePicker(props: ResourcePickerProps) {
showWarning(
`Maximum ${maxSelection()} resources can be selected. Only ${maxSelection() - current.length} more can be added.`,
);
- props.onSelectionChange([
- ...current,
- ...toAdd.slice(0, maxSelection() - current.length),
- ]);
+ props.onSelectionChange([...current, ...toAdd.slice(0, maxSelection() - current.length)]);
return;
}
props.onSelectionChange(newSelection);
@@ -144,44 +149,32 @@ export function ResourcePicker(props: ResourcePickerProps) {
<div class="space-y-3">
{/* Filter bar */}
<div class="flex flex-col gap-3">
- <div class="flex gap-2 flex-wrap">
- {/* Search input */}
+ <div class="flex flex-wrap gap-2">
<SearchField
- class="flex-1 min-w-[200px]"
+ class="min-w-[200px] flex-1"
inputClass={formControl}
value={search()}
onChange={setSearch}
placeholder="Search by name or ID..."
/>
- {/* Tag filter */}
- <input
- type="text"
- class={`${formControl} w-40`}
+ <SearchField
+ class="w-full sm:w-48"
+ inputClass={formControl}
placeholder="Filter by tag..."
- aria-label="Filter resources by tag"
+ title="Filter resources by tag"
value={tagFilter()}
- onInput={(e) => setTagFilter(e.currentTarget.value)}
+ onChange={setTagFilter}
/>
</div>
- {/* Type toggle buttons */}
- <div class="flex gap-1">
- <For each={RESOURCE_PICKER_TYPE_FILTERS}>
- {(type) => (
- <button
- class={`min-h-10 sm:min-h-9 min-w-10 px-3 py-2 rounded-md text-sm font-medium transition-all ${
- typeFilter() === type
- ? 'bg-blue-600 border border-blue-500 text-blue-400'
- : 'bg-surface border border-border text-muted hover:border-border'
- }`}
- onClick={() => setTypeFilter(type)}
- >
- {getResourcePickerTypeFilterLabel(type)}
- </button>
- )}
- </For>
- </div>
+ <FilterButtonGroup
+ options={typeFilterOptions()}
+ value={typeFilter()}
+ onChange={setTypeFilter}
+ ariaLabel="Resource type filter"
+ variant="settings"
+ />
</div>
{/* Resource list */}
@@ -319,21 +312,25 @@ export function ResourcePicker(props: ResourcePickerProps) {
{/* Action bar */}
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2">
<div class="flex flex-col sm:flex-row gap-2">
- <button
- class="w-full sm:w-auto min-h-10 sm:min-h-9 flex items-center justify-center gap-1.5 px-3 py-2.5 text-sm rounded-md border border-border text-slate-400 hover:border-slate-500 hover:text-slate-300 transition-colors"
+ <Button
+ variant="outline"
+ size="settingsAction"
+ class="w-full gap-1.5 text-muted sm:w-auto"
onClick={selectAllVisible}
>
<CheckSquare size={14} />
Select all visible ({filteredResources().length})
- </button>
+ </Button>
<Show when={props.selected().length > 0}>
- <button
- class="w-full sm:w-auto min-h-10 sm:min-h-9 flex items-center justify-center gap-1.5 px-3 py-2.5 text-sm rounded-md border border-border text-slate-400 hover:border-red-500 hover:text-red-400 transition-colors"
+ <Button
+ variant="dangerOutline"
+ size="settingsAction"
+ class="w-full gap-1.5 sm:w-auto"
onClick={clearAll}
>
<XSquare size={14} />
Clear all
- </button>
+ </Button>
</Show>
</div>
<span class="text-xs sm:text-sm text-muted">
@@ -351,14 +348,16 @@ export function ResourcePicker(props: ResourcePickerProps) {
{(item) => (
<span class="inline-flex items-center gap-1 pl-2 pr-1 py-1 rounded-md bg-blue-600 border border-blue-500 text-sm text-blue-300">
{item.name}
- <button
- class="p-0.5 rounded hover:bg-blue-500 transition-colors"
+ <Button
+ variant="ghost"
+ size="xs"
+ class="min-h-0 p-0.5 text-blue-300 hover:bg-blue-500"
onClick={() => removeSelected(item.id)}
aria-label={`Remove ${item.name}`}
title={`Remove ${item.name}`}
>
<X size={12} />
- </button>
+ </Button>
</span>
)}
</For>
diff --git a/frontend-modern/src/components/Settings/__tests__/ResourcePicker.test.tsx b/frontend-modern/src/components/Settings/__tests__/ResourcePicker.test.tsx
index 3b26947d03..9a42a62f6f 100644
--- a/frontend-modern/src/components/Settings/__tests__/ResourcePicker.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/ResourcePicker.test.tsx
@@ -205,6 +205,35 @@ describe('ResourcePicker', () => {
expect(screen.queryByText('Production VM')).not.toBeInTheDocument();
});
+ it('filters resources by tag through the shared search field', async () => {
+ mockResources = [
+ makeResource({
+ id: 'vm-prod-101',
+ type: 'vm',
+ name: 'Production VM',
+ displayName: 'Production VM',
+ tags: ['critical', 'finance'],
+ }),
+ makeResource({
+ id: 'host-dev-55',
+ type: 'agent',
+ name: 'Edge Host',
+ displayName: 'Edge Host',
+ status: 'online',
+ tags: ['lab'],
+ }),
+ ];
+
+ renderPicker();
+
+ const tagInput = screen.getByPlaceholderText('Filter by tag...');
+ fireEvent.input(tagInput, { target: { value: 'finance' } });
+
+ expect(await screen.findByText('Production VM')).toBeInTheDocument();
+ expect(screen.queryByText('Edge Host')).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Clear search' })).toBeInTheDocument();
+ });
+
it('toggles individual selection on and off', async () => {
mockResources = [
makeResource({ id: 'vm-1', type: 'vm', name: 'Alpha VM', displayName: 'Alpha VM' }),
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 2a18df303d..1e12c3106b 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -248,6 +248,7 @@ describe('shared primitive guardrails', () => {
id: string;
canonical?: { path?: string; export?: string };
requiredConsumers?: Array<{ path?: string }>;
+ forbiddenPatterns?: Array<{ path?: string; patterns?: string[] }>;
}>;
patternGuards?: Array<{
id: string;
@@ -266,9 +267,21 @@ describe('shared primitive guardrails', () => {
expect(registeredRule?.canonical?.export).toBe('FilterButtonGroup');
expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual([
'src/components/Settings/GeneralSettingsPanel.tsx',
+ 'src/components/Settings/ResourcePicker.tsx',
'src/components/Settings/ReportingPanel.tsx',
'src/features/patrol/PatrolIntelligenceHeader.tsx',
]);
+ expect(registeredRule?.forbiddenPatterns).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({
+ path: 'src/components/Settings/ResourcePicker.tsx',
+ patterns: expect.arrayContaining([
+ 'min-h-10 sm:min-h-9 min-w-10 px-3 py-2 rounded-md text-sm font-medium transition-all',
+ '<For each={RESOURCE_PICKER_TYPE_FILTERS}>',
+ ]),
+ }),
+ ]),
+ );
expect(registeredGuard?.canonical?.path).toBe(
'src/components/shared/filterButtonGroupModel.ts',
);
@@ -306,6 +319,11 @@ describe('shared primitive guardrails', () => {
expect(generalSettingsPanelSource).not.toContain(
'props.pvePollingSelection() === option.value',
);
+ expect(resourcePickerSource).toContain('FilterButtonGroup');
+ expect(resourcePickerSource).not.toContain('<For each={RESOURCE_PICKER_TYPE_FILTERS}>');
+ expect(resourcePickerSource).not.toContain(
+ 'min-h-10 sm:min-h-9 min-w-10 px-3 py-2 rounded-md text-sm font-medium transition-all',
+ );
expect(reportingPanelSource.match(/<FilterButtonGroup/g) ?? []).toHaveLength(2);
expect(reportingPanelSource).toContain('variant="prominent"');
expect(reportingPanelSource).not.toContain('getReportingToggleButtonClass');
@@ -336,6 +354,7 @@ describe('shared primitive guardrails', () => {
id: string;
canonical?: { path?: string; export?: string };
requiredConsumers?: Array<{ path?: string }>;
+ forbiddenPatterns?: Array<{ path?: string; patterns?: string[] }>;
}>;
patternGuards?: Array<{
id: string;
@@ -438,6 +457,7 @@ describe('shared primitive guardrails', () => {
id: string;
canonical?: { path?: string; export?: string };
requiredConsumers?: Array<{ path?: string }>;
+ forbiddenPatterns?: Array<{ path?: string; patterns?: string[] }>;
}>;
patternGuards?: Array<{
id: string;
@@ -529,6 +549,7 @@ describe('shared primitive guardrails', () => {
id: string;
canonical?: { path?: string; export?: string };
requiredConsumers?: Array<{ path?: string }>;
+ forbiddenPatterns?: Array<{ path?: string; patterns?: string[] }>;
}>;
patternGuards?: Array<{
id: string;
@@ -676,6 +697,7 @@ describe('shared primitive guardrails', () => {
id: string;
canonical?: { path?: string; export?: string };
requiredConsumers?: Array<{ path?: string }>;
+ forbiddenPatterns?: Array<{ path?: string; patterns?: string[] }>;
}>;
patternGuards?: Array<{
id: string;
@@ -1514,6 +1536,7 @@ describe('shared primitive guardrails', () => {
id: string;
canonical?: { path?: string; export?: string };
requiredConsumers?: Array<{ path?: string }>;
+ forbiddenPatterns?: Array<{ path?: string; patterns?: string[] }>;
}>;
patternGuards?: Array<{
id: string;
@@ -1588,9 +1611,21 @@ describe('shared primitive guardrails', () => {
'src/components/Settings/InfrastructureInstallerSection.tsx',
'src/components/Settings/InfrastructureSourceManager.tsx',
'src/components/Settings/InfrastructureWorkspace.tsx',
+ 'src/components/Settings/ResourcePicker.tsx',
'src/features/patrol/PatrolIntelligenceWorkspace.tsx',
'src/features/standalone/StandalonePageSurface.tsx',
]);
+ expect(registeredRule?.forbiddenPatterns).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({
+ path: 'src/components/Settings/ResourcePicker.tsx',
+ patterns: expect.arrayContaining([
+ 'hover:border-red-500 hover:text-red-400',
+ 'w-full sm:w-auto min-h-10 sm:min-h-9 flex items-center justify-center gap-1.5 px-3 py-2.5 text-sm rounded-md border border-border',
+ ]),
+ }),
+ ]),
+ );
expect(registeredGuard?.canonical?.path).toBe('src/components/shared/buttonModel.ts');
expect(registeredGuard?.canonical?.export).toBe('getButtonClass');
expect(registeredGuard?.allPatterns).toEqual([
@@ -1866,6 +1901,12 @@ describe('shared primitive guardrails', () => {
expect(infrastructureWorkspaceSource).not.toContain(
'h-9 w-9 items-center justify-center rounded-md border border-border text-base-content transition-colors hover:bg-surface-hover',
);
+ expect(resourcePickerSource).toContain('@/components/shared/Button');
+ expect(resourcePickerSource).toContain('<Button');
+ expect(resourcePickerSource).not.toContain('hover:border-red-500 hover:text-red-400');
+ expect(resourcePickerSource).not.toContain(
+ 'w-full sm:w-auto min-h-10 sm:min-h-9 flex items-center justify-center gap-1.5 px-3 py-2.5 text-sm rounded-md border border-border',
+ );
expect(discoveryTabSource).toContain('@/components/shared/Button');
expect(discoveryTabSource).toContain('@/components/shared/CopyableCodeRow');
expect(discoveryTabSource).toContain('CopyValueButton');
@@ -2751,6 +2792,7 @@ describe('shared primitive guardrails', () => {
id: string;
canonical?: { path?: string; export?: string };
requiredConsumers?: Array<{ path?: string }>;
+ forbiddenPatterns?: Array<{ path?: string; patterns?: string[] }>;
}>;
patternGuards?: Array<{
id: string;
@@ -2778,6 +2820,14 @@ describe('shared primitive guardrails', () => {
'src/components/shared/CommandPaletteModal.tsx',
'src/components/shared/SearchInput.tsx',
]);
+ expect(registeredRule?.forbiddenPatterns).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({
+ path: 'src/components/Settings/ResourcePicker.tsx',
+ patterns: ['type="text"', 'onInput={(e) => setTagFilter'],
+ }),
+ ]),
+ );
expect(registeredGuard?.canonical?.path).toBe('src/components/shared/SearchField.tsx');
expect(registeredGuard?.canonical?.export).toBe('SearchField');
expect(registeredGuard?.allPatterns).toEqual(['type="search"']);
@@ -2806,6 +2856,10 @@ describe('shared primitive guardrails', () => {
expect(searchFieldModelSource).toContain('shouldShowSearchFieldClearButton');
expect(searchFieldModelSource).toContain('getSearchFieldInputPaddingRightClass');
expect(searchFieldModelSource).toContain("return 'pr-14 sm:pr-20'");
+ expect(resourcePickerSource.match(/<SearchField/g) ?? []).toHaveLength(2);
+ expect(resourcePickerSource).toContain('placeholder="Filter by tag..."');
+ expect(resourcePickerSource).not.toContain('type="text"');
+ expect(resourcePickerSource).not.toContain('onInput={(e) => setTagFilter');
for (const source of [
assistantCommandHelpDialogSource,