From 285809e6b5ed100714f52fcbf4fc49355d15716c Mon Sep 17 00:00:00 2001 From: Davis Plumlee <56367316+dplumlee@users.noreply.github.com> Date: Thu, 7 Jan 2021 15:14:30 -0700 Subject: [PATCH] [Security Solution][Detections] Alert table status update bug (#87243) --- .../detections/components/alerts_table/actions.tsx | 1 - .../timeline_actions/alert_context_menu.tsx | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx index 54cdd636f7a3..457f53845007 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx @@ -77,7 +77,6 @@ export const updateAlertStatusAction = async ({ setEventsLoading({ eventIds: alertIds, isLoading: true }); const queryObject = query ? { query: JSON.parse(query) } : getUpdateAlertsQuery(alertIds); - const response = await updateAlertStatus({ query: queryObject, status: selectedStatus }); // TODO: Only delete those that were successfully updated from updatedRules setEventsDeleted({ eventIds: alertIds, isDeleted: true }); diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/alert_context_menu.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/alert_context_menu.tsx index 614b39d280ae..35f753f8cf0b 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/alert_context_menu.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/alert_context_menu.tsx @@ -60,9 +60,6 @@ const AlertContextMenuComponent: React.FC = ({ const dispatch = useDispatch(); const [, dispatchToaster] = useStateToaster(); const [isPopoverOpen, setPopover] = useState(false); - const [alertStatus, setAlertStatus] = useState( - (ecsRowData.signal?.status && (ecsRowData.signal.status[0] as Status)) ?? undefined - ); const eventId = ecsRowData._id; const ruleId = useMemo( (): string | null => @@ -90,6 +87,10 @@ const AlertContextMenuComponent: React.FC = ({ const { addWarning } = useAppToasts(); + const alertStatus = useMemo(() => { + return ecsRowData.signal?.status && (ecsRowData.signal.status[0] as Status); + }, [ecsRowData]); + const onButtonClick = useCallback(() => { setPopover(!isPopoverOpen); }, [isPopoverOpen]); @@ -122,9 +123,6 @@ const AlertContextMenuComponent: React.FC = ({ const onAddExceptionConfirm = useCallback( (didCloseAlert: boolean, didBulkCloseAlert) => { closeAddExceptionModal(); - if (didCloseAlert) { - setAlertStatus('closed'); - } if (timelineId !== TimelineId.active || didBulkCloseAlert) { refetch(); } @@ -154,7 +152,6 @@ const AlertContextMenuComponent: React.FC = ({ } displaySuccessToast(title, dispatchToaster); } - setAlertStatus(newStatus); }, [dispatchToaster, addWarning] ); @@ -359,10 +356,10 @@ const AlertContextMenuComponent: React.FC = ({ return []; } }, [ - alertStatus, closeAlertActionComponent, inProgressAlertActionComponent, openAlertActionComponent, + alertStatus, ]); const items = useMemo(