Skip to content

Commit

Permalink
[Security Solution][Detections] Alert table status update bug (elasti…
Browse files Browse the repository at this point in the history
  • Loading branch information
dplumlee authored Jan 8, 2021
1 parent 5a65331 commit 3bb1aa2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ const AlertContextMenuComponent: React.FC<AlertContextMenuProps> = ({
const dispatch = useDispatch();
const [, dispatchToaster] = useStateToaster();
const [isPopoverOpen, setPopover] = useState(false);
const [alertStatus, setAlertStatus] = useState<Status | undefined>(
(ecsRowData.signal?.status && (ecsRowData.signal.status[0] as Status)) ?? undefined
);
const eventId = ecsRowData._id;
const ruleId = useMemo(
(): string | null =>
Expand Down Expand Up @@ -90,6 +87,10 @@ const AlertContextMenuComponent: React.FC<AlertContextMenuProps> = ({

const { addWarning } = useAppToasts();

const alertStatus = useMemo(() => {
return ecsRowData.signal?.status && (ecsRowData.signal.status[0] as Status);
}, [ecsRowData]);

const onButtonClick = useCallback(() => {
setPopover(!isPopoverOpen);
}, [isPopoverOpen]);
Expand Down Expand Up @@ -122,9 +123,6 @@ const AlertContextMenuComponent: React.FC<AlertContextMenuProps> = ({
const onAddExceptionConfirm = useCallback(
(didCloseAlert: boolean, didBulkCloseAlert) => {
closeAddExceptionModal();
if (didCloseAlert) {
setAlertStatus('closed');
}
if (timelineId !== TimelineId.active || didBulkCloseAlert) {
refetch();
}
Expand Down Expand Up @@ -154,7 +152,6 @@ const AlertContextMenuComponent: React.FC<AlertContextMenuProps> = ({
}
displaySuccessToast(title, dispatchToaster);
}
setAlertStatus(newStatus);
},
[dispatchToaster, addWarning]
);
Expand Down Expand Up @@ -359,10 +356,10 @@ const AlertContextMenuComponent: React.FC<AlertContextMenuProps> = ({
return [];
}
}, [
alertStatus,
closeAlertActionComponent,
inProgressAlertActionComponent,
openAlertActionComponent,
alertStatus,
]);

const items = useMemo(
Expand Down

0 comments on commit 3bb1aa2

Please sign in to comment.