forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Support
force
stop deployment (elastic#118563)
* support force stop * fix i18n, revert tests * update text * remove "Force" from the confirmation modals
- Loading branch information
1 parent
1a6cb84
commit 8779827
Showing
6 changed files
with
113 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
x-pack/plugins/ml/public/application/trained_models/models_management/force_stop_dialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { FC } from 'react'; | ||
import { EuiConfirmModal } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import type { OverlayStart } from 'kibana/public'; | ||
import type { ModelItem } from './models_list'; | ||
import { toMountPoint } from '../../../../../../../src/plugins/kibana_react/public'; | ||
|
||
interface ForceStopModelConfirmDialogProps { | ||
model: ModelItem; | ||
onCancel: () => void; | ||
onConfirm: () => void; | ||
} | ||
|
||
export const ForceStopModelConfirmDialog: FC<ForceStopModelConfirmDialogProps> = ({ | ||
model, | ||
onConfirm, | ||
onCancel, | ||
}) => { | ||
return ( | ||
<EuiConfirmModal | ||
title={ | ||
<FormattedMessage | ||
id="xpack.ml.trainedModels.modelsList.forceStopDialog.title" | ||
defaultMessage="Stop model {modelId}?" | ||
values={{ modelId: model.model_id }} | ||
/> | ||
} | ||
onCancel={onCancel} | ||
onConfirm={onConfirm} | ||
cancelButtonText={ | ||
<FormattedMessage | ||
id="xpack.ml.trainedModels.modelsList.forceStopDialog.cancelText" | ||
defaultMessage="Cancel" | ||
/> | ||
} | ||
confirmButtonText={ | ||
<FormattedMessage | ||
id="xpack.ml.trainedModels.modelsList.forceStopDialog.confirmText" | ||
defaultMessage="Stop" | ||
/> | ||
} | ||
buttonColor="danger" | ||
> | ||
<FormattedMessage | ||
id="xpack.ml.trainedModels.modelsList.forceStopDialog.pipelinesWarning" | ||
defaultMessage="You can't use these ingest pipelines until you restart the model:" | ||
/> | ||
<ul> | ||
{Object.keys(model.pipelines!) | ||
.sort() | ||
.map((pipelineName) => { | ||
return <li key={pipelineName}>{pipelineName}</li>; | ||
})} | ||
</ul> | ||
</EuiConfirmModal> | ||
); | ||
}; | ||
|
||
export const getUserConfirmationProvider = | ||
(overlays: OverlayStart) => async (forceStopModel: ModelItem) => { | ||
return new Promise(async (resolve, reject) => { | ||
try { | ||
const modalSession = overlays.openModal( | ||
toMountPoint( | ||
<ForceStopModelConfirmDialog | ||
model={forceStopModel} | ||
onCancel={() => { | ||
modalSession.close(); | ||
resolve(false); | ||
}} | ||
onConfirm={() => { | ||
modalSession.close(); | ||
resolve(true); | ||
}} | ||
/> | ||
) | ||
); | ||
} catch (e) { | ||
resolve(false); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters