diff --git a/client/src/pages/Alerts.jsx b/client/src/pages/Alerts.jsx index 24fa682..a514e67 100644 --- a/client/src/pages/Alerts.jsx +++ b/client/src/pages/Alerts.jsx @@ -7,7 +7,9 @@ import { BellIcon, CheckCircleIcon, XCircleIcon, - ExclamationTriangleIcon + ExclamationTriangleIcon, + ChevronDownIcon, + ChevronRightIcon } from '@heroicons/react/24/outline'; import { EditAlertModal, DetectionDetailsModal } from '../components/AlertModals'; @@ -22,6 +24,7 @@ const Alerts = () => { const [editingRule, setEditingRule] = useState(null); const [showDetectionModal, setShowDetectionModal] = useState(false); const [selectedDetection, setSelectedDetection] = useState(null); + const [expandedGroups, setExpandedGroups] = useState(new Set()); useEffect(() => { fetchAlertData(); @@ -76,6 +79,16 @@ const Alerts = () => { return groupedArrays; }; + const toggleGroupExpansion = (groupIndex) => { + const newExpanded = new Set(expandedGroups); + if (newExpanded.has(groupIndex)) { + newExpanded.delete(groupIndex); + } else { + newExpanded.add(groupIndex); + } + setExpandedGroups(newExpanded); + }; + const handleDeleteRule = async (ruleId) => { if (window.confirm('Are you sure you want to delete this alert rule?')) { try { @@ -371,8 +384,15 @@ const Alerts = () => {

) : ( -
- +
+
+

+ 💡 Alert Grouping: Related alerts (SMS, email, webhook) for the same detection event are grouped together. + Click the expand button (▶) or "+X more" badge to see all alerts in a group. +

+
+
+
@@ -397,14 +417,30 @@ const Alerts = () => { @@ -413,7 +449,7 @@ const Alerts = () => { {primaryAlert.alert_type} - {relatedAlerts.map((alert, idx) => ( + {!expandedGroups.has(groupIndex) && relatedAlerts.map((alert, idx) => ( {alert.alert_type} @@ -423,7 +459,7 @@ const Alerts = () => { - {/* Show related alerts as sub-rows if any */} - {relatedAlerts.map((alert, alertIndex) => ( + {/* Show related alerts as sub-rows if expanded */} + {expandedGroups.has(groupIndex) && relatedAlerts.map((alert, alertIndex) => (
{t('alerts.status')}
+ {relatedAlerts.length > 0 && ( + + )} {getStatusIcon(primaryAlert.status)} {primaryAlert.status} {relatedAlerts.length > 0 && ( - + )}
{primaryAlert.recipient} - {relatedAlerts.length > 0 && relatedAlerts.some(a => a.recipient !== primaryAlert.recipient) && ( + {!expandedGroups.has(groupIndex) && relatedAlerts.length > 0 && relatedAlerts.some(a => a.recipient !== primaryAlert.recipient) && (
+{relatedAlerts.filter(a => a.recipient !== primaryAlert.recipient).length} others
@@ -483,8 +519,8 @@ const Alerts = () => {
@@ -563,6 +599,7 @@ const Alerts = () => {
+ )} )}