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.

Split agents thresholds section owners

rcourtmandb3f89267d02
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index 5f9d8ccc0f..68674584d6 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -180,6 +180,12 @@ and `frontend-modern/src/components/Alerts/ThresholdsTableDockerContainersSectio
Future Docker thresholds presentation work should extend those section owners
instead of expanding `frontend-modern/src/components/Alerts/ThresholdsTableDockerTab.tsx`
back into a mixed render surface.
+The agents tab now follows that same shell-versus-section pattern through
+`frontend-modern/src/components/Alerts/ThresholdsTableAgentsResourcesSection.tsx`
+and `frontend-modern/src/components/Alerts/ThresholdsTableAgentDisksSection.tsx`.
+Future agent thresholds presentation work should extend those section owners
+instead of expanding `frontend-modern/src/components/Alerts/ThresholdsTableAgentsTab.tsx`
+back into a mixed render surface.
The alert resource thresholds editor now follows the same shape: shared metric
normalization, bounds, value-resolution, and override-label logic live in
`frontend-modern/src/components/Alerts/alertResourceTableModel.ts`, shared group
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 92d2007a6c..4713f0ea65 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -459,6 +459,12 @@ and `frontend-modern/src/components/Alerts/ThresholdsTableDockerContainersSectio
Future Docker thresholds presentation changes should extend those section
surfaces rather than restoring mixed JSX ownership to
`frontend-modern/src/components/Alerts/ThresholdsTableDockerTab.tsx`.
+The agents tab now follows that same composition pattern through
+`frontend-modern/src/components/Alerts/ThresholdsTableAgentsResourcesSection.tsx`
+and `frontend-modern/src/components/Alerts/ThresholdsTableAgentDisksSection.tsx`.
+Future agent thresholds presentation changes should extend those section
+surfaces rather than restoring mixed JSX ownership to
+`frontend-modern/src/components/Alerts/ThresholdsTableAgentsTab.tsx`.
Canonical threshold row shaping now routes through
`frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts`
plus the family-owned feature hooks
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableAgentDisksSection.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableAgentDisksSection.tsx
new file mode 100644
index 0000000000..cac784f4ff
--- /dev/null
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableAgentDisksSection.tsx
@@ -0,0 +1,70 @@
+import { Show } from 'solid-js';
+import HardDrive from 'lucide-solid/icons/hard-drive';
+
+import { ResourceTable } from './ResourceTable';
+import { CollapsibleSection } from './Thresholds/sections/CollapsibleSection';
+import { formatMetricValue } from '@/features/alerts/thresholds/helpers';
+import type { ThresholdsTableSectionProps } from '@/features/alerts/thresholds/thresholdsTableSectionProps';
+
+export function ThresholdsTableAgentDisksSection(props: ThresholdsTableSectionProps) {
+ const { state, tableProps } = props;
+
+ return (
+ <Show when={state.hasSection('agentDisks')}>
+ <CollapsibleSection
+ id="agentDisks"
+ title={state.sectionTitles.agentDisks}
+ resourceCount={state.agentDisksWithOverrides().length}
+ collapsed={state.isCollapsed('agentDisks')}
+ onToggle={() => state.toggleSection('agentDisks')}
+ icon={<HardDrive class="w-5 h-5" />}
+ isGloballyDisabled={tableProps.disableAllAgents()}
+ emptyMessage={state.AGENT_DISKS_EMPTY_STATE}
+ >
+ <div ref={state.registerSection('agentDisks')} class="scroll-mt-24">
+ <ResourceTable
+ title=""
+ groupedResources={state.agentDisksGroupedByAgent()}
+ groupHeaderMeta={state.guestGroupHeaderMeta()}
+ columns={['Disk %']}
+ activeAlerts={tableProps.activeAlerts}
+ emptyMessage={state.AGENT_DISKS_FILTER_EMPTY_STATE}
+ onEdit={state.startEditing}
+ onSaveEdit={state.saveEdit}
+ onCancelEdit={state.cancelEdit}
+ onRemoveOverride={state.removeOverride}
+ onToggleDisabled={state.toggleDisabled}
+ showOfflineAlertsColumn={false}
+ editingId={state.editingId}
+ editingThresholds={state.editingThresholds}
+ setEditingThresholds={state.setEditingThresholds}
+ editingNote={state.editingNote}
+ setEditingNote={state.setEditingNote}
+ onBulkEdit={(ids) =>
+ state.handleBulkEdit(ids, [
+ 'CPU %',
+ 'Memory %',
+ 'Disk R MB/s',
+ 'Disk W MB/s',
+ 'Net In MB/s',
+ 'Net Out MB/s',
+ ])
+ }
+ formatMetricValue={formatMetricValue}
+ hasActiveAlert={state.hasActiveAlert}
+ globalDefaults={{ disk: tableProps.agentDefaults.disk }}
+ setGlobalDefaults={(value) => {
+ if (typeof value === 'function') {
+ const nextValue = value({ disk: tableProps.agentDefaults.disk });
+ tableProps.setAgentDefaults((prev) => ({ ...prev, disk: nextValue.disk }));
+ } else {
+ tableProps.setAgentDefaults((prev) => ({ ...prev, disk: value.disk }));
+ }
+ }}
+ setHasUnsavedChanges={tableProps.setHasUnsavedChanges}
+ />
+ </div>
+ </CollapsibleSection>
+ </Show>
+ );
+}
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableAgentsResourcesSection.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableAgentsResourcesSection.tsx
new file mode 100644
index 0000000000..df6c44a234
--- /dev/null
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableAgentsResourcesSection.tsx
@@ -0,0 +1,57 @@
+import { Show } from 'solid-js';
+
+import { ResourceTable } from './ResourceTable';
+import { formatMetricValue } from '@/features/alerts/thresholds/helpers';
+import type { ThresholdsTableSectionProps } from '@/features/alerts/thresholds/thresholdsTableSectionProps';
+
+export function ThresholdsTableAgentsResourcesSection(props: ThresholdsTableSectionProps) {
+ const { state, tableProps } = props;
+
+ return (
+ <Show when={state.hasSection('agents')}>
+ <div ref={state.registerSection('agents')} class="scroll-mt-24">
+ <ResourceTable
+ title={state.sectionTitles.agents}
+ resources={state.agentsWithOverrides()}
+ columns={['CPU %', 'Memory %', 'Disk %', 'Disk Temp °C']}
+ activeAlerts={tableProps.activeAlerts}
+ emptyMessage={state.AGENT_THRESHOLDS_FILTER_EMPTY_STATE}
+ onEdit={state.startEditing}
+ onSaveEdit={state.saveEdit}
+ onCancelEdit={state.cancelEdit}
+ onRemoveOverride={state.removeOverride}
+ onToggleDisabled={state.toggleDisabled}
+ onToggleNodeConnectivity={state.toggleNodeConnectivity}
+ showOfflineAlertsColumn={true}
+ editingId={state.editingId}
+ editingThresholds={state.editingThresholds}
+ setEditingThresholds={state.setEditingThresholds}
+ editingNote={state.editingNote}
+ setEditingNote={state.setEditingNote}
+ onBulkEdit={(ids) =>
+ state.handleBulkEdit(ids, ['CPU %', 'Memory %', 'Disk %', 'Temp °C'])
+ }
+ formatMetricValue={formatMetricValue}
+ hasActiveAlert={state.hasActiveAlert}
+ globalDefaults={tableProps.agentDefaults}
+ setGlobalDefaults={tableProps.setAgentDefaults}
+ setHasUnsavedChanges={tableProps.setHasUnsavedChanges}
+ globalDisableFlag={tableProps.disableAllAgents}
+ onToggleGlobalDisable={() =>
+ tableProps.setDisableAllAgents(!tableProps.disableAllAgents())
+ }
+ globalDisableOfflineFlag={tableProps.disableAllAgentsOffline}
+ onToggleGlobalDisableOffline={() =>
+ tableProps.setDisableAllAgentsOffline(!tableProps.disableAllAgentsOffline())
+ }
+ showDelayColumn={true}
+ globalDelaySeconds={tableProps.timeThresholds().agent}
+ metricDelaySeconds={tableProps.metricTimeThresholds().agent ?? {}}
+ onMetricDelayChange={(metric, value) => state.updateMetricDelay('agent', metric, value)}
+ factoryDefaults={tableProps.factoryAgentDefaults}
+ onResetDefaults={tableProps.resetAgentDefaults}
+ />
+ </div>
+ </Show>
+ );
+}
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableAgentsTab.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableAgentsTab.tsx
index f953f929e9..9769c7cf6e 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableAgentsTab.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableAgentsTab.tsx
@@ -1,124 +1,12 @@
-import { Show } from 'solid-js';
-import HardDrive from 'lucide-solid/icons/hard-drive';
-
-import { ResourceTable } from './ResourceTable';
-import { CollapsibleSection } from './Thresholds/sections/CollapsibleSection';
-import type { ThresholdsTableProps } from '@/features/alerts/thresholds/types';
-import type { ThresholdsTableState } from '@/features/alerts/thresholds/hooks/useThresholdsTableState';
-import { formatMetricValue } from '@/features/alerts/thresholds/helpers';
-
-interface ThresholdsTableTabProps {
- state: ThresholdsTableState;
- tableProps: ThresholdsTableProps;
-}
-
-export function ThresholdsTableAgentsTab(props: ThresholdsTableTabProps) {
- const { state, tableProps } = props;
+import { ThresholdsTableAgentDisksSection } from './ThresholdsTableAgentDisksSection';
+import { ThresholdsTableAgentsResourcesSection } from './ThresholdsTableAgentsResourcesSection';
+import type { ThresholdsTableSectionProps } from '@/features/alerts/thresholds/thresholdsTableSectionProps';
+export function ThresholdsTableAgentsTab(props: ThresholdsTableSectionProps) {
return (
<>
- <Show when={state.hasSection('agents')}>
- <div ref={state.registerSection('agents')} class="scroll-mt-24">
- <ResourceTable
- title={state.sectionTitles.agents}
- resources={state.agentsWithOverrides()}
- columns={['CPU %', 'Memory %', 'Disk %', 'Disk Temp °C']}
- activeAlerts={tableProps.activeAlerts}
- emptyMessage={state.AGENT_THRESHOLDS_FILTER_EMPTY_STATE}
- onEdit={state.startEditing}
- onSaveEdit={state.saveEdit}
- onCancelEdit={state.cancelEdit}
- onRemoveOverride={state.removeOverride}
- onToggleDisabled={state.toggleDisabled}
- onToggleNodeConnectivity={state.toggleNodeConnectivity}
- showOfflineAlertsColumn={true}
- editingId={state.editingId}
- editingThresholds={state.editingThresholds}
- setEditingThresholds={state.setEditingThresholds}
- editingNote={state.editingNote}
- setEditingNote={state.setEditingNote}
- onBulkEdit={(ids) =>
- state.handleBulkEdit(ids, ['CPU %', 'Memory %', 'Disk %', 'Temp °C'])
- }
- formatMetricValue={formatMetricValue}
- hasActiveAlert={state.hasActiveAlert}
- globalDefaults={tableProps.agentDefaults}
- setGlobalDefaults={tableProps.setAgentDefaults}
- setHasUnsavedChanges={tableProps.setHasUnsavedChanges}
- globalDisableFlag={tableProps.disableAllAgents}
- onToggleGlobalDisable={() =>
- tableProps.setDisableAllAgents(!tableProps.disableAllAgents())
- }
- globalDisableOfflineFlag={tableProps.disableAllAgentsOffline}
- onToggleGlobalDisableOffline={() =>
- tableProps.setDisableAllAgentsOffline(!tableProps.disableAllAgentsOffline())
- }
- showDelayColumn={true}
- globalDelaySeconds={tableProps.timeThresholds().agent}
- metricDelaySeconds={tableProps.metricTimeThresholds().agent ?? {}}
- onMetricDelayChange={(metric, value) => state.updateMetricDelay('agent', metric, value)}
- factoryDefaults={tableProps.factoryAgentDefaults}
- onResetDefaults={tableProps.resetAgentDefaults}
- />
- </div>
- </Show>
-
- <Show when={state.hasSection('agentDisks')}>
- <CollapsibleSection
- id="agentDisks"
- title={state.sectionTitles.agentDisks}
- resourceCount={state.agentDisksWithOverrides().length}
- collapsed={state.isCollapsed('agentDisks')}
- onToggle={() => state.toggleSection('agentDisks')}
- icon={<HardDrive class="w-5 h-5" />}
- isGloballyDisabled={tableProps.disableAllAgents()}
- emptyMessage={state.AGENT_DISKS_EMPTY_STATE}
- >
- <div ref={state.registerSection('agentDisks')} class="scroll-mt-24">
- <ResourceTable
- title=""
- groupedResources={state.agentDisksGroupedByAgent()}
- groupHeaderMeta={state.guestGroupHeaderMeta()}
- columns={['Disk %']}
- activeAlerts={tableProps.activeAlerts}
- emptyMessage={state.AGENT_DISKS_FILTER_EMPTY_STATE}
- onEdit={state.startEditing}
- onSaveEdit={state.saveEdit}
- onCancelEdit={state.cancelEdit}
- onRemoveOverride={state.removeOverride}
- onToggleDisabled={state.toggleDisabled}
- showOfflineAlertsColumn={false}
- editingId={state.editingId}
- editingThresholds={state.editingThresholds}
- setEditingThresholds={state.setEditingThresholds}
- editingNote={state.editingNote}
- setEditingNote={state.setEditingNote}
- onBulkEdit={(ids) =>
- state.handleBulkEdit(ids, [
- 'CPU %',
- 'Memory %',
- 'Disk R MB/s',
- 'Disk W MB/s',
- 'Net In MB/s',
- 'Net Out MB/s',
- ])
- }
- formatMetricValue={formatMetricValue}
- hasActiveAlert={state.hasActiveAlert}
- globalDefaults={{ disk: tableProps.agentDefaults.disk }}
- setGlobalDefaults={(value) => {
- if (typeof value === 'function') {
- const nextValue = value({ disk: tableProps.agentDefaults.disk });
- tableProps.setAgentDefaults((prev) => ({ ...prev, disk: nextValue.disk }));
- } else {
- tableProps.setAgentDefaults((prev) => ({ ...prev, disk: value.disk }));
- }
- }}
- setHasUnsavedChanges={tableProps.setHasUnsavedChanges}
- />
- </div>
- </CollapsibleSection>
- </Show>
+ <ThresholdsTableAgentsResourcesSection {...props} />
+ <ThresholdsTableAgentDisksSection {...props} />
</>
);
}
diff --git a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
index 1586a17056..acb2262be9 100644
--- a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
+++ b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
@@ -28,7 +28,9 @@ import alertScheduleTabSource from '@/features/alerts/tabs/ScheduleTab.tsx?raw';
import alertThresholdsTabSource from '@/features/alerts/tabs/ThresholdsTab.tsx?raw';
import recentAlertsPanelSource from '@/components/Alerts/RecentAlertsPanel.tsx?raw';
import thresholdsTableSource from '@/components/Alerts/ThresholdsTable.tsx?raw';
+import thresholdsTableAgentDisksSectionSource from '@/components/Alerts/ThresholdsTableAgentDisksSection.tsx?raw';
import thresholdsTableAgentsTabSource from '@/components/Alerts/ThresholdsTableAgentsTab.tsx?raw';
+import thresholdsTableAgentsResourcesSectionSource from '@/components/Alerts/ThresholdsTableAgentsResourcesSection.tsx?raw';
import thresholdsTableDockerContainersSectionSource from '@/components/Alerts/ThresholdsTableDockerContainersSection.tsx?raw';
import thresholdsTableDockerHostsSectionSource from '@/components/Alerts/ThresholdsTableDockerHostsSection.tsx?raw';
import thresholdsTableDockerIgnoredPrefixesSectionSource from '@/components/Alerts/ThresholdsTableDockerIgnoredPrefixesSection.tsx?raw';
@@ -437,7 +439,16 @@ describe('tab path helpers', () => {
expect(thresholdsTablePMGTabSource).toContain('export function ThresholdsTablePMGTab');
expect(thresholdsTablePMGTabSource).toContain('pmgGlobalDefaults()');
expect(thresholdsTableAgentsTabSource).toContain('export function ThresholdsTableAgentsTab');
- expect(thresholdsTableAgentsTabSource).toContain('agentDisksGroupedByAgent()');
+ expect(thresholdsTableAgentsTabSource).toContain('ThresholdsTableAgentsResourcesSection');
+ expect(thresholdsTableAgentsTabSource).toContain('ThresholdsTableAgentDisksSection');
+ expect(thresholdsTableAgentsTabSource).not.toContain('agentDisksGroupedByAgent()');
+ expect(thresholdsTableAgentsResourcesSectionSource).toContain(
+ 'export function ThresholdsTableAgentsResourcesSection',
+ );
+ expect(thresholdsTableAgentDisksSectionSource).toContain(
+ 'export function ThresholdsTableAgentDisksSection',
+ );
+ expect(thresholdsTableAgentDisksSectionSource).toContain('agentDisksGroupedByAgent()');
expect(thresholdsTableDockerTabSource).toContain('export function ThresholdsTableDockerTab');
expect(thresholdsTableDockerTabSource).toContain('ThresholdsTableDockerIgnoredPrefixesSection');
expect(thresholdsTableDockerTabSource).toContain('ThresholdsTableDockerServiceGapSection');
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index f7f0f726a9..9ddee88d8c 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -350,7 +350,9 @@ import alertHistoryTabSource from '@/features/alerts/tabs/HistoryTab.tsx?raw';
import alertScheduleTabSource from '@/features/alerts/tabs/ScheduleTab.tsx?raw';
import alertThresholdsTabSource from '@/features/alerts/tabs/ThresholdsTab.tsx?raw';
import thresholdsTableSource from '@/components/Alerts/ThresholdsTable.tsx?raw';
+import thresholdsTableAgentDisksSectionSource from '@/components/Alerts/ThresholdsTableAgentDisksSection.tsx?raw';
import thresholdsTableAgentsTabSource from '@/components/Alerts/ThresholdsTableAgentsTab.tsx?raw';
+import thresholdsTableAgentsResourcesSectionSource from '@/components/Alerts/ThresholdsTableAgentsResourcesSection.tsx?raw';
import thresholdsTableDockerContainersSectionSource from '@/components/Alerts/ThresholdsTableDockerContainersSection.tsx?raw';
import thresholdsTableDockerHostsSectionSource from '@/components/Alerts/ThresholdsTableDockerHostsSection.tsx?raw';
import thresholdsTableDockerIgnoredPrefixesSectionSource from '@/components/Alerts/ThresholdsTableDockerIgnoredPrefixesSection.tsx?raw';
@@ -2980,7 +2982,16 @@ describe('frontend resource type boundaries', () => {
expect(thresholdsTablePMGTabSource).toContain('export function ThresholdsTablePMGTab');
expect(thresholdsTablePMGTabSource).toContain('pmgGlobalDefaults()');
expect(thresholdsTableAgentsTabSource).toContain('export function ThresholdsTableAgentsTab');
- expect(thresholdsTableAgentsTabSource).toContain('agentDisksGroupedByAgent()');
+ expect(thresholdsTableAgentsTabSource).toContain('ThresholdsTableAgentsResourcesSection');
+ expect(thresholdsTableAgentsTabSource).toContain('ThresholdsTableAgentDisksSection');
+ expect(thresholdsTableAgentsTabSource).not.toContain('agentDisksGroupedByAgent()');
+ expect(thresholdsTableAgentsResourcesSectionSource).toContain(
+ 'export function ThresholdsTableAgentsResourcesSection',
+ );
+ expect(thresholdsTableAgentDisksSectionSource).toContain(
+ 'export function ThresholdsTableAgentDisksSection',
+ );
+ expect(thresholdsTableAgentDisksSectionSource).toContain('agentDisksGroupedByAgent()');
expect(thresholdsTableDockerTabSource).toContain('export function ThresholdsTableDockerTab');
expect(thresholdsTableDockerTabSource).toContain('ThresholdsTableDockerIgnoredPrefixesSection');
expect(thresholdsTableDockerTabSource).toContain('ThresholdsTableDockerServiceGapSection');