Skip to content

Commit

Permalink
[Enterprise Search] disable adding ml pipelines to default ingest pip…
Browse files Browse the repository at this point in the history
…eline (#141169)
  • Loading branch information
TattdCodeMonkey authored Sep 21, 2022
1 parent 1186e35 commit f6f5efd
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const AddMLInferencePipelineButton: React.FC<AddMLInferencePipelineButton
onClick,
}) => {
const { capabilities } = useValues(KibanaLogic);
const { canUseMlInferencePipeline } = useValues(PipelinesLogic);
const { canUseMlInferencePipeline, hasIndexIngestionPipeline } = useValues(PipelinesLogic);
const hasMLPermissions = capabilities?.ml?.canAccessML ?? false;
if (!hasMLPermissions) {
return (
Expand All @@ -36,6 +36,21 @@ export const AddMLInferencePipelineButton: React.FC<AddMLInferencePipelineButton
</EuiToolTip>
);
}
if (!hasIndexIngestionPipeline) {
return (
<EuiToolTip
content={i18n.translate(
'xpack.enterpriseSearch.content.indices.pipelines.mlInference.addButton.defaultIngestPipeline.disabledTooltip',
{
defaultMessage:
'You cannot add machine learning inference pipeline processors to the default ingest pipeline. You must first copy and customize the default ingest pipeline to add machine learning inference pipeline processors.',
}
)}
>
<AddButton disabled />
</EuiToolTip>
);
}
if (!canUseMlInferencePipeline) {
return (
<EuiToolTip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const DEFAULT_VALUES = {
pipelineState: DEFAULT_PIPELINE_VALUES,
showModal: false,
showAddMlInferencePipelineModal: false,
hasIndexIngestionPipeline: false,
};

describe('PipelinesLogic', () => {
Expand Down Expand Up @@ -86,6 +87,7 @@ describe('PipelinesLogic', () => {
expect(PipelinesLogic.values).toEqual({
...DEFAULT_VALUES,
pipelineState: { ...DEFAULT_PIPELINE_VALUES, name: 'new_pipeline_name' },
hasIndexIngestionPipeline: true,
});
});
describe('makeRequest', () => {
Expand Down Expand Up @@ -155,6 +157,7 @@ describe('PipelinesLogic', () => {
connector: { ...connectorIndex.connector, pipeline: newPipeline },
},
pipelineState: newPipeline,
hasIndexIngestionPipeline: true,
});
});
it('should not set configState if modal is open', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ interface PipelinesValues {
canUseMlInferencePipeline: boolean;
defaultPipelineValues: IngestPipelineParams;
defaultPipelineValuesData: IngestPipelineParams | null;
hasIndexIngestionPipeline: boolean;
index: FetchIndexApiResponse;
mlInferencePipelineProcessors: InferencePipeline[];
pipelineState: IngestPipelineParams;
Expand Down Expand Up @@ -289,14 +290,26 @@ export const PipelinesLogic = kea<MakeLogicType<PipelinesValues, PipelinesAction
() => [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,
],
}),
});

0 comments on commit f6f5efd

Please sign in to comment.