mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Enterprise Search] delete ml inference pipeline (#141009)
* [Enterprise Search] delete ml inference pipeline added a confirm modal and delete call for the delete pipeline action on the index pipelines page. * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
92ca42f007
commit
b5a35d74e7
3 changed files with 124 additions and 2 deletions
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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 { createApiLogic } from '../../../shared/api_logic/create_api_logic';
|
||||
import { HttpLogic } from '../../../shared/http';
|
||||
|
||||
export interface DeleteMlInferencePipelineApiLogicArgs {
|
||||
indexName: string;
|
||||
pipelineName: string;
|
||||
}
|
||||
|
||||
export interface DeleteMlInferencePipelineResponse {
|
||||
deleted?: string;
|
||||
updated?: string;
|
||||
}
|
||||
|
||||
export const deleteMlInferencePipeline = async (
|
||||
args: DeleteMlInferencePipelineApiLogicArgs
|
||||
): Promise<DeleteMlInferencePipelineResponse> => {
|
||||
const route = `/internal/enterprise_search/indices/${args.indexName}/ml_inference/pipeline_processors/${args.pipelineName}`;
|
||||
|
||||
return await HttpLogic.values.http.delete<DeleteMlInferencePipelineResponse>(route);
|
||||
};
|
||||
|
||||
export const DeleteMlInferencePipelineApiLogic = createApiLogic(
|
||||
['delete_ml_inference_pipeline_api_logic'],
|
||||
deleteMlInferencePipeline
|
||||
);
|
|
@ -7,17 +7,19 @@
|
|||
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import { useValues } from 'kea';
|
||||
import { useActions, useValues } from 'kea';
|
||||
|
||||
import {
|
||||
EuiBadge,
|
||||
EuiButtonEmpty,
|
||||
EuiConfirmModal,
|
||||
EuiFlexGroup,
|
||||
EuiFlexItem,
|
||||
EuiHealth,
|
||||
EuiPanel,
|
||||
EuiPopover,
|
||||
EuiPopoverTitle,
|
||||
EuiText,
|
||||
EuiTextColor,
|
||||
EuiTitle,
|
||||
} from '@elastic/eui';
|
||||
|
@ -25,7 +27,11 @@ import {
|
|||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { InferencePipeline } from '../../../../../../common/types/pipelines';
|
||||
import { CANCEL_BUTTON_LABEL, DELETE_BUTTON_LABEL } from '../../../../shared/constants';
|
||||
import { HttpLogic } from '../../../../shared/http';
|
||||
import { IndexNameLogic } from '../index_name_logic';
|
||||
|
||||
import { PipelinesLogic } from './pipelines_logic';
|
||||
|
||||
export const InferencePipelineCard: React.FC<InferencePipeline> = ({
|
||||
pipelineName,
|
||||
|
@ -34,7 +40,10 @@ export const InferencePipelineCard: React.FC<InferencePipeline> = ({
|
|||
modelType,
|
||||
}) => {
|
||||
const { http } = useValues(HttpLogic);
|
||||
const { indexName } = useValues(IndexNameLogic);
|
||||
const [isPopOverOpen, setIsPopOverOpen] = useState(false);
|
||||
const [showConfirmDelete, setShowConfirmDelete] = useState(false);
|
||||
const { deleteMlPipeline } = useActions(PipelinesLogic);
|
||||
|
||||
const deployedText = i18n.translate('xpack.enterpriseSearch.inferencePipelineCard.isDeployed', {
|
||||
defaultMessage: 'Deployed',
|
||||
|
@ -100,7 +109,13 @@ export const InferencePipelineCard: React.FC<InferencePipeline> = ({
|
|||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
<div>
|
||||
<EuiButtonEmpty size="s" flush="both" iconType="trash" color="text">
|
||||
<EuiButtonEmpty
|
||||
size="s"
|
||||
flush="both"
|
||||
iconType="trash"
|
||||
color="text"
|
||||
onClick={() => setShowConfirmDelete(true)}
|
||||
>
|
||||
{i18n.translate(
|
||||
'xpack.enterpriseSearch.inferencePipelineCard.action.delete',
|
||||
{ defaultMessage: 'Delete pipeline' }
|
||||
|
@ -137,6 +152,42 @@ export const InferencePipelineCard: React.FC<InferencePipeline> = ({
|
|||
</EuiFlexGroup>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
{showConfirmDelete && (
|
||||
<EuiConfirmModal
|
||||
onCancel={() => setShowConfirmDelete(false)}
|
||||
onConfirm={() => {
|
||||
setShowConfirmDelete(false);
|
||||
deleteMlPipeline({
|
||||
indexName,
|
||||
pipelineName,
|
||||
});
|
||||
}}
|
||||
title={i18n.translate(
|
||||
'xpack.enterpriseSearch.inferencePipelineCard.deleteConfirm.title',
|
||||
{ defaultMessage: 'Delete Pipeline' }
|
||||
)}
|
||||
buttonColor="danger"
|
||||
cancelButtonText={CANCEL_BUTTON_LABEL}
|
||||
confirmButtonText={DELETE_BUTTON_LABEL}
|
||||
defaultFocusedButton="confirm"
|
||||
maxWidth
|
||||
>
|
||||
<EuiText>
|
||||
<p>
|
||||
{i18n.translate(
|
||||
'xpack.enterpriseSearch.inferencePipelineCard.deleteConfirm.description',
|
||||
{
|
||||
defaultMessage:
|
||||
'You are removing the pipeline "{pipelineName}" from the Machine Learning Inference Pipeline and deleting it.',
|
||||
values: {
|
||||
pipelineName,
|
||||
},
|
||||
}
|
||||
)}
|
||||
</p>
|
||||
</EuiText>
|
||||
</EuiConfirmModal>
|
||||
)}
|
||||
</EuiPanel>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -47,6 +47,11 @@ import {
|
|||
FetchIndexApiResponse,
|
||||
} from '../../../api/index/fetch_index_api_logic';
|
||||
import { CreateMlInferencePipelineApiLogic } from '../../../api/ml_models/create_ml_inference_pipeline';
|
||||
import {
|
||||
DeleteMlInferencePipelineApiLogic,
|
||||
DeleteMlInferencePipelineApiLogicArgs,
|
||||
DeleteMlInferencePipelineResponse,
|
||||
} from '../../../api/ml_models/delete_ml_inference_pipeline';
|
||||
import { FetchMlInferencePipelineProcessorsApiLogic } from '../../../api/pipelines/fetch_ml_inference_pipeline_processors';
|
||||
import { isApiIndex, isConnectorIndex, isCrawlerIndex } from '../../../utils/indices';
|
||||
|
||||
|
@ -68,6 +73,18 @@ type PipelinesActions = Pick<
|
|||
CreateCustomPipelineApiLogicArgs,
|
||||
CreateCustomPipelineApiLogicResponse
|
||||
>['apiSuccess'];
|
||||
deleteMlPipeline: Actions<
|
||||
DeleteMlInferencePipelineApiLogicArgs,
|
||||
DeleteMlInferencePipelineResponse
|
||||
>['makeRequest'];
|
||||
deleteMlPipelineError: Actions<
|
||||
DeleteMlInferencePipelineApiLogicArgs,
|
||||
DeleteMlInferencePipelineResponse
|
||||
>['apiError'];
|
||||
deleteMlPipelineSuccess: Actions<
|
||||
DeleteMlInferencePipelineApiLogicArgs,
|
||||
DeleteMlInferencePipelineResponse
|
||||
>['apiSuccess'];
|
||||
fetchCustomPipeline: Actions<
|
||||
FetchCustomPipelineApiLogicArgs,
|
||||
FetchCustomPipelineApiLogicResponse
|
||||
|
@ -129,6 +146,12 @@ export const PipelinesLogic = kea<MakeLogicType<PipelinesValues, PipelinesAction
|
|||
],
|
||||
CreateMlInferencePipelineApiLogic,
|
||||
['apiSuccess as createMlInferencePipelineSuccess'],
|
||||
DeleteMlInferencePipelineApiLogic,
|
||||
[
|
||||
'apiError as deleteMlPipelineError',
|
||||
'apiSuccess as deleteMlPipelineSuccess',
|
||||
'makeRequest as deleteMlPipeline',
|
||||
],
|
||||
],
|
||||
values: [
|
||||
FetchDefaultPipelineApiLogic,
|
||||
|
@ -190,6 +213,23 @@ export const PipelinesLogic = kea<MakeLogicType<PipelinesValues, PipelinesAction
|
|||
createMlInferencePipelineSuccess: () => {
|
||||
actions.fetchMlInferenceProcessors({ indexName: values.index.name });
|
||||
},
|
||||
deleteMlPipelineError: (error) => flashAPIErrors(error),
|
||||
deleteMlPipelineSuccess: (value) => {
|
||||
if (value.deleted) {
|
||||
flashSuccessToast(
|
||||
i18n.translate(
|
||||
'xpack.enterpriseSearch.content.indices.pipelines.successToastDeleteMlPipeline.title',
|
||||
{
|
||||
defaultMessage: 'Deleted machine learning inference pipeline "{pipelineName}"',
|
||||
values: {
|
||||
pipelineName: value.deleted,
|
||||
},
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
actions.fetchMlInferenceProcessors({ indexName: values.index.name });
|
||||
},
|
||||
fetchIndexApiSuccess: (index) => {
|
||||
if (!values.showModal) {
|
||||
// Don't do this when the modal is open to avoid overwriting the values while editing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue