-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Transforms: Support to set destination ingest pipeline. #123911
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
dcd82f7
[ML] Support to set destination ingest pipeline.
walterra b36a61c
[ML] Fix jest tests.
walterra 180656c
[ML] Fix permissions.
walterra 4b48974
[ML] Use EuiComboBox to be able to empty input.
walterra 153cc5f
[ML] Add support to allow editing a transform destination ingest pipe…
walterra fa04ee0
[ML] Fix setting ingest pipeline field to optional.
walterra 647ecf9
[ML] Fix translations.
walterra d2250c1
[ML] Fix functional tests.
walterra 4a2e665
[ML] Fix unexposed form state.
walterra 4a93e66
[ML] Tweaks.
walterra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 13 additions & 0 deletions
13
x-pack/plugins/transform/common/types/es_ingest_pipeline.ts
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,13 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
// This interface doesn't cover a full ingest pipeline spec, | ||
// just what's necessary to make it work in the transform creation wizard. | ||
// The full interface can be found in x-pack/plugins/ingest_pipelines/common/types.ts | ||
export interface EsIngestPipeline { | ||
name: string; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; | |
|
||
import { | ||
EuiAccordion, | ||
EuiComboBox, | ||
EuiLink, | ||
EuiSwitch, | ||
EuiFieldText, | ||
|
@@ -28,6 +29,7 @@ import { toMountPoint } from '../../../../../../../../../src/plugins/kibana_reac | |
|
||
import { | ||
isEsIndices, | ||
isEsIngestPipelines, | ||
isPostTransformsPreviewResponseSchema, | ||
} from '../../../../../../common/api_schemas/type_guards'; | ||
import { TransformId } from '../../../../../../common/types/transform'; | ||
|
@@ -82,8 +84,12 @@ export const StepDetailsForm: FC<StepDetailsFormProps> = React.memo( | |
const [destinationIndex, setDestinationIndex] = useState<EsIndexName>( | ||
defaults.destinationIndex | ||
); | ||
const [destinationIngestPipeline, setDestinationIngestPipeline] = useState<string>( | ||
defaults.destinationIngestPipeline | ||
); | ||
const [transformIds, setTransformIds] = useState<TransformId[]>([]); | ||
const [indexNames, setIndexNames] = useState<EsIndexName[]>([]); | ||
const [ingestPipelineNames, setIngestPipelineNames] = useState<string[]>([]); | ||
|
||
const canCreateDataView = useMemo( | ||
() => | ||
|
@@ -180,7 +186,10 @@ export const StepDetailsForm: FC<StepDetailsFormProps> = React.memo( | |
setTransformIds(resp.transforms.map((transform) => transform.id)); | ||
} | ||
|
||
const indices = await api.getEsIndices(); | ||
const [indices, ingestPipelines] = await Promise.all([ | ||
api.getEsIndices(), | ||
api.getEsIngestPipelines(), | ||
]); | ||
|
||
if (isEsIndices(indices)) { | ||
setIndexNames(indices.map((index) => index.name)); | ||
|
@@ -200,6 +209,24 @@ export const StepDetailsForm: FC<StepDetailsFormProps> = React.memo( | |
}); | ||
} | ||
|
||
if (isEsIngestPipelines(ingestPipelines)) { | ||
setIngestPipelineNames(ingestPipelines.map(({ name }) => name)); | ||
} else { | ||
toastNotifications.addDanger({ | ||
title: i18n.translate('xpack.transform.stepDetailsForm.errorGettingIngestPipelines', { | ||
defaultMessage: 'An error occurred getting the existing ingest pipeline names:', | ||
}), | ||
text: toMountPoint( | ||
<ToastNotificationText | ||
overlays={overlays} | ||
theme={theme} | ||
text={getErrorMessage(ingestPipelines)} | ||
/>, | ||
{ theme$: theme.theme$ } | ||
), | ||
}); | ||
} | ||
|
||
try { | ||
setIndexPatternTitles(await deps.data.indexPatterns.getTitles()); | ||
} catch (e) { | ||
|
@@ -311,6 +338,7 @@ export const StepDetailsForm: FC<StepDetailsFormProps> = React.memo( | |
transformSettingsMaxPageSearchSize, | ||
transformSettingsDocsPerSecond, | ||
destinationIndex, | ||
destinationIngestPipeline, | ||
touched: true, | ||
valid, | ||
indexPatternTimeField, | ||
|
@@ -331,6 +359,7 @@ export const StepDetailsForm: FC<StepDetailsFormProps> = React.memo( | |
transformFrequency, | ||
transformSettingsMaxPageSearchSize, | ||
destinationIndex, | ||
destinationIngestPipeline, | ||
valid, | ||
indexPatternTimeField, | ||
/* eslint-enable react-hooks/exhaustive-deps */ | ||
|
@@ -443,6 +472,37 @@ export const StepDetailsForm: FC<StepDetailsFormProps> = React.memo( | |
/> | ||
</EuiFormRow> | ||
|
||
{ingestPipelineNames.length > 0 && ( | ||
<EuiFormRow | ||
label={i18n.translate( | ||
'xpack.transform.stepDetailsForm.destinationIngestPipelineLabel', | ||
{ | ||
defaultMessage: 'Destination ingest pipeline', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed, if I add a pipeline, hit Next, and then Previous, the pipeline is being forgotten. It also isn't being saved in the config. |
||
} | ||
)} | ||
> | ||
<EuiComboBox | ||
data-test-subj="transformDestinationPipelineSelect" | ||
aria-label={i18n.translate( | ||
'xpack.transform.stepDetailsForm.destinationIngestPipelineAriaLabel', | ||
{ | ||
defaultMessage: 'Select an ingest pipeline', | ||
} | ||
)} | ||
placeholder={i18n.translate( | ||
'xpack.transform.stepDetailsForm.destinationIngestPipelineComboBoxPlaceholder', | ||
{ | ||
defaultMessage: 'Select an ingest pipeline', | ||
} | ||
)} | ||
singleSelection={{ asPlainText: true }} | ||
options={ingestPipelineNames.map((label: string) => ({ label }))} | ||
selectedOptions={[{ label: destinationIngestPipeline }]} | ||
onChange={(options) => setDestinationIngestPipeline(options[0]?.label ?? '')} | ||
/> | ||
</EuiFormRow> | ||
)} | ||
|
||
{stepDefineState.transformFunction === TRANSFORM_FUNCTION.LATEST ? ( | ||
<> | ||
<EuiSpacer size={'m'} /> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider adding the pipeline to the details summary?