diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/field_components/drag_and_drop_text_list.scss b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/field_components/drag_and_drop_text_list.scss index a30c50df2cc9..2f563d86a6d4 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/field_components/drag_and_drop_text_list.scss +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/field_components/drag_and_drop_text_list.scss @@ -1,6 +1,7 @@ .pipelineProcessorsEditor__form__dragAndDropList { &__panel { - box-shadow: none; + background-color: $euiColorLightestShade; + padding: $euiSizeM; } &__grabIcon { @@ -16,9 +17,12 @@ } &__item { - background-color: $euiColorEmptyShade; - padding-top: $euiSizeM; - padding-bottom: $euiSizeM; - border-bottom: $euiBorderThin; + background-color: $euiColorLightestShade; + padding-top: $euiSizeS; + padding-bottom: $euiSizeS; + } + + &__labelContainer { + margin-bottom: $euiSizeXS; } } diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/field_components/drag_and_drop_text_list.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/field_components/drag_and_drop_text_list.tsx index f029eea1db4f..63e1fdaa9a8f 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/field_components/drag_and_drop_text_list.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/field_components/drag_and_drop_text_list.tsx @@ -16,10 +16,10 @@ import { EuiFlexGroup, EuiFlexItem, EuiIcon, - EuiPanel, - EuiSpacer, EuiFieldText, EuiIconTip, + EuiFormRow, + EuiText, } from '@elastic/eui'; import { @@ -32,6 +32,9 @@ import { import './drag_and_drop_text_list.scss'; interface Props { + label: string; + helpText: React.ReactNode; + error: string | null; value: ArrayItem[]; onMove: (sourceIdx: number, destinationIdx: number) => void; onAdd: () => void; @@ -51,6 +54,9 @@ const i18nTexts = { }; function DragAndDropTextListComponent({ + label, + helpText, + error, value, onMove, onAdd, @@ -59,6 +65,7 @@ function DragAndDropTextListComponent({ textValidation, }: Props): JSX.Element { const [droppableId] = useState(() => uuid.v4()); + const [firstItemId] = useState(() => uuid.v4()); const onDragEnd = useCallback( ({ source, destination }) => { @@ -69,110 +76,132 @@ function DragAndDropTextListComponent({ [onMove] ); return ( - - - - {value.map((item, idx) => { - return ( - - {(provided) => { - return ( - - -
- -
-
- - - path={item.path} - config={{ - validations: textValidation - ? [{ validator: textValidation }] - : undefined, - }} - readDefaultValueOnForm={!item.isNew} + + <> + {/* Label and help text. Also wire up the htmlFor so the label points to the first text field. */} + + + + + + + + +

{helpText}

+
+
+
+ + {/* The processor panel */} +
+ + + {value.map((item, idx) => { + return ( + + {(provided) => { + return ( + - {(field) => { - const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage( - field - ); - return ( - - - - - {typeof errorMessage === 'string' && ( - -
- +
+ +
+ + + + path={item.path} + config={{ + validations: textValidation + ? [{ validator: textValidation }] + : undefined, + }} + readDefaultValueOnForm={!item.isNew} + > + {(field) => { + const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage( + field + ); + return ( + + + -
-
- )} -
- ); - }} - - - - {value.length > 1 ? ( - onRemove(item.id)} - /> - ) : ( - // Render a no-op placeholder button - - )} - -
- ); - }} -
- ); - })} -
-
- {value.length ? : null} - - {addLabel} - - + + {typeof errorMessage === 'string' && ( + +
+ +
+
+ )} + + ); + }} + + + + {value.length > 1 ? ( + onRemove(item.id)} + /> + ) : ( + // Render a no-op placeholder button + + )} + + + ); + }} + + ); + })} + + + + {addLabel} + +
+ +
); } diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/processors/grok.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/processors/grok.tsx index 40ddeddc0c4e..5df30be3407a 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/processors/grok.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/processor_form/processors/grok.tsx @@ -6,7 +6,6 @@ import React, { FunctionComponent } from 'react'; import { i18n } from '@kbn/i18n'; -import { EuiFormRow } from '@elastic/eui'; import { FIELD_TYPES, @@ -124,22 +123,17 @@ export const Grok: FunctionComponent = () => { {({ items, addItem, removeItem, moveItem, error }) => { return ( - - - + value={items} + onMove={moveItem} + onAdd={addItem} + onRemove={removeItem} + addLabel={i18nTexts.addPatternLabel} + textValidation={patternValidation} + /> ); }}