Skip to content

Commit

Permalink
Implement PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Sep 14, 2020
1 parent 9f65205 commit 6852cb8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
margin-left: $euiSizeS;
}

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

&__item {
background-color: $euiColorEmptyShade;
padding-top: $euiSizeM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
EuiPanel,
EuiSpacer,
EuiFieldText,
EuiIconTip,
} from '@elastic/eui';

import {
Expand Down Expand Up @@ -77,7 +78,13 @@ function DragAndDropTextListComponent({
<EuiDroppable droppableId={droppableId}>
{value.map((item, idx) => {
return (
<EuiDraggable spacing="none" draggableId={String(item.id)} index={idx} key={item.id}>
<EuiDraggable
customDragHandle
spacing="none"
draggableId={String(item.id)}
index={idx}
key={item.id}
>
{(provided) => {
return (
<EuiFlexGroup
Expand Down Expand Up @@ -105,27 +112,53 @@ function DragAndDropTextListComponent({
readDefaultValueOnForm={!item.isNew}
>
{(field) => {
const { isInvalid } = getFieldValidityAndErrorMessage(field);
const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(
field
);
return (
<EuiFieldText
isInvalid={isInvalid}
value={field.value}
onChange={field.onChange}
compressed
fullWidth
/>
<EuiFlexGroup gutterSize="none" alignItems="center">
<EuiFlexItem>
<EuiFieldText
isInvalid={isInvalid}
value={field.value}
onChange={field.onChange}
compressed
fullWidth
/>
</EuiFlexItem>
{typeof errorMessage === 'string' && (
<EuiFlexItem grow={false}>
<div className="pipelineProcessorsEditor__form__dragAndDropList__errorIcon">
<EuiIconTip
aria-label={errorMessage}
content={errorMessage}
type="alert"
color="danger"
/>
</div>
</EuiFlexItem>
)}
</EuiFlexGroup>
);
}}
</UseField>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
aria-label={i18nTexts.removeItemButtonAriaLabel}
className="pipelineProcessorsEditor__form__dragAndDropList__removeButton"
iconType="minusInCircle"
color="danger"
onClick={() => onRemove(item.id)}
/>
{value.length > 1 ? (
<EuiButtonIcon
aria-label={i18nTexts.removeItemButtonAriaLabel}
className="pipelineProcessorsEditor__form__dragAndDropList__removeButton"
iconType="minusInCircle"
color="danger"
onClick={() => onRemove(item.id)}
/>
) : (
// Render a no-op placeholder button
<EuiIcon
className="pipelineProcessorsEditor__form__dragAndDropList__removeButton"
type="empty"
/>
)}
</EuiFlexItem>
</EuiFlexGroup>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ export const ManageProcessorForm: FunctionComponent<Props> = ({
onSubmit: handleSubmit,
});

const { subscribe } = form;

useEffect(() => {
const subscription = form.subscribe(onFormUpdate);
const subscription = subscribe(onFormUpdate);
return subscription.unsubscribe;
}, [onFormUpdate, form]);
}, [onFormUpdate, subscribe]);

return (
<ViewComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ window.Worker = function () {
(this as any).terminate = () => {};
};

// disable all react-beautiful-dnd development warnings
(window as any)['__react-beautiful-dnd-disable-dev-warnings'] = true;

describe('<Grok/>', () => {
const setup = (props?: { defaultValue: Record<string, any> }) => {
function MyComponent() {
Expand All @@ -43,6 +40,16 @@ describe('<Grok/>', () => {
}
return mount(<MyComponent />);
};

beforeAll(() => {
// disable all react-beautiful-dnd development warnings
(window as any)['__react-beautiful-dnd-disable-dev-warnings'] = true;
});

afterAll(() => {
// enable all react-beautiful-dnd development warnings
(window as any)['__react-beautiful-dnd-disable-dev-warnings'] = false;
});
test('smoke', () => {
setup({ defaultValue: { type: 'grok', fields: { patterns: ['test'] } } });
});
Expand Down

0 comments on commit 6852cb8

Please sign in to comment.