diff --git a/frontend-modern/src/components/Alerts/ResourceTable.tsx b/frontend-modern/src/components/Alerts/ResourceTable.tsx index f94e80a02..1416ce626 100644 --- a/frontend-modern/src/components/Alerts/ResourceTable.tsx +++ b/frontend-modern/src/components/Alerts/ResourceTable.tsx @@ -13,6 +13,7 @@ interface ResourceTableProps { onRemoveOverride: (resourceId: string) => void; onToggleDisabled?: (resourceId: string) => void; onToggleNodeConnectivity?: (nodeId: string) => void; + onBatchToggleAlerts?: (resourceIds: string[], enable: boolean) => void; editingId: () => string | null; editingThresholds: () => Record; setEditingThresholds: (value: Record) => void; @@ -21,6 +22,28 @@ interface ResourceTableProps { } export function ResourceTable(props: ResourceTableProps) { + // Get all resource IDs for batch operations + const getAllResourceIds = () => { + if (props.groupedResources) { + return Object.values(props.groupedResources).flat().map(r => r.id); + } + return props.resources?.map(r => r.id) || []; + }; + + // Check if all alerts are disabled + const areAllAlertsDisabled = () => { + const resources = props.groupedResources ? Object.values(props.groupedResources).flat() : (props.resources || []); + if (resources.length === 0) return false; + + // For nodes, check disableConnectivity instead of disabled + if (props.title === 'Proxmox Nodes') { + return resources.every(r => r.disableConnectivity === true); + } + + // For guests and storage, check disabled flag + return resources.every(r => r.disabled === true); + }; + const MetricValueWithHeat = (metricProps: { resourceId: string; metric: string; @@ -70,7 +93,50 @@ export function ResourceTable(props: ResourceTableProps) { )} - Alerts +
+ Alerts + 0}> + + +
Actions diff --git a/frontend-modern/src/components/Alerts/ThresholdsTable.tsx b/frontend-modern/src/components/Alerts/ThresholdsTable.tsx index e7f8a58e1..c5e5db2c3 100644 --- a/frontend-modern/src/components/Alerts/ThresholdsTable.tsx +++ b/frontend-modern/src/components/Alerts/ThresholdsTable.tsx @@ -425,7 +425,7 @@ export function ThresholdsTable(props: ThresholdsTableProps) { props.setHasUnsavedChanges(true); }; - const toggleDisabled = (resourceId: string) => { + const toggleDisabled = (resourceId: string, forceState?: boolean) => { // Flatten grouped guests to find the resource const allGuests = Object.values(guestsGroupedByNode()).flat(); const allResources = [...allGuests, ...storageWithOverrides()]; @@ -437,7 +437,7 @@ export function ThresholdsTable(props: ThresholdsTableProps) { // Determine the current disabled state - check the resource's current state, not the override const currentDisabledState = resource.disabled; - const newDisabledState = !currentDisabledState; + const newDisabledState = forceState !== undefined ? forceState : !currentDisabledState; // Clean the thresholds to exclude 'disabled' if it got in there const cleanThresholds: any = { ...(existingOverride?.thresholds || {}) }; @@ -500,7 +500,7 @@ export function ThresholdsTable(props: ThresholdsTableProps) { props.setHasUnsavedChanges(true); }; - const toggleNodeConnectivity = (nodeId: string) => { + const toggleNodeConnectivity = (nodeId: string, forceState?: boolean) => { const node = nodesWithOverrides().find(r => r.id === nodeId); if (!node || node.type !== 'node') return; @@ -509,7 +509,7 @@ export function ThresholdsTable(props: ThresholdsTableProps) { // Determine the current state const currentDisableConnectivity = existingOverride?.disableConnectivity || false; - const newDisableConnectivity = !currentDisableConnectivity; + const newDisableConnectivity = forceState !== undefined ? forceState : !currentDisableConnectivity; // Clean the thresholds to exclude any unwanted fields const cleanThresholds: any = { ...(existingOverride?.thresholds || {}) };