Skip to content

Commit

Permalink
Clean up error state of Ingest Pipelines drag and drop list items. (#…
Browse files Browse the repository at this point in the history
…137244)

(cherry picked from commit 405c904)
  • Loading branch information
CJ Cenizal committed Jul 29, 2022
1 parent dc72962 commit 90f01ca
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ describe('Processor: Grok', () => {
const {
actions: { saveNewProcessor },
form,
exists,
} = testBed;

// Click submit button with only the type defined
await saveNewProcessor();

// Expect form error as "field" is a required parameter
expect(form.getErrorsMessages()).toEqual(['A field value is required.']);
// Patterns field is also required; it uses EuiDraggable and only shows an error icon when invalid
expect(exists('droppableList.errorIcon')).toBe(true);
expect(form.getErrorsMessages()).toEqual([
'A field value is required.', // "Field" input
'A value is required.', // First input in "Patterns" list
]);
});

test('saves with default parameter values', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ type TestSubject =
| 'copyFromInput'
| 'trimSwitch.input'
| 'droppableList.addButton'
| 'droppableList.errorIcon'
| 'droppableList.input-0'
| 'droppableList.input-1'
| 'droppableList.input-2';
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@
padding: $euiSizeM;
}

&__grabIcon {
margin-right: $euiSizeS;
}

&__removeButton {
margin-left: $euiSizeS;
}

&__errorIcon {
margin-left: -$euiSizeXL;
}

&__item {
background-color: $euiColorLightestShade;
padding-top: $euiSizeS;
Expand All @@ -26,3 +18,11 @@
margin-bottom: $euiSizeXS;
}
}

.pipelineProcessorsEditor__form__dragAndDropList__grabIcon {
height: $euiSizeXL;
width: $euiSizeXL;
display: flex;
align-items: center;
justify-content: center;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
EuiFlexItem,
EuiIcon,
EuiFieldText,
EuiIconTip,
EuiFormRow,
EuiText,
} from '@elastic/eui';
Expand Down Expand Up @@ -133,15 +132,14 @@ function DragAndDropTextListComponent({
<EuiFlexGroup
className="pipelineProcessorsEditor__form__dragAndDropList__item"
justifyContent="center"
alignItems="center"
gutterSize="none"
>
<EuiFlexItem grow={false}>
<div {...provided.dragHandleProps}>
<EuiIcon
className="pipelineProcessorsEditor__form__dragAndDropList__grabIcon"
type="grab"
/>
<div
{...provided.dragHandleProps}
className="pipelineProcessorsEditor__form__dragAndDropList__grabIcon"
>
<EuiIcon type="grab" />
</div>
</EuiFlexItem>
<EuiFlexItem>
Expand All @@ -160,34 +158,17 @@ function DragAndDropTextListComponent({
const { isInvalid, errorMessage } =
getFieldValidityAndErrorMessage(field);
return (
<EuiFlexGroup gutterSize="none" alignItems="center">
<EuiFlexItem>
<EuiFieldText
data-test-subj={`input-${idx}`}
id={idx === 0 ? firstItemId : undefined}
isInvalid={isInvalid}
value={field.value}
onChange={field.onChange}
compressed
fullWidth
/>
</EuiFlexItem>
{typeof errorMessage === 'string' && (
<EuiFlexItem grow={false}>
<div
className="pipelineProcessorsEditor__form__dragAndDropList__errorIcon"
data-test-subj="errorIcon"
>
<EuiIconTip
aria-label={errorMessage}
content={errorMessage}
type="alert"
color="danger"
/>
</div>
</EuiFlexItem>
)}
</EuiFlexGroup>
<EuiFormRow isInvalid={isInvalid} error={errorMessage} fullWidth>
<EuiFieldText
data-test-subj={`input-${idx}`}
id={idx === 0 ? firstItemId : undefined}
isInvalid={isInvalid}
value={field.value}
onChange={field.onChange}
compressed
fullWidth
/>
</EuiFormRow>
);
}}
</UseField>
Expand All @@ -200,6 +181,7 @@ function DragAndDropTextListComponent({
iconType="minusInCircle"
color="danger"
onClick={() => onRemove(item.id)}
size="s"
/>
) : (
// Render a no-op placeholder button
Expand Down

0 comments on commit 90f01ca

Please sign in to comment.