44 * you may not use this file except in compliance with the Elastic License.
55 */
66
7- import React , { useState } from 'react' ;
7+ import React , { useState , Fragment } from 'react' ;
88import { indexBy } from 'lodash' ;
99import {
1010 EuiPageBody ,
@@ -21,6 +21,7 @@ import {
2121 EuiCallOut ,
2222 EuiSpacer ,
2323 EuiBetaBadge ,
24+ EuiButtonEmpty ,
2425} from '@elastic/eui' ;
2526import { FormattedMessage } from '@kbn/i18n/react' ;
2627import { i18n } from '@kbn/i18n' ;
@@ -34,6 +35,8 @@ import {
3435import { AlertInstancesRouteWithApi } from './alert_instances_route' ;
3536import { ViewInApp } from './view_in_app' ;
3637import { PLUGIN } from '../../../constants/plugin' ;
38+ import { AlertEdit } from '../../alert_form' ;
39+ import { AlertsContextProvider } from '../../../context/alerts_context' ;
3740
3841type AlertDetailsProps = {
3942 alert : Alert ;
@@ -52,7 +55,17 @@ export const AlertDetails: React.FunctionComponent<AlertDetailsProps> = ({
5255 muteAlert,
5356 requestRefresh,
5457} ) => {
55- const { capabilities } = useAppDependencies ( ) ;
58+ const {
59+ http,
60+ toastNotifications,
61+ capabilities,
62+ alertTypeRegistry,
63+ actionTypeRegistry,
64+ uiSettings,
65+ docLinks,
66+ charts,
67+ dataPlugin,
68+ } = useAppDependencies ( ) ;
5669
5770 const canSave = hasSaveAlertsCapability ( capabilities ) ;
5871
@@ -61,6 +74,7 @@ export const AlertDetails: React.FunctionComponent<AlertDetailsProps> = ({
6174
6275 const [ isEnabled , setIsEnabled ] = useState < boolean > ( alert . enabled ) ;
6376 const [ isMuted , setIsMuted ] = useState < boolean > ( alert . muteAll ) ;
77+ const [ editFlyoutVisible , setEditFlyoutVisibility ] = useState < boolean > ( false ) ;
6478
6579 return (
6680 < EuiPage >
@@ -90,6 +104,40 @@ export const AlertDetails: React.FunctionComponent<AlertDetailsProps> = ({
90104 </ EuiPageContentHeaderSection >
91105 < EuiPageContentHeaderSection >
92106 < EuiFlexGroup responsive = { false } gutterSize = "xs" >
107+ { canSave ? (
108+ < EuiFlexItem grow = { false } >
109+ < Fragment >
110+ { ' ' }
111+ < EuiButtonEmpty
112+ iconType = "pencil"
113+ onClick = { ( ) => setEditFlyoutVisibility ( true ) }
114+ >
115+ < FormattedMessage
116+ id = "xpack.triggersActionsUI.sections.alertDetails.editAlertButtonLabel"
117+ defaultMessage = "Edit"
118+ />
119+ </ EuiButtonEmpty >
120+ < AlertsContextProvider
121+ value = { {
122+ http,
123+ actionTypeRegistry,
124+ alertTypeRegistry,
125+ toastNotifications,
126+ uiSettings,
127+ docLinks,
128+ charts,
129+ dataFieldsFormats : dataPlugin . fieldFormats ,
130+ } }
131+ >
132+ < AlertEdit
133+ initialAlert = { alert }
134+ editFlyoutVisible = { editFlyoutVisible }
135+ setEditFlyoutVisibility = { setEditFlyoutVisibility }
136+ />
137+ </ AlertsContextProvider >
138+ </ Fragment >
139+ </ EuiFlexItem >
140+ ) : null }
93141 < EuiFlexItem grow = { false } >
94142 < ViewInApp alert = { alert } />
95143 </ EuiFlexItem >
0 commit comments