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.

Expose per-resource alert delay controls (#1497)

[email protected]69cfce92d31b
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index 33fe2d96ce..232a77fc2b 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -1401,6 +1401,15 @@ coverage, duplicate and delayed reports, wall-clock changes, suppression
reset, migration/restart continuity, backup hard-cap behavior, preview
immutability, and first-match lifecycle identity.
+The thresholds resource rows expose that same policy owner directly through a
+per-resource alert-delay action. The action carries the canonical resource id
+and the first supported CPU, memory, or disk signal into the versioned
+intent-policy editor, expands it, and leaves persistence and inheritance with
+`/api/alerts/intent-policies`. Resources without a supported metric open on
+`state.offline`. Threshold rows must not create a parallel delay field in the
+legacy threshold override document or save intent changes through the
+threshold-config endpoint.
+
### Provider-observed storage and workload incident lifecycle
Provider observations use one stable alert identity composed from provider,
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 6c26b144ca..693a5dc3ce 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -4758,6 +4758,14 @@ rendering remains in
`frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx`, and shared
metric normalization remains in
`frontend-modern/src/components/Alerts/alertResourceTableModel.ts`.
+Desktop rows and mobile resource cards also share one alert-delay handoff:
+their timer action emits the canonical resource id plus the first supported
+CPU, memory, or disk signal, while `ThresholdsTab.tsx` owns selection state and
+`AlertIntentPolicyPanel.tsx` owns expansion, scrolling, field inheritance, and
+API persistence. The action remains available for non-threshold-editable rows
+and falls back to `state.offline` when no supported metric exists. New
+platform threshold sections must forward this shared handoff rather than add a
+platform-local delay editor or a second intent-policy transport.
`frontend-modern/src/features/alerts/useAlertDestinationsTabState.ts` now owns
destination test actions, retry orchestration, and delivery-health loading while
`frontend-modern/src/features/alerts/tabs/DestinationsTab.tsx` stays the
diff --git a/frontend-modern/src/components/Alerts/AlertResourceTableDesktop.tsx b/frontend-modern/src/components/Alerts/AlertResourceTableDesktop.tsx
index 3c6e0ba596..dd846d9f7c 100644
--- a/frontend-modern/src/components/Alerts/AlertResourceTableDesktop.tsx
+++ b/frontend-modern/src/components/Alerts/AlertResourceTableDesktop.tsx
@@ -519,6 +519,7 @@ export function AlertResourceTableDesktop(props: AlertResourceTableDesktopProps)
onSetOfflineState={props.table.onSetOfflineState}
onToggleBackup={props.table.onToggleBackup}
onToggleSnapshot={props.table.onToggleSnapshot}
+ onConfigureResourceIntent={props.table.onConfigureResourceIntent}
globalDisableFlag={props.table.globalDisableFlag}
globalDisableOfflineFlag={props.table.globalDisableOfflineFlag}
editingNote={props.table.editingNote}
@@ -560,6 +561,7 @@ export function AlertResourceTableDesktop(props: AlertResourceTableDesktopProps)
onSetOfflineState={props.table.onSetOfflineState}
onToggleBackup={props.table.onToggleBackup}
onToggleSnapshot={props.table.onToggleSnapshot}
+ onConfigureResourceIntent={props.table.onConfigureResourceIntent}
globalDisableFlag={props.table.globalDisableFlag}
globalDisableOfflineFlag={props.table.globalDisableOfflineFlag}
editingNote={props.table.editingNote}
diff --git a/frontend-modern/src/components/Alerts/AlertResourceTableMobile.tsx b/frontend-modern/src/components/Alerts/AlertResourceTableMobile.tsx
index 472555c73b..f3915398cc 100644
--- a/frontend-modern/src/components/Alerts/AlertResourceTableMobile.tsx
+++ b/frontend-modern/src/components/Alerts/AlertResourceTableMobile.tsx
@@ -2,6 +2,7 @@ import { For, Show } from 'solid-js';
import Check from 'lucide-solid/icons/check';
import Pencil from 'lucide-solid/icons/pencil';
import RotateCcw from 'lucide-solid/icons/rotate-ccw';
+import Timer from 'lucide-solid/icons/timer';
import X from 'lucide-solid/icons/x';
import { ActionIconButton } from '@/components/shared/Button';
@@ -296,6 +297,28 @@ export function AlertResourceTableMobile(props: AlertResourceTableMobileProps) {
<Pencil class="w-4 h-4" aria-hidden="true" />
</ActionIconButton>
</Show>
+ <Show when={!isEditing() && props.table.onConfigureResourceIntent}>
+ <ActionIconButton
+ onClick={() => {
+ const preferredMetric = ['cpu', 'memory', 'disk'].find(
+ (metric) =>
+ props.table.columns.some(
+ (column) => normalizeAlertResourceMetricKey(column) === metric,
+ ) && alertResourceSupportsMetric(resource.type, metric),
+ );
+ props.table.onConfigureResourceIntent?.(
+ resource.id,
+ preferredMetric ? `metric.${preferredMetric}` : 'state.offline',
+ );
+ }}
+ label={`Configure alert delay for ${getAlertResourceLabel(resource)}`}
+ title="Configure individual alert delay"
+ tone="neutral"
+ size="sm"
+ >
+ <Timer class="w-4 h-4" aria-hidden="true" />
+ </ActionIconButton>
+ </Show>
<Show when={isEditing()}>
<ActionIconButton
onClick={cancelEditing}
diff --git a/frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx b/frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx
index f5d6c72920..747d0f4a0a 100644
--- a/frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx
+++ b/frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx
@@ -1,6 +1,7 @@
import { For, Show } from 'solid-js';
import Pencil from 'lucide-solid/icons/pencil';
import RotateCcw from 'lucide-solid/icons/rotate-ccw';
+import Timer from 'lucide-solid/icons/timer';
import X from 'lucide-solid/icons/x';
import { ActionIconButton } from '@/components/shared/Button';
@@ -38,6 +39,7 @@ import {
type AlertResourceThresholdMap,
} from './alertResourceTableModel';
import type { Alert } from '@/types/api';
+import type { AlertIntentSignal } from '@/api/alertIntentPolicies';
import type { Resource } from '@/features/alerts/thresholds/tableTypes';
type OfflineState = 'off' | 'warning' | 'critical';
@@ -67,6 +69,7 @@ interface AlertResourceTableRowProps {
onSetOfflineState?: (resourceId: string, state: OfflineState) => void;
onToggleBackup?: (resourceId: string, forceState?: boolean) => void;
onToggleSnapshot?: (resourceId: string, forceState?: boolean) => void;
+ onConfigureResourceIntent?: (resourceId: string, signal: AlertIntentSignal) => void;
globalDisableFlag?: () => boolean;
globalDisableOfflineFlag?: () => boolean;
editingNote: () => string;
@@ -91,6 +94,17 @@ export function AlertResourceTableRow(props: AlertResourceTableRowProps) {
isEditing(),
);
const isOverridden = (metric: string) => isAlertResourceMetricOverridden(props.resource, metric);
+ const preferredIntentSignal = (): AlertIntentSignal => {
+ for (const metric of ['cpu', 'memory', 'disk'] as const) {
+ if (
+ props.columns.some((column) => normalizeAlertResourceMetricKey(column) === metric) &&
+ alertResourceSupportsMetric(props.resource.type, metric)
+ ) {
+ return `metric.${metric}`;
+ }
+ }
+ return 'state.offline';
+ };
const getThresholds = (): AlertResourceThresholdMap => thresholds();
@@ -595,10 +609,11 @@ export function AlertResourceTableRow(props: AlertResourceTableRowProps) {
props.resource.hasOverride ||
((props.resource.type === 'agent' || props.resource.type === 'dockerHost') &&
props.resource.disableConnectivity);
+ const showIntent = typeof props.onConfigureResourceIntent === 'function';
return (
<Show
- when={showEdit || showRevert}
+ when={showEdit || showRevert || showIntent}
fallback={
<span class="text-xs text-muted" aria-hidden="true">
—
@@ -616,6 +631,22 @@ export function AlertResourceTableRow(props: AlertResourceTableRowProps) {
<Pencil class="w-4 h-4" aria-hidden="true" />
</ActionIconButton>
</Show>
+ <Show when={showIntent}>
+ <ActionIconButton
+ onClick={() =>
+ props.onConfigureResourceIntent?.(
+ props.resource.id,
+ preferredIntentSignal(),
+ )
+ }
+ label={`Configure alert delay for ${resourceLabel()}`}
+ title="Configure individual alert delay"
+ tone="neutral"
+ size="xs"
+ >
+ <Timer class="w-4 h-4" aria-hidden="true" />
+ </ActionIconButton>
+ </Show>
<Show when={showRevert}>
<ActionIconButton
onClick={() => props.onRemoveOverride(props.resource.id)}
diff --git a/frontend-modern/src/components/Alerts/ResourceTable.test.tsx b/frontend-modern/src/components/Alerts/ResourceTable.test.tsx
index 7d77c65f5c..2829cc2511 100644
--- a/frontend-modern/src/components/Alerts/ResourceTable.test.tsx
+++ b/frontend-modern/src/components/Alerts/ResourceTable.test.tsx
@@ -1472,6 +1472,34 @@ describe('ResourceTable', () => {
});
describe('delay settings', () => {
+ it('opens the canonical per-resource delay editor from the resource row', () => {
+ const onConfigureResourceIntent = vi.fn();
+ const props = makeProps({
+ resources: [makeResource({ id: 'vm-1', name: 'Database VM' })],
+ columns: ['CPU %', 'Memory %'],
+ onConfigureResourceIntent,
+ });
+ render(() => <ResourceTable {...props} />);
+
+ fireEvent.click(screen.getByLabelText('Configure alert delay for Database VM'));
+
+ expect(onConfigureResourceIntent).toHaveBeenCalledWith('vm-1', 'metric.cpu');
+ });
+
+ it('falls back to the offline signal when the row has no supported metric', () => {
+ const onConfigureResourceIntent = vi.fn();
+ const props = makeProps({
+ resources: [makeResource({ id: 'docker-host-1', name: 'Docker Host', type: 'dockerHost' })],
+ columns: [],
+ onConfigureResourceIntent,
+ });
+ render(() => <ResourceTable {...props} />);
+
+ fireEvent.click(screen.getByLabelText('Configure alert delay for Docker Host'));
+
+ expect(onConfigureResourceIntent).toHaveBeenCalledWith('docker-host-1', 'state.offline');
+ });
+
it('shows delay toggle button when showDelayColumn and onMetricDelayChange are provided', () => {
const props = makeProps({
showDelayColumn: true,
diff --git a/frontend-modern/src/components/Alerts/ResourceTable.tsx b/frontend-modern/src/components/Alerts/ResourceTable.tsx
index 06b1c3e696..fcdb701cbc 100644
--- a/frontend-modern/src/components/Alerts/ResourceTable.tsx
+++ b/frontend-modern/src/components/Alerts/ResourceTable.tsx
@@ -2,6 +2,7 @@ import { Show } from 'solid-js';
import X from 'lucide-solid/icons/x';
import { useBreakpoint } from '@/hooks/useBreakpoint';
import type { Alert } from '@/types/api';
+import type { AlertIntentSignal } from '@/api/alertIntentPolicies';
import {
ALERT_BULK_EDIT_CLEAR_LABEL,
getAlertBulkEditOpenLabel,
@@ -16,6 +17,7 @@ export type { GroupHeaderMeta, Resource } from '@/features/alerts/thresholds/tab
export interface ResourceTableProps {
title: string;
+ onConfigureResourceIntent?: (resourceId: string, signal: AlertIntentSignal) => void;
resources?: Resource[];
groupedResources?: Record<string, Resource[]>;
columns: string[];
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableAgentDisksSection.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableAgentDisksSection.tsx
index 5f893b086e..80eef07708 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableAgentDisksSection.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableAgentDisksSection.tsx
@@ -24,6 +24,7 @@ export function ThresholdsTableAgentDisksSection(props: ThresholdsTableSectionPr
<div ref={state.registerSection('agentDisks')} class="scroll-mt-24">
<ResourceTable
title=""
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
groupedResources={state.agentDisksGroupedByAgent()}
groupHeaderMeta={state.agentGroupHeaderMeta()}
columns={['Disk %']}
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableAgentsResourcesSection.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableAgentsResourcesSection.tsx
index c1444f6996..15efb16c97 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableAgentsResourcesSection.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableAgentsResourcesSection.tsx
@@ -19,6 +19,7 @@ export function ThresholdsTableAgentsResourcesSection(props: ThresholdsTableSect
<div ref={state.registerSection('agents')} class="scroll-mt-24">
<ResourceTable
title={state.sectionTitles.agents}
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
resources={state.agentsWithOverrides()}
columns={['CPU %', 'Memory %', 'Disk %', 'Disk Temp °C']}
activeAlerts={tableProps.activeAlerts}
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableDockerContainersSection.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableDockerContainersSection.tsx
index be7ad97a86..15bfdca610 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableDockerContainersSection.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableDockerContainersSection.tsx
@@ -12,6 +12,7 @@ export function ThresholdsTableDockerContainersSection(props: ThresholdsTableSec
<div ref={state.registerSection('dockerContainers')} class="scroll-mt-24">
<ResourceTable
title={state.sectionTitles.dockerContainers}
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
groupedResources={state.dockerContainersGroupedByHost()}
groupHeaderMeta={state.dockerHostGroupMeta()}
columns={[
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableDockerHostsSection.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableDockerHostsSection.tsx
index 34ae54cc90..478af773c0 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableDockerHostsSection.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableDockerHostsSection.tsx
@@ -12,6 +12,7 @@ export function ThresholdsTableDockerHostsSection(props: ThresholdsTableSectionP
<div ref={state.registerSection('dockerHosts')} class="scroll-mt-24">
<ResourceTable
title={state.sectionTitles.dockerHosts}
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
resources={state.dockerHostsWithOverrides()}
columns={[]}
activeAlerts={tableProps.activeAlerts}
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableKubernetesTab.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableKubernetesTab.tsx
index 937a70c8a5..34876a7331 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableKubernetesTab.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableKubernetesTab.tsx
@@ -50,6 +50,7 @@ function KubernetesResourceSection(
<div ref={state.registerSection(props.id)} class="scroll-mt-24">
<ResourceTable
title=""
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
resources={props.resources()}
columns={props.columns}
activeAlerts={tableProps.activeAlerts}
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxGuestsSection.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxGuestsSection.tsx
index 3bf15be73b..71c161d74e 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxGuestsSection.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxGuestsSection.tsx
@@ -24,6 +24,7 @@ export function ThresholdsTableProxmoxGuestsSection(props: ThresholdsTableSectio
<div ref={state.registerSection('guests')} class="scroll-mt-24">
<ResourceTable
title=""
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
groupedResources={state.guestsGroupedByNode()}
groupHeaderMeta={state.guestGroupHeaderMeta()}
columns={[
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxNodesSection.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxNodesSection.tsx
index f026d9f774..e73984b29f 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxNodesSection.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxNodesSection.tsx
@@ -24,6 +24,7 @@ export function ThresholdsTableProxmoxNodesSection(props: ThresholdsTableSection
<div ref={state.registerSection('nodes')} class="scroll-mt-24">
<ResourceTable
title=""
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
resources={state.nodesWithOverrides()}
columns={['CPU %', 'Memory %', 'Disk %', 'Temp °C']}
activeAlerts={tableProps.activeAlerts}
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxPBSSection.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxPBSSection.tsx
index f1a0e59563..3a3f5d5bb2 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxPBSSection.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxPBSSection.tsx
@@ -24,6 +24,7 @@ export function ThresholdsTableProxmoxPBSSection(props: ThresholdsTableSectionPr
<div id="threshold-section-pbs" ref={state.registerSection('pbs')} class="scroll-mt-24">
<ResourceTable
title=""
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
resources={state.pbsServersWithOverrides()}
columns={['CPU %', 'Memory %']}
activeAlerts={tableProps.activeAlerts}
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxPMGSection.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxPMGSection.tsx
index bdb0d5abbe..6bda08afce 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxPMGSection.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxPMGSection.tsx
@@ -24,6 +24,7 @@ export function ThresholdsTableProxmoxPMGSection(props: ThresholdsTableSectionPr
<div id="threshold-section-pmg" ref={state.registerSection('pmg')} class="scroll-mt-24">
<ResourceTable
title=""
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
resources={state.pmgServersWithOverrides()}
columns={[
'Queue Warn',
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxStorageSection.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxStorageSection.tsx
index 9314066cdc..bfdb4383e3 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxStorageSection.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxStorageSection.tsx
@@ -24,6 +24,7 @@ export function ThresholdsTableProxmoxStorageSection(props: ThresholdsTableSecti
<div ref={state.registerSection('storage')} class="scroll-mt-24">
<ResourceTable
title=""
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
groupedResources={state.storageGroupedByNode()}
groupHeaderMeta={state.guestGroupHeaderMeta()}
columns={['Usage %']}
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableTrueNASTab.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableTrueNASTab.tsx
index 3a17135d78..72a5e48ea4 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableTrueNASTab.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableTrueNASTab.tsx
@@ -57,6 +57,7 @@ function TrueNASResourceSection(
<div ref={state.registerSection(props.id)} class="scroll-mt-24">
<ResourceTable
title=""
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
resources={props.resources()}
columns={props.columns}
activeAlerts={tableProps.activeAlerts}
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableVMwareTab.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableVMwareTab.tsx
index 8ff273cc15..46968dfd50 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableVMwareTab.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableVMwareTab.tsx
@@ -64,6 +64,7 @@ function VMwareResourceSection(
<div ref={state.registerSection(props.id)} class="scroll-mt-24">
<ResourceTable
title=""
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
resources={props.resources()}
columns={props.columns}
activeAlerts={tableProps.activeAlerts}
diff --git a/frontend-modern/src/features/alerts/AlertIntentPolicyPanel.tsx b/frontend-modern/src/features/alerts/AlertIntentPolicyPanel.tsx
index 372541cc23..75f4bbd457 100644
--- a/frontend-modern/src/features/alerts/AlertIntentPolicyPanel.tsx
+++ b/frontend-modern/src/features/alerts/AlertIntentPolicyPanel.tsx
@@ -60,7 +60,16 @@ const ruleFor = (
signal: AlertIntentSignal,
): AlertIntentRule => document?.resources?.[resourceId]?.[signal] ?? {};
-export function AlertIntentPolicyPanel(props: { resources: readonly Resource[] }) {
+export interface AlertIntentPolicySelectionTarget {
+ resourceId: string;
+ signal: AlertIntentSignal;
+ requestId: number;
+}
+
+export function AlertIntentPolicyPanel(props: {
+ resources: readonly Resource[];
+ selectionTarget?: AlertIntentPolicySelectionTarget | null;
+}) {
const [expanded, setExpanded] = createSignal(false);
const [document, setDocument] = createSignal<AlertIntentPolicyDocument | null>(null);
const [loading, setLoading] = createSignal(false);
@@ -98,6 +107,7 @@ export function AlertIntentPolicyPanel(props: { resources: readonly Resource[] }
const [previewBackupActive, setPreviewBackupActive] = createSignal(false);
const [previewing, setPreviewing] = createSignal(false);
const [preview, setPreview] = createSignal<AlertIntentPolicyPreview | null>(null);
+ let panelElement: HTMLDivElement | undefined;
const selectedResource = createMemo(() =>
sortedResources().find((resource) => resource.id === resourceId()),
@@ -144,6 +154,19 @@ export function AlertIntentPolicyPanel(props: { resources: readonly Resource[] }
}
});
+ createEffect(() => {
+ const target = props.selectionTarget;
+ if (!target) return;
+ const requestId = target.requestId;
+ setResourceId(target.resourceId);
+ setSignal(target.signal);
+ setExpanded(true);
+ queueMicrotask(() => {
+ if (props.selectionTarget?.requestId !== requestId) return;
+ panelElement?.scrollIntoView?.({ behavior: 'smooth', block: 'start' });
+ });
+ });
+
createEffect(() => {
const current = ruleFor(document(), resourceId(), signal());
setOverrideGrace(current.graceSeconds === undefined ? '' : String(current.graceSeconds));
@@ -340,7 +363,12 @@ export function AlertIntentPolicyPanel(props: { resources: readonly Resource[] }
);
return (
- <Card padding="md" class="space-y-4">
+ <Card
+ id="alert-intent-policy-panel"
+ ref={panelElement}
+ padding="md"
+ class="space-y-4 scroll-mt-24"
+ >
<div class="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
<div>
<h2 class="text-base font-semibold text-base-content">Alert intent & grace</h2>
diff --git a/frontend-modern/src/features/alerts/__tests__/AlertIntentPolicyPanel.test.tsx b/frontend-modern/src/features/alerts/__tests__/AlertIntentPolicyPanel.test.tsx
index 65a1aa2870..00f2b7b735 100644
--- a/frontend-modern/src/features/alerts/__tests__/AlertIntentPolicyPanel.test.tsx
+++ b/frontend-modern/src/features/alerts/__tests__/AlertIntentPolicyPanel.test.tsx
@@ -79,6 +79,23 @@ describe('AlertIntentPolicyPanel', () => {
expect(await screen.findByLabelText('Resource')).toHaveValue(resource.id);
});
+ it('opens directly on a row-selected resource and signal', async () => {
+ render(() => (
+ <AlertIntentPolicyPanel
+ resources={[resource]}
+ selectionTarget={{
+ resourceId: resource.id,
+ signal: 'metric.memory',
+ requestId: 1,
+ }}
+ />
+ ));
+
+ expect(await screen.findByRole('button', { name: 'Hide policies' })).toBeInTheDocument();
+ expect(screen.getByLabelText('Resource')).toHaveValue(resource.id);
+ expect(screen.getByLabelText('Signal')).toHaveValue('metric.memory');
+ });
+
it('saves field-level resource overrides without disabling inherited policy', async () => {
render(() => <AlertIntentPolicyPanel resources={[resource]} />);
diff --git a/frontend-modern/src/features/alerts/__tests__/ThresholdsTab.test.tsx b/frontend-modern/src/features/alerts/__tests__/ThresholdsTab.test.tsx
index ff02825618..aafb35681d 100644
--- a/frontend-modern/src/features/alerts/__tests__/ThresholdsTab.test.tsx
+++ b/frontend-modern/src/features/alerts/__tests__/ThresholdsTab.test.tsx
@@ -1,4 +1,4 @@
-import { render, cleanup } from '@solidjs/testing-library';
+import { render, cleanup, waitFor } from '@solidjs/testing-library';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { ThresholdsTab } from '../tabs/ThresholdsTab';
@@ -271,6 +271,7 @@ const buildProps = (): ThresholdsTabProps =>
describe('ThresholdsTab', () => {
beforeEach(() => {
captureThresholdsTableProps.mockReset();
+ captureIntentPolicyProps.mockReset();
});
afterEach(() => {
@@ -290,4 +291,28 @@ describe('ThresholdsTab', () => {
expect(typeof props.guestDefaults).toBe('object');
expect(typeof props.dockerDefaults).toBe('object');
});
+
+ it('routes a resource-row delay action into the canonical intent policy panel', async () => {
+ render(() => <ThresholdsTab {...buildProps()} />);
+
+ const tableProps = captureThresholdsTableProps.mock.calls[0][0] as {
+ onConfigureResourceIntent: (resourceId: string, signal: string) => void;
+ };
+ tableProps.onConfigureResourceIntent('vm-canonical', 'metric.memory');
+
+ await waitFor(() => {
+ const panelProps = captureIntentPolicyProps.mock.calls.at(-1)?.[0] as {
+ selectionTarget?: {
+ resourceId: string;
+ signal: string;
+ requestId: number;
+ };
+ };
+ expect(panelProps.selectionTarget).toEqual({
+ resourceId: 'vm-canonical',
+ signal: 'metric.memory',
+ requestId: 1,
+ });
+ });
+ });
});
diff --git a/frontend-modern/src/features/alerts/tabs/ThresholdsTab.tsx b/frontend-modern/src/features/alerts/tabs/ThresholdsTab.tsx
index fd56dcd330..5e40292543 100644
--- a/frontend-modern/src/features/alerts/tabs/ThresholdsTab.tsx
+++ b/frontend-modern/src/features/alerts/tabs/ThresholdsTab.tsx
@@ -1,13 +1,35 @@
+import { createSignal } from 'solid-js';
import { ThresholdsTable } from '@/components/Alerts/ThresholdsTable';
-import { AlertIntentPolicyPanel } from '../AlertIntentPolicyPanel';
+import {
+ AlertIntentPolicyPanel,
+ type AlertIntentPolicySelectionTarget,
+} from '../AlertIntentPolicyPanel';
+import type { AlertIntentSignal } from '@/api/alertIntentPolicies';
import type { ThresholdsTabProps } from '../thresholds/thresholdsTabModel';
export function ThresholdsTab(props: ThresholdsTabProps) {
+ const [intentSelectionTarget, setIntentSelectionTarget] =
+ createSignal<AlertIntentPolicySelectionTarget | null>(null);
+ let intentSelectionRequest = 0;
+
+ const configureResourceIntent = (resourceId: string, signal: AlertIntentSignal) => {
+ intentSelectionRequest += 1;
+ setIntentSelectionTarget({
+ resourceId,
+ signal,
+ requestId: intentSelectionRequest,
+ });
+ };
+
return (
<div class="space-y-4">
- <AlertIntentPolicyPanel resources={props.allResources} />
+ <AlertIntentPolicyPanel
+ resources={props.allResources}
+ selectionTarget={intentSelectionTarget()}
+ />
<ThresholdsTable
+ onConfigureResourceIntent={configureResourceIntent}
overrides={props.overrides}
setOverrides={props.setOverrides}
rawOverridesConfig={props.rawOverridesConfig}
diff --git a/frontend-modern/src/features/alerts/thresholds/types.ts b/frontend-modern/src/features/alerts/thresholds/types.ts
index ce0fe3ec57..a3270b7bd0 100644
--- a/frontend-modern/src/features/alerts/thresholds/types.ts
+++ b/frontend-modern/src/features/alerts/thresholds/types.ts
@@ -6,6 +6,7 @@ import type {
BackupAlertConfig,
} from '@/types/alerts';
import type { Resource } from '@/types/resource';
+import type { AlertIntentSignal } from '@/api/alertIntentPolicies';
export type OverrideType =
| 'guest'
@@ -73,6 +74,7 @@ export interface SimpleThresholds {
}
export interface ThresholdsTableProps {
+ onConfigureResourceIntent?: (resourceId: string, signal: AlertIntentSignal) => void;
overrides: () => Override[];
setOverrides: (overrides: Override[]) => void;
rawOverridesConfig: () => Record<string, RawOverrideConfig>;