From 9152a3ef774e46adc87a02c8b9c2a283a7f8995d Mon Sep 17 00:00:00 2001 From: Rodney Norris Date: Tue, 20 Sep 2022 16:11:50 -0500 Subject: [PATCH] [Enterprise Search] disable adding ml pipelines to default ingest pipeline --- .../ml_inference/add_ml_inference_button.tsx | 17 +++++++++++++- .../pipelines/pipelines_logic.test.ts | 3 +++ .../search_index/pipelines/pipelines_logic.ts | 23 +++++++++++++++---- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/add_ml_inference_button.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/add_ml_inference_button.tsx index 6a11c17e878aa..2bc65e041cc86 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/add_ml_inference_button.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/add_ml_inference_button.tsx @@ -22,7 +22,7 @@ export const AddMLInferencePipelineButton: React.FC { const { capabilities } = useValues(KibanaLogic); - const { canUseMlInferencePipeline } = useValues(PipelinesLogic); + const { canUseMlInferencePipeline, hasIndexIngestionPipeline } = useValues(PipelinesLogic); const hasMLPermissions = capabilities?.ml?.canAccessML ?? false; if (!hasMLPermissions) { return ( @@ -36,6 +36,21 @@ export const AddMLInferencePipelineButton: React.FC ); } + if (!hasIndexIngestionPipeline) { + return ( + + + + ); + } if (!canUseMlInferencePipeline) { return ( { @@ -86,6 +87,7 @@ describe('PipelinesLogic', () => { expect(PipelinesLogic.values).toEqual({ ...DEFAULT_VALUES, pipelineState: { ...DEFAULT_PIPELINE_VALUES, name: 'new_pipeline_name' }, + hasIndexIngestionPipeline: true, }); }); describe('makeRequest', () => { @@ -155,6 +157,7 @@ describe('PipelinesLogic', () => { connector: { ...connectorIndex.connector, pipeline: newPipeline }, }, pipelineState: newPipeline, + hasIndexIngestionPipeline: true, }); }); it('should not set configState if modal is open', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/pipelines_logic.ts b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/pipelines_logic.ts index e6cb840be420a..99d241507dd2a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/pipelines_logic.ts +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/pipelines_logic.ts @@ -107,6 +107,7 @@ interface PipelinesValues { canUseMlInferencePipeline: boolean; defaultPipelineValues: IngestPipelineParams; defaultPipelineValuesData: IngestPipelineParams | null; + hasIndexIngestionPipeline: boolean; index: FetchIndexApiResponse; mlInferencePipelineProcessors: InferencePipeline[]; pipelineState: IngestPipelineParams; @@ -289,14 +290,26 @@ export const PipelinesLogic = kea [selectors.index], (index: ElasticsearchIndexWithIngestion) => !isApiIndex(index), ], - canUseMlInferencePipeline: [ - () => [selectors.canSetPipeline, selectors.pipelineState], - (canSetPipeline: boolean, pipelineState: IngestPipelineParams) => - canSetPipeline && pipelineState.run_ml_inference, - ], defaultPipelineValues: [ () => [selectors.defaultPipelineValuesData], (pipeline: IngestPipelineParams | null) => pipeline ?? DEFAULT_PIPELINE_VALUES, ], + hasIndexIngestionPipeline: [ + () => [selectors.pipelineState, selectors.defaultPipelineValues], + (pipelineState: IngestPipelineParams, defaultPipelineValues: IngestPipelineParams) => + pipelineState.name !== defaultPipelineValues.name, + ], + canUseMlInferencePipeline: [ + () => [ + selectors.canSetPipeline, + selectors.hasIndexIngestionPipeline, + selectors.pipelineState, + ], + ( + canSetPipeline: boolean, + hasIndexIngestionPipeline: boolean, + pipelineState: IngestPipelineParams + ) => canSetPipeline && hasIndexIngestionPipeline && pipelineState.run_ml_inference, + ], }), });