@@ -53,10 +53,17 @@ interface Props {
5353 snapshot : ModelSnapshot ;
5454 snapshots : ModelSnapshot [ ] ;
5555 job : CombinedJobWithStats ;
56- closeFlyout ( reload : boolean ) : void ;
56+ closeFlyout ( ) : void ;
57+ refresh ( ) : void ;
5758}
5859
59- export const RevertModelSnapshotFlyout : FC < Props > = ( { snapshot, snapshots, job, closeFlyout } ) => {
60+ export const RevertModelSnapshotFlyout : FC < Props > = ( {
61+ snapshot,
62+ snapshots,
63+ job,
64+ closeFlyout,
65+ refresh,
66+ } ) => {
6067 const { toasts } = useNotifications ( ) ;
6168 const { loadAnomalyDataForJob, loadEventRateForJob } = useMemo (
6269 ( ) => chartLoaderProvider ( mlResultsService ) ,
@@ -110,13 +117,6 @@ export const RevertModelSnapshotFlyout: FC<Props> = ({ snapshot, snapshots, job,
110117 setChartReady ( true ) ;
111118 } , [ job ] ) ;
112119
113- function closeWithReload ( ) {
114- closeFlyout ( true ) ;
115- }
116- function closeWithoutReload ( ) {
117- closeFlyout ( false ) ;
118- }
119-
120120 function showRevertModal ( ) {
121121 setRevertModalVisible ( true ) ;
122122 }
@@ -138,15 +138,18 @@ export const RevertModelSnapshotFlyout: FC<Props> = ({ snapshot, snapshots, job,
138138 } ) )
139139 : undefined ;
140140
141- await ml . jobs . revertModelSnapshot (
142- job . job_id ,
143- currentSnapshot . snapshot_id ,
144- replay ,
145- end ,
146- events
147- ) ;
141+ ml . jobs
142+ . revertModelSnapshot ( job . job_id , currentSnapshot . snapshot_id , replay , end , events )
143+ . then ( ( ) => {
144+ toasts . addSuccess (
145+ i18n . translate ( 'xpack.ml.revertModelSnapshotFlyout.revertSuccessTitle' , {
146+ defaultMessage : 'Model snapshot revert successful' ,
147+ } )
148+ ) ;
149+ refresh ( ) ;
150+ } ) ;
148151 hideRevertModal ( ) ;
149- closeWithReload ( ) ;
152+ closeFlyout ( ) ;
150153 } catch ( error ) {
151154 setApplying ( false ) ;
152155 toasts . addError ( new Error ( error . body . message ) , {
@@ -166,7 +169,7 @@ export const RevertModelSnapshotFlyout: FC<Props> = ({ snapshot, snapshots, job,
166169
167170 return (
168171 < >
169- < EuiFlyout onClose = { closeWithoutReload } hideCloseButton size = "m" >
172+ < EuiFlyout onClose = { closeFlyout } hideCloseButton size = "m" >
170173 < EuiFlyoutHeader hasBorder >
171174 < EuiTitle size = "s" >
172175 < h5 >
@@ -347,7 +350,7 @@ export const RevertModelSnapshotFlyout: FC<Props> = ({ snapshot, snapshots, job,
347350 < EuiFlyoutFooter >
348351 < EuiFlexGroup justifyContent = "spaceBetween" >
349352 < EuiFlexItem grow = { false } >
350- < EuiButtonEmpty iconType = "cross" onClick = { closeWithoutReload } flush = "left" >
353+ < EuiButtonEmpty iconType = "cross" onClick = { closeFlyout } flush = "left" >
351354 < FormattedMessage
352355 id = "xpack.ml.newJob.wizard.revertModelSnapshotFlyout.closeButton"
353356 defaultMessage = "Close"
@@ -395,7 +398,12 @@ export const RevertModelSnapshotFlyout: FC<Props> = ({ snapshot, snapshots, job,
395398 confirmButtonDisabled = { applying }
396399 buttonColor = "danger"
397400 defaultFocusedButton = "confirm"
398- />
401+ >
402+ < FormattedMessage
403+ id = "xpack.ml.newJob.wizard.revertModelSnapshotFlyout.modalBody"
404+ defaultMessage = "The snapshot revert will be carried out in the background and may take some time."
405+ />
406+ </ EuiConfirmModal >
399407 </ EuiOverlayMask >
400408 ) }
401409 </ >
0 commit comments