Skip to content

Commit 0767f8d

Browse files
committed
adds error toast
1 parent fb18489 commit 0767f8d

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

x-pack/plugins/siem/public/alerts/components/signals/actions.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
replaceTemplateFieldFromMatchFilters,
2424
replaceTemplateFieldFromDataProviders,
2525
} from './helpers';
26-
import { displaySuccessToast } from '../../../common/components/toasters';
26+
import { displaySuccessToast, displayErrorToast } from '../../../common/components/toasters';
2727
import * as i18n from './translations';
2828

2929
export const getUpdateSignalsQuery = (eventIds: Readonly<string[]>) => {
@@ -69,14 +69,18 @@ export const updateSignalStatusAction = async ({
6969
// TODO: Only delete those that were successfully updated from updatedRules
7070
setEventsDeleted({ eventIds: signalIds, isDeleted: true });
7171

72-
const statusMessage =
72+
const successTitle =
7373
status === 'closed'
74-
? i18n.CLOSED_ALERT_TOAST(signalIds.length)
75-
: i18n.OPENED_ALERT_TOAST(signalIds.length);
74+
? i18n.CLOSED_ALERT_SUCCESS_TOAST(signalIds.length)
75+
: i18n.OPENED_ALERT_SUCCESS_TOAST(signalIds.length);
7676

77-
displaySuccessToast(statusMessage, dispatchToaster);
77+
displaySuccessToast(successTitle, dispatchToaster);
7878
} catch (e) {
79-
// TODO: Show error toasts
79+
const errorTitle =
80+
status === 'closed'
81+
? i18n.CLOSED_ALERT_FAILED_TOAST(signalIds.length)
82+
: i18n.OPENED_ALERT_FAILED_TOAST(signalIds.length);
83+
displayErrorToast(errorTitle, [e.message], dispatchToaster);
8084
} finally {
8185
setEventsLoading({ eventIds: signalIds, isLoading: false });
8286
}

x-pack/plugins/siem/public/alerts/components/signals/translations.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,30 @@ export const ACTION_INVESTIGATE_IN_TIMELINE = i18n.translate(
102102
}
103103
);
104104

105-
export const CLOSED_ALERT_TOAST = (totalAlerts: number) =>
106-
i18n.translate('xpack.siem.detectionEngine.signals.closedAlertToastMessage', {
105+
export const CLOSED_ALERT_SUCCESS_TOAST = (totalAlerts: number) =>
106+
i18n.translate('xpack.siem.detectionEngine.signals.closedAlertSuccessToastMessage', {
107107
values: { totalAlerts },
108108
defaultMessage:
109-
'Successfully Closed {totalAlerts} {totalAlerts, plural, =1 {Alert} other {Alerts}}.',
109+
'Successfully closed {totalAlerts} {totalAlerts, plural, =1 {alert} other {alerts}}.',
110110
});
111111

112-
export const OPENED_ALERT_TOAST = (totalAlerts: number) =>
113-
i18n.translate('xpack.siem.detectionEngine.signals.openedAlertToastMessage', {
112+
export const OPENED_ALERT_SUCCESS_TOAST = (totalAlerts: number) =>
113+
i18n.translate('xpack.siem.detectionEngine.signals.openedAlertSuccessToastMessage', {
114114
values: { totalAlerts },
115115
defaultMessage:
116-
'Successfully Opened {totalAlerts} {totalAlerts, plural, =1 {Alert} other {Alerts}}.',
116+
'Successfully opened {totalAlerts} {totalAlerts, plural, =1 {alert} other {alerts}}.',
117+
});
118+
119+
export const CLOSED_ALERT_FAILED_TOAST = (totalAlerts: number) =>
120+
i18n.translate('xpack.siem.detectionEngine.signals.closedAlertFailedToastMessage', {
121+
values: { totalAlerts },
122+
defaultMessage:
123+
'Failed to close {totalAlerts} {totalAlerts, plural, =1 {alert} other {alerts}}.',
124+
});
125+
126+
export const OPENED_ALERT_FAILED_TOAST = (totalAlerts: number) =>
127+
i18n.translate('xpack.siem.detectionEngine.signals.openedAlertFailedToastMessage', {
128+
values: { totalAlerts },
129+
defaultMessage:
130+
'Failed to open {totalAlerts} {totalAlerts, plural, =1 {alert} other {alerts}}.',
117131
});

0 commit comments

Comments
 (0)