Skip to content
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

[Ingest Node Pipelines] Pipeline Processors Editor #66021

Merged
merged 188 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
c19382d
initial plugin setup
alisonelizabeth Apr 3, 2020
bf94f1c
add smoke test
alisonelizabeth Apr 5, 2020
e24165e
Merge branch 'master' of github.com:elastic/kibana into feature/inges…
alisonelizabeth Apr 5, 2020
b0bb193
Merge branch 'master' of github.com:elastic/kibana into feature/inges…
alisonelizabeth Apr 6, 2020
5a536bd
fix license check
alisonelizabeth Apr 6, 2020
ef2f1ab
refactor plugin setup
alisonelizabeth Apr 6, 2020
fc9235b
Merge branch 'master' into feature/ingest-node-pipelines
elasticmachine Apr 7, 2020
a841441
Merge branch 'master' into feature/ingest-node-pipelines
elasticmachine Apr 7, 2020
7de73c8
Server-side create/update ingest pipelines (#62744)
alisonelizabeth Apr 8, 2020
ac0ac2b
Merge branch 'master' into feature/ingest-node-pipelines
elasticmachine Apr 8, 2020
699ebef
List pipelines (#62785)
jloleysens Apr 9, 2020
92b3f21
[Ingest pipelines] Create pipeline UI (#63017)
alisonelizabeth Apr 14, 2020
993d065
Merge branch 'master' of github.com:elastic/kibana into feature/inges…
alisonelizabeth Apr 14, 2020
2b70fa7
First vertical slice of pipeline editor component
jloleysens Apr 15, 2020
402459f
Made a space for common parameters
jloleysens Apr 15, 2020
cf8b36b
[Ingest pipelines] Edit pipeline page (#63522)
alisonelizabeth Apr 15, 2020
3824e25
First iteration of CRUD functionality working
jloleysens Apr 16, 2020
7d48f21
Merge branch 'feature/ingest-node-pipelines' of github.com:elastic/ki…
jloleysens Apr 16, 2020
f3f705f
WiP on moving the pipeline editor to pipeline processor editor
jloleysens Apr 16, 2020
48a18c6
Finish refactor to work with passing state out
jloleysens Apr 16, 2020
9e09ad5
Refactor and fix tests
jloleysens Apr 16, 2020
8d18877
Merge branch 'master' of github.com:elastic/kibana into feature/inges…
alisonelizabeth Apr 20, 2020
7e7d776
[Ingest pipelines] Polish details panel and empty list (#63926)
alisonelizabeth Apr 20, 2020
4560d75
Address some early feedback and use FormDataProvider
jloleysens Apr 20, 2020
597b148
Merge branch 'feature/ingest-node-pipelines' of github.com:elastic/ki…
jloleysens Apr 20, 2020
6ffaeda
[Ingest pipelines] Delete pipeline (#63635)
alisonelizabeth Apr 20, 2020
2c340b2
Merge branch 'master' of github.com:elastic/kibana into feature/inges…
jloleysens Apr 21, 2020
34cb91a
[Ingest Node Pipelines] Clone Pipeline (#64049)
jloleysens Apr 22, 2020
29b006b
Merge branch 'feature/ingest-node-pipelines' of github.com:elastic/ki…
jloleysens Apr 22, 2020
564f74f
Update to using the more flexible controlled component pattern
jloleysens Apr 22, 2020
9c0bd8e
Handle sub-form validity
jloleysens Apr 22, 2020
82a999c
Fix Jest test
jloleysens Apr 22, 2020
be9a290
Refactor some names
jloleysens Apr 22, 2020
2957970
Mark as private
jloleysens Apr 22, 2020
736c98e
Major WiP
jloleysens Apr 23, 2020
eba5305
[Ingest node pipelines] Privileges (#63850)
jloleysens Apr 23, 2020
74b69c7
First iteration of drag and drop tree on feature parity
jloleysens Apr 23, 2020
8314d23
First steps toward add on failure handler
jloleysens Apr 23, 2020
1141e50
First iteration of nested tree with add on failure working
jloleysens Apr 23, 2020
5c84cc4
Refactor and some UI layout updates
jloleysens Apr 23, 2020
09f74db
Remove immer (not call stack safe)
jloleysens Apr 23, 2020
dbc5cc5
Merge branch 'master' into feature/ingest-node-pipelines
elasticmachine Apr 24, 2020
a2b4049
[Ingest Node Pipelines] More lenient treatment of on-failure value (#…
jloleysens Apr 25, 2020
e40cefc
Move file to components folder
jloleysens Apr 27, 2020
cad13fd
Merge branch 'master' into feature/ingest-node-pipelines
elasticmachine Apr 27, 2020
fc0ed64
[Ingest pipelines] Simulate pipeline (#64223)
alisonelizabeth Apr 27, 2020
6c71bff
Merge branch 'feature/ingest-node-pipelines' of github.com:elastic/ki…
jloleysens Apr 28, 2020
0ef475c
Updated tree rendering
jloleysens Apr 28, 2020
6dbdf06
[Ingest Node Pipelines] Show flyout after editing or creating a pipel…
jloleysens Apr 28, 2020
e7f1e3c
Clarification of terms
jloleysens Apr 29, 2020
b60ef5f
Implement move between lists functionality
jloleysens Apr 29, 2020
a9c5384
Merge branch 'master' of github.com:elastic/kibana into feature/inges…
alisonelizabeth Apr 29, 2020
5643419
fix TS
alisonelizabeth Apr 29, 2020
61d194b
Prevent nesting a parent inside of its own child
jloleysens Apr 29, 2020
d9ef80a
Add comment
jloleysens Apr 29, 2020
f3a16f2
Merge branch 'master' into feature/ingest-node-pipelines
elasticmachine Apr 29, 2020
7010b9e
Merge branch 'master' of github.com:elastic/kibana into feature/inges…
alisonelizabeth Apr 29, 2020
3c4353f
Merge branch 'master' into feature/ingest-node-pipelines
elasticmachine Apr 30, 2020
a4c298d
[Ingest pipelines] Cleanup (#64794)
alisonelizabeth Apr 30, 2020
5bbb9fc
address review feedback
alisonelizabeth Apr 30, 2020
dd93b11
remove unused import
alisonelizabeth Apr 30, 2020
3ccc16d
Big refactor to tree rendering structure
jloleysens Apr 30, 2020
b8b169f
Remove unused component
jloleysens Apr 30, 2020
62b0f53
A number of NB changes
jloleysens May 1, 2020
a5bd69a
Merge branch 'feature/ingest-node-pipelines' of github.com:elastic/ki…
jloleysens May 4, 2020
68c12f9
Merge branch 'master' of github.com:elastic/kibana into pipeline-edit…
jloleysens May 4, 2020
3992a29
fix bad conflict resolution
jloleysens May 4, 2020
b88f703
Implemented a slightly better destination resolution algo.
jloleysens May 4, 2020
b05e356
Fix subtle staleness bug, whitelist keys for setValue
jloleysens May 4, 2020
f70165c
NB styling fix!!
jloleysens May 4, 2020
e6f9bd0
Fix stale delete bug too
jloleysens May 4, 2020
fb2733b
Update naming of editor modes and update comments
jloleysens May 7, 2020
74221e4
Use field types combo box
jloleysens May 7, 2020
53c42d9
Add delete confirmation modal
jloleysens May 7, 2020
8617031
Refactor delete modal component file name
jloleysens May 7, 2020
d32b73c
Better visual integration with existing form
jloleysens May 7, 2020
62b3277
Update layout and styling of form
jloleysens May 7, 2020
9e1e698
Move pipeline processor copy into pipeline processor component
jloleysens May 7, 2020
d5b0e8a
First step of refactor to moving between trees
jloleysens May 7, 2020
8e738a2
First iteration of x-tree drag and drop
jloleysens May 7, 2020
39c8dbd
Remove unused import
jloleysens May 7, 2020
1a63baf
Fix jest test types
jloleysens May 7, 2020
e6f4f74
Fix up minor i18n issues and fix up layout of on failure
jloleysens May 7, 2020
830e9e9
Remove unnecessary prop
jloleysens May 7, 2020
41613be
Update spacing above add processor button to make it more center
jloleysens May 7, 2020
c7fe2db
Merge branch 'master' of github.com:elastic/kibana into pipeline-edit…
jloleysens May 8, 2020
eff46b0
Fix destination resolution algo
jloleysens May 8, 2020
0fcdd06
Update dragging resolver unit tests and add a lot more comments
jloleysens May 8, 2020
49def41
Use one sorting algo (removed use of euiReorder for now)
jloleysens May 9, 2020
698d8ff
Add placeholder tests and update comments
jloleysens May 11, 2020
33fe79c
Merge branch 'master' into feature/pipeline-editor
elasticmachine May 11, 2020
b1eb94c
Quite a big refactor
jloleysens May 12, 2020
7d632fc
Fix off by one bug in tests and implementation 🤦🏼‍♂
jloleysens May 12, 2020
b6f0042
Update behaviour for dragging up across trees and add tests
jloleysens May 12, 2020
78b86ad
Fix combine instruction
jloleysens May 12, 2020
6316956
Merge branch 'master' of github.com:elastic/kibana into feature/pipel…
jloleysens May 12, 2020
1688711
Fix test and i18n issues
jloleysens May 12, 2020
07b6df1
Remove background color
jloleysens May 12, 2020
bed0bf8
Fix selector after selector refactor
jloleysens May 13, 2020
99fa8cd
A major performance
jloleysens May 13, 2020
0f477f3
Fix component smoke test
jloleysens May 13, 2020
1fdbf8a
Fix reading value from processor state using processor selector
jloleysens May 13, 2020
ce275fe
[Ingest pipelines] Custom processor form (#66022)
alisonelizabeth May 13, 2020
40e6c71
Merge branch 'master' of github.com:elastic/kibana into feature/pipel…
jloleysens May 18, 2020
6af236d
Re add background color and refactor name of processor item
jloleysens May 18, 2020
f00cfcf
Fix file naming and refactor 🚜 dnd tree rendering
jloleysens May 18, 2020
9591de0
Fix getting of initial on failure processors value
jloleysens May 18, 2020
c1f62df
Update padding styles for containers
jloleysens May 19, 2020
94096ea
A lot of styling updates to get closer to look of mockup
jloleysens May 19, 2020
f06f9e4
Merge branch 'master' of github.com:elastic/kibana into feature/pipel…
jloleysens May 26, 2020
edddeee
A WiP version of th click-tree an alternative to dnd
jloleysens May 20, 2020
971e2e9
Remove dnd tree
jloleysens May 26, 2020
2402cc8
Merge branch 'master' into feature/pipeline-editor
elasticmachine Jun 4, 2020
f2a20c8
clean up reamining dnd tree references
jloleysens Jun 4, 2020
b0387de
Clean up and refactor of tree component
jloleysens Jun 4, 2020
8098fc9
Added the ability to duplicate a processor
jloleysens Jun 4, 2020
5c5a932
Fix types in test
jloleysens Jun 4, 2020
d121586
Added duplicate functionality to ui
jloleysens Jun 4, 2020
1afecdf
Memoize tree components
jloleysens Jun 4, 2020
e43c7a4
address es lint issues
jloleysens Jun 4, 2020
626a61d
remove unused import
jloleysens Jun 4, 2020
24afa02
Fix editing of custom json
jloleysens Jun 4, 2020
58b79a5
Address form performance issues
jloleysens Jun 4, 2020
9ffebad
Add all known missing processors
jloleysens Jun 4, 2020
7caac48
Add ability to cancel move
jloleysens Jun 4, 2020
1095aca
Fix staleness in test and view request flyouts
jloleysens Jun 4, 2020
da8fb67
fix type issue
jloleysens Jun 4, 2020
df4f70a
Remove unused translations and skip funcitonal test for now
jloleysens Jun 5, 2020
e1149bd
add todo comment
jloleysens Jun 5, 2020
243185e
Fix type issues
jloleysens Jun 5, 2020
f646b78
remove poc styles
jloleysens Jun 5, 2020
e884ee2
disable other move buttons if we have a selected processor
jloleysens Jun 5, 2020
180e73f
Refactor drop zone pin to button and add some styling
jloleysens Jun 5, 2020
7e8de28
Refactor processor editor item
jloleysens Jun 5, 2020
fd8dbeb
Update styling and use icon for cancel move action too
jloleysens Jun 5, 2020
64e06c0
fix nasty integration bug
jloleysens Jun 5, 2020
a7ee474
some minor optimizations
jloleysens Jun 5, 2020
9420c87
prevent parent from being placed in own on failure handler
jloleysens Jun 5, 2020
6aea902
Re-add cancel button
jloleysens Jun 8, 2020
2003eb5
Re-introduce failure processors toggle
jloleysens Jun 8, 2020
bc091df
Fix typo
jloleysens Jun 8, 2020
cc66d65
Add Handler types for processor editor item
jloleysens Jun 8, 2020
14c59b0
Fix staleness bug for type, refactor classname and fix duplicate
jloleysens Jun 8, 2020
9844dee
Experimenting with padels (revert this to undo if no further
jloleysens Jun 8, 2020
08247dd
Add description and unique ids
jloleysens Jun 8, 2020
edc7b6e
Share links via component-wide context rather than props
jloleysens Jun 8, 2020
d396be0
Merge branch 'master' into feature/pipeline-editor
elasticmachine Jun 8, 2020
6a1234e
Virtualized list and back to outline dropzones
jloleysens Jun 9, 2020
c8ccb34
Refactor id getter to a service and make it an incrementing number
jloleysens Jun 9, 2020
f10e2d8
Temporary fix for double rendering issue.
jloleysens Jun 9, 2020
bff143e
add todo comment
jloleysens Jun 9, 2020
cc84437
remove euicode element
jloleysens Jun 9, 2020
97089ab
properly handle duplicate flow
jloleysens Jun 9, 2020
3cf7c9f
attempt to fix i18n
jloleysens Jun 9, 2020
bb21d75
split private_tree into it's own component and add comments
jloleysens Jun 9, 2020
22c094a
refactor 🚜. rename Tree to ProcessorsTree and move things around
jloleysens Jun 9, 2020
9267793
do not delete the top level arrays for processors and onfailures
jloleysens Jun 9, 2020
c5a5e4e
fix typescript error
jloleysens Jun 10, 2020
791d9e6
Merge branch 'master' into feature/pipeline-editor
elasticmachine Jun 10, 2020
0b71abe
Move duplicate, addOnFailure and delete actions into ctx menu
jloleysens Jun 10, 2020
94a9c65
remove unused import
jloleysens Jun 10, 2020
fd2789f
add support for pressing esc key to cancel move
jloleysens Jun 10, 2020
90fd933
Add outside click listener
jloleysens Jun 10, 2020
a25056a
always prompt before deleting a processor
jloleysens Jun 10, 2020
e51bf88
refactor remove distinction between adding top level and on fail
jloleysens Jun 10, 2020
1a2b439
add processor button to tree
jloleysens Jun 10, 2020
ef2c745
Hide the add on failure context menu item for processors with
jloleysens Jun 10, 2020
9ba6906
Reinstated x-tree moving and highlight and disable for buttons
jloleysens Jun 10, 2020
1918b8b
removing ids step 1: remove idGenerator
jloleysens Jun 11, 2020
9a5cf06
remove ids step 2: added inline text input
jloleysens Jun 11, 2020
d519513
Slight improvement to styling of text input (border)
jloleysens Jun 11, 2020
8e78aea
Re-implement missing failure toggle test
jloleysens Jun 11, 2020
4624337
address type todo
jloleysens Jun 11, 2020
5ef85cd
Address many type issues and fix yarn.lock
jloleysens Jun 11, 2020
4b05049
re-enable create pipeline functional test
jloleysens Jun 11, 2020
4b26dd4
prevent multiple flyouts from opening
jloleysens Jun 11, 2020
8b3e9f7
change flyout title when editing an on-failure processor
jloleysens Jun 11, 2020
ca2f8d5
absolutely position the failure handlers label
jloleysens Jun 11, 2020
65fb5ff
fix description behaviour not removing tag if empty
jloleysens Jun 11, 2020
dcb23bd
some minor clean up
jloleysens Jun 11, 2020
a242aa7
add onflyoutopen cb to tests
jloleysens Jun 11, 2020
73babef
Merge branch 'master' into feature/pipeline-editor
elasticmachine Jun 11, 2020
1419d3b
Merge branch 'master' into feature/pipeline-editor
elasticmachine Jun 12, 2020
634f9d0
refactor processors editor item to multiple files
jloleysens Jun 12, 2020
7db7f3e
Merge branch 'master' into feature/pipeline-editor
elasticmachine Jun 15, 2020
ec77c7d
fix add on-failure handler in context menu after refactor
jloleysens Jun 15, 2020
7e91996
Merge branch 'master' into feature/pipeline-editor
elasticmachine Jun 16, 2020
a3d0dc8
tag -> new description field
jloleysens Jun 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@
"react-syntax-highlighter": "^5.7.0",
"react-tiny-virtual-list": "^2.2.0",
"react-use": "^13.27.0",
"react-virtualized": "^9.21.2",
"react-vis": "^1.8.1",
"react-visibility-sensor": "^5.1.1",
"recompose": "^0.26.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,6 @@ describe('<PipelinesCreate />', () => {
expect(exists('versionField')).toBe(true);
});

test('should toggle the on-failure processors editor', async () => {
const { actions, component, exists } = testBed;

// On-failure editor should be hidden by default
expect(exists('onFailureEditor')).toBe(false);

await act(async () => {
actions.toggleOnFailureSwitch();
await nextTick();
component.update();
});

expect(exists('onFailureEditor')).toBe(true);
});

test('should show the request flyout', async () => {
const { actions, component, find, exists } = testBed;

Expand Down
14 changes: 10 additions & 4 deletions x-pack/plugins/ingest_pipelines/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/

interface Processor {
[key: string]: {
[key: string]: unknown;
};
export interface ESProcessorConfig {
on_failure?: Processor[];
ignore_failure?: boolean;
if?: string;
tag?: string;
[key: string]: any;
}

export interface Processor {
[typeName: string]: ESProcessorConfig;
}

export interface Pipeline {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { useState } from 'react';
import React, { useState, useCallback, useRef } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiButton, EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui';

Expand All @@ -16,6 +16,11 @@ import { PipelineTestFlyout } from './pipeline_test_flyout';
import { PipelineFormFields } from './pipeline_form_fields';
import { PipelineFormError } from './pipeline_form_error';
import { pipelineFormSchema } from './schema';
import {
OnUpdateHandlerArg,
OnUpdateHandler,
SerializeResult,
} from '../pipeline_processors_editor';

export interface PipelineFormProps {
onSave: (pipeline: Pipeline) => void;
Expand All @@ -30,8 +35,8 @@ export const PipelineForm: React.FunctionComponent<PipelineFormProps> = ({
defaultValue = {
name: '',
description: '',
processors: '',
on_failure: '',
processors: [],
on_failure: [],
version: '',
},
onSave,
Expand All @@ -44,10 +49,25 @@ export const PipelineForm: React.FunctionComponent<PipelineFormProps> = ({

const [isTestingPipeline, setIsTestingPipeline] = useState<boolean>(false);

const processorStateRef = useRef<OnUpdateHandlerArg>();

const handleSave: FormConfig['onSubmit'] = async (formData, isValid) => {
if (isValid) {
onSave(formData as Pipeline);
let override: SerializeResult | undefined;

if (!isValid) {
return;
}

if (processorStateRef.current) {
const processorsState = processorStateRef.current;
if (await processorsState.validate()) {
override = processorsState.getData();
} else {
return;
}
}

onSave({ ...formData, ...(override || {}) } as Pipeline);
};

const handleTestPipelineClick = () => {
Expand All @@ -60,6 +80,10 @@ export const PipelineForm: React.FunctionComponent<PipelineFormProps> = ({
onSubmit: handleSave,
});

const onEditorFlyoutOpen = useCallback(() => {
setIsRequestVisible(false);
}, [setIsRequestVisible]);

const saveButtonLabel = isSaving ? (
<FormattedMessage
id="xpack.ingestPipelines.form.savingButtonLabel"
Expand All @@ -77,6 +101,11 @@ export const PipelineForm: React.FunctionComponent<PipelineFormProps> = ({
/>
);

const onProcessorsChangeHandler = useCallback<OnUpdateHandler>(
(arg) => (processorStateRef.current = arg),
[]
);

return (
<>
<Form
Expand All @@ -90,10 +119,13 @@ export const PipelineForm: React.FunctionComponent<PipelineFormProps> = ({

{/* All form fields */}
<PipelineFormFields
onEditorFlyoutOpen={onEditorFlyoutOpen}
initialProcessors={defaultValue.processors}
initialOnFailureProcessors={defaultValue.on_failure}
onProcessorsUpdate={onProcessorsChangeHandler}
hasVersion={Boolean(defaultValue.version)}
isTestButtonDisabled={isTestingPipeline || form.isValid === false}
onTestPipelineClick={handleTestPipelineClick}
hasOnFailure={Boolean(defaultValue.on_failure)}
isEditing={isEditing}
/>

Expand Down Expand Up @@ -147,13 +179,19 @@ export const PipelineForm: React.FunctionComponent<PipelineFormProps> = ({
{/* ES request flyout */}
{isRequestVisible ? (
<PipelineRequestFlyout
readProcessors={() =>
processorStateRef.current?.getData() || { processors: [], on_failure: [] }
}
closeFlyout={() => setIsRequestVisible((prevIsRequestVisible) => !prevIsRequestVisible)}
/>
) : null}

{/* Test pipeline flyout */}
{isTestingPipeline ? (
<PipelineTestFlyout
readProcessors={() =>
processorStateRef.current?.getData() || { processors: [], on_failure: [] }
}
closeFlyout={() => {
setIsTestingPipeline((prevIsTestingPipeline) => !prevIsTestingPipeline);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,41 @@

import React, { useState } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { EuiButton, EuiSpacer, EuiSwitch, EuiLink } from '@elastic/eui';
import { EuiSpacer, EuiSwitch } from '@elastic/eui';

import {
getUseField,
getFormRow,
Field,
JsonEditorField,
useKibana,
} from '../../../shared_imports';
import { Processor } from '../../../../common/types';
import { FormDataProvider } from '../../../shared_imports';
import { PipelineProcessorsEditor, OnUpdateHandler } from '../pipeline_processors_editor';

import { getUseField, getFormRow, Field, useKibana } from '../../../shared_imports';

interface Props {
initialProcessors: Processor[];
initialOnFailureProcessors?: Processor[];
onProcessorsUpdate: OnUpdateHandler;
hasVersion: boolean;
hasOnFailure: boolean;
isTestButtonDisabled: boolean;
onTestPipelineClick: () => void;
onEditorFlyoutOpen: () => void;
isEditing?: boolean;
}

const UseField = getUseField({ component: Field });
const FormRow = getFormRow({ titleTag: 'h3' });

export const PipelineFormFields: React.FunctionComponent<Props> = ({
initialProcessors,
initialOnFailureProcessors,
onProcessorsUpdate,
isEditing,
hasVersion,
hasOnFailure,
isTestButtonDisabled,
onTestPipelineClick,
onEditorFlyoutOpen,
}) => {
const { services } = useKibana();

const [isVersionVisible, setIsVersionVisible] = useState<boolean>(hasVersion);
const [isOnFailureEditorVisible, setIsOnFailureEditorVisible] = useState<boolean>(hasOnFailure);

return (
<>
Expand Down Expand Up @@ -110,127 +112,32 @@ export const PipelineFormFields: React.FunctionComponent<Props> = ({
/>
</FormRow>

{/* Processors field */}
<FormRow
title={
<FormattedMessage
id="xpack.ingestPipelines.form.processorsFieldTitle"
defaultMessage="Processors"
/>
}
description={
<>
<FormattedMessage
id="xpack.ingestPipelines.form.processorsFieldDescription"
defaultMessage="The processors to use to transform the documents before indexing. {learnMoreLink}"
values={{
learnMoreLink: (
<EuiLink
href={services.documentation.getProcessorsUrl()}
target="_blank"
external
>
{i18n.translate('xpack.ingestPipelines.form.processorsDocumentionLink', {
defaultMessage: 'Learn more',
})}
</EuiLink>
),
}}
/>

<EuiSpacer />
{/* Pipeline Processors Editor */}
<FormDataProvider pathsToWatch={['processors', 'on_failure']}>
{({ processors, on_failure: onFailure }) => {
const processorProp =
typeof processors === 'string' && processors
? JSON.parse(processors)
: initialProcessors ?? [];

<EuiButton
size="s"
onClick={onTestPipelineClick}
disabled={isTestButtonDisabled}
data-test-subj="testPipelineButton"
>
<FormattedMessage
id="xpack.ingestPipelines.form.testPipelineButtonLabel"
defaultMessage="Test pipeline"
/>
</EuiButton>
</>
}
>
<UseField
path="processors"
component={JsonEditorField}
componentProps={{
euiCodeEditorProps: {
'data-test-subj': 'processorsEditor',
height: '300px',
'aria-label': i18n.translate('xpack.ingestPipelines.form.processorsFieldAriaLabel', {
defaultMessage: 'Processors JSON editor',
}),
},
}}
/>
</FormRow>
const onFailureProp =
typeof onFailure === 'string' && onFailure
? JSON.parse(onFailure)
: initialOnFailureProcessors ?? [];

{/* On-failure field */}
<FormRow
title={
<FormattedMessage
id="xpack.ingestPipelines.form.onFailureTitle"
defaultMessage="Failure processors"
/>
}
description={
<>
<FormattedMessage
id="xpack.ingestPipelines.form.onFailureDescription"
defaultMessage="The alternate processors to execute after a processor fails. {learnMoreLink}"
values={{
learnMoreLink: (
<EuiLink
href={services.documentation.getHandlingFailureUrl()}
target="_blank"
external
>
{i18n.translate('xpack.ingestPipelines.form.onFailureDocumentionLink', {
defaultMessage: 'Learn more',
})}
</EuiLink>
),
}}
/>
<EuiSpacer size="m" />
<EuiSwitch
label={
<FormattedMessage
id="xpack.ingestPipelines.form.onFailureToggleDescription"
defaultMessage="Add failure processors"
/>
}
checked={isOnFailureEditorVisible}
onChange={(e) => setIsOnFailureEditorVisible(e.target.checked)}
data-test-subj="onFailureToggle"
return (
<PipelineProcessorsEditor
onFlyoutOpen={onEditorFlyoutOpen}
learnMoreAboutProcessorsUrl={services.documentation.getProcessorsUrl()}
learnMoreAboutOnFailureProcessorsUrl={services.documentation.getHandlingFailureUrl()}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these URLs ever change? I'm surprised to see them being passed as props, but then I don't know what the convention is in Kibana.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these URLs ever change?

yeah, they change based on the version of stack you are running. So if you are on v7.7.0 all links to docs should send you to the correct v7.7.0 docs.

The idea with passing them in as props here is so that this component can be moved out of the ingest pipelines editor in future without depending on plugin specific ways of sharing these values like context or services.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Cloud UI has a docs "service" of sorts, which defines a map of doc links, and then renders links using config to control the docs version. I'm not suggested you implement that, just sharing 😅

isTestButtonDisabled={isTestButtonDisabled}
onTestPipelineClick={onTestPipelineClick}
onUpdate={onProcessorsUpdate}
value={{ processors: processorProp, onFailure: onFailureProp }}
/>
</>
}
>
{isOnFailureEditorVisible ? (
<UseField
path="on_failure"
component={JsonEditorField}
componentProps={{
euiCodeEditorProps: {
'data-test-subj': 'onFailureEditor',
height: '300px',
'aria-label': i18n.translate('xpack.ingestPipelines.form.onFailureFieldAriaLabel', {
defaultMessage: 'Failure processors JSON editor',
}),
},
}}
/>
) : (
// <FormRow/> requires children or a field
// For now, we return an empty <div> if the editor is not visible
<div />
)}
</FormRow>
);
}}
</FormDataProvider>
</>
);
};
Loading