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

Clean up error state of Ingest Pipelines drag and drop list items. #137244

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
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