@@ -12,19 +12,21 @@ import {
12
12
EuiTitle ,
13
13
EuiButtonIcon ,
14
14
} from '@elastic/eui' ;
15
+ import { errorNotificationToast } from '../../../../utils/helpers' ;
15
16
import { ROUTES } from '../../../../utils/constants' ;
16
17
import React , { useMemo , useState } from 'react' ;
17
18
import { RouteComponentProps } from 'react-router-dom' ;
18
19
import { RuleTableItem } from '../../utils/helpers' ;
19
20
import { DeleteRuleModal } from '../DeleteModal/DeleteModal' ;
20
21
import { RuleContentViewer } from '../RuleContentViewer/RuleContentViewer' ;
21
22
import { RuleViewerFlyoutHeaderActions } from './RuleViewFlyoutHeaderActions' ;
22
- import { RuleService } from '../../../../services' ;
23
+ import { RuleService , NotificationsStart } from '../../../../services' ;
23
24
24
25
export interface RuleViewerFlyoutProps {
25
26
history ?: RouteComponentProps [ 'history' ] ;
26
27
ruleTableItem : RuleTableItem ;
27
28
ruleService ?: RuleService ;
29
+ notifications ?: NotificationsStart ;
28
30
hideFlyout : ( refreshRules ?: boolean ) => void ;
29
31
}
30
32
@@ -33,6 +35,7 @@ export const RuleViewerFlyout: React.FC<RuleViewerFlyoutProps> = ({
33
35
hideFlyout,
34
36
ruleTableItem,
35
37
ruleService,
38
+ notifications,
36
39
} ) => {
37
40
const [ actionsPopoverOpen , setActionsPopoverOpen ] = useState ( false ) ;
38
41
const [ isDeleteModalVisible , setIsDeleteModalVisible ] = useState ( false ) ;
@@ -80,12 +83,12 @@ export const RuleViewerFlyout: React.FC<RuleViewerFlyoutProps> = ({
80
83
}
81
84
const deleteRuleRes = await ruleService . deleteRule ( ruleTableItem . ruleId ) ;
82
85
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 ) ;
85
91
}
86
-
87
- closeDeleteModal ( ) ;
88
- hideFlyout ( true ) ;
89
92
} ;
90
93
91
94
const deleteModal = useMemo (
0 commit comments