33 * or more contributor license agreements. Licensed under the Elastic License;
44 * you may not use this file except in compliance with the Elastic License.
55 */
6- import React , { Fragment , useCallback , useReducer , useState } from 'react' ;
6+ import React , { Fragment , useReducer , useState } from 'react' ;
77import { FormattedMessage } from '@kbn/i18n/react' ;
88import {
99 EuiTitle ,
@@ -40,9 +40,6 @@ export const AlertEdit = ({ initialAlert, onClose }: AlertEditProps) => {
4040 const [ hasActionsWithBrokenConnector , setHasActionsWithBrokenConnector ] = useState < boolean > (
4141 false
4242 ) ;
43- const setAlert = ( key : string , value : any ) => {
44- dispatch ( { command : { type : 'setAlert' } , payload : { key, value } } ) ;
45- } ;
4643
4744 const {
4845 reloadAlerts,
@@ -53,12 +50,6 @@ export const AlertEdit = ({ initialAlert, onClose }: AlertEditProps) => {
5350 docLinks,
5451 } = useAlertsContext ( ) ;
5552
56- const closeFlyout = useCallback ( ( ) => {
57- onClose ( ) ;
58- setAlert ( 'alert' , initialAlert ) ;
59- // eslint-disable-next-line react-hooks/exhaustive-deps
60- } , [ onClose ] ) ;
61-
6253 const alertType = alertTypeRegistry . get ( alert . alertTypeId ) ;
6354
6455 const errors = {
@@ -105,7 +96,7 @@ export const AlertEdit = ({ initialAlert, onClose }: AlertEditProps) => {
10596 return (
10697 < EuiPortal >
10798 < EuiFlyout
108- onClose = { closeFlyout }
99+ onClose = { ( ) => onClose ( ) }
109100 aria-labelledby = "flyoutAlertEditTitle"
110101 size = "m"
111102 maxWidth = { 620 }
@@ -155,7 +146,7 @@ export const AlertEdit = ({ initialAlert, onClose }: AlertEditProps) => {
155146 < EuiFlexItem grow = { false } >
156147 < EuiButtonEmpty
157148 data-test-subj = "cancelSaveEditedAlertButton"
158- onClick = { closeFlyout }
149+ onClick = { ( ) => onClose ( ) }
159150 >
160151 { i18n . translate (
161152 'xpack.triggersActionsUI.sections.alertEdit.cancelButtonLabel' ,
@@ -179,7 +170,7 @@ export const AlertEdit = ({ initialAlert, onClose }: AlertEditProps) => {
179170 const savedAlert = await onSaveAlert ( ) ;
180171 setIsSaving ( false ) ;
181172 if ( savedAlert ) {
182- closeFlyout ( ) ;
173+ onClose ( ) ;
183174 if ( reloadAlerts ) {
184175 reloadAlerts ( ) ;
185176 }
0 commit comments