Skip to content

Commit dae1c8f

Browse files
committed
toast error notifications for rule deletion
Signed-off-by: Aleksandar Djindjic <[email protected]>
1 parent 264c4ea commit dae1c8f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

public/pages/Rules/components/RuleViewerFlyout/RuleViewerFlyout.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@ import {
1212
EuiTitle,
1313
EuiButtonIcon,
1414
} from '@elastic/eui';
15+
import { errorNotificationToast } from '../../../../utils/helpers';
1516
import { ROUTES } from '../../../../utils/constants';
1617
import React, { useMemo, useState } from 'react';
1718
import { RouteComponentProps } from 'react-router-dom';
1819
import { RuleTableItem } from '../../utils/helpers';
1920
import { DeleteRuleModal } from '../DeleteModal/DeleteModal';
2021
import { RuleContentViewer } from '../RuleContentViewer/RuleContentViewer';
2122
import { RuleViewerFlyoutHeaderActions } from './RuleViewFlyoutHeaderActions';
22-
import { RuleService } from '../../../../services';
23+
import { RuleService, NotificationsStart } from '../../../../services';
2324

2425
export interface RuleViewerFlyoutProps {
2526
history?: RouteComponentProps['history'];
2627
ruleTableItem: RuleTableItem;
2728
ruleService?: RuleService;
29+
notifications?: NotificationsStart;
2830
hideFlyout: (refreshRules?: boolean) => void;
2931
}
3032

@@ -33,6 +35,7 @@ export const RuleViewerFlyout: React.FC<RuleViewerFlyoutProps> = ({
3335
hideFlyout,
3436
ruleTableItem,
3537
ruleService,
38+
notifications,
3639
}) => {
3740
const [actionsPopoverOpen, setActionsPopoverOpen] = useState(false);
3841
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
@@ -80,12 +83,12 @@ export const RuleViewerFlyout: React.FC<RuleViewerFlyoutProps> = ({
8083
}
8184
const deleteRuleRes = await ruleService.deleteRule(ruleTableItem.ruleId);
8285

83-
if (!deleteRuleRes.ok) {
84-
// TODO: show error
86+
if (deleteRuleRes.ok) {
87+
closeDeleteModal();
88+
hideFlyout(true);
89+
} else {
90+
errorNotificationToast(notifications, 'delete', 'rule', deleteRuleRes.error);
8591
}
86-
87-
closeDeleteModal();
88-
hideFlyout(true);
8992
};
9093

9194
const deleteModal = useMemo(

public/pages/Rules/containers/Rules/Rules.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export const Rules: React.FC<RulesProps> = (props) => {
9393
history={props.history}
9494
ruleTableItem={flyoutData}
9595
ruleService={services.ruleService}
96+
notifications={props.notifications}
9697
/>
9798
) : null}
9899
<EuiFlexGroup direction="column">

0 commit comments

Comments
 (0)