Skip to content

Commit

Permalink
Remove error state from form
Browse files Browse the repository at this point in the history
We already did this for the users flyout. Basically changes the dirty state of the form from an error state to just showing “Required”. i18n had not been translated yet for `ATTRIBUTE_VALUE_ERROR`
  • Loading branch information
scottybollinger committed Jun 24, 2021
1 parent 5d840ce commit 96507ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import React from 'react';

import { shallow, ShallowWrapper } from 'enzyme';

import { EuiComboBox, EuiFieldText } from '@elastic/eui';
import { EuiComboBox, EuiFieldText, EuiFormRow } from '@elastic/eui';

import { AttributeName } from '../types';

import { AttributeSelector } from './attribute_selector';
import { ANY_AUTH_PROVIDER, ANY_AUTH_PROVIDER_OPTION_LABEL } from './constants';
import { ANY_AUTH_PROVIDER, ANY_AUTH_PROVIDER_OPTION_LABEL, REQUIRED_LABEL } from './constants';

const handleAttributeSelectorChange = jest.fn();
const handleAttributeValueChange = jest.fn();
Expand Down Expand Up @@ -166,5 +166,12 @@ describe('AttributeSelector', () => {
baseProps.elasticsearchRoles[0]
);
});

it('shows helpText when attributeValueInvalid', () => {
const wrapper = shallow(<AttributeSelector {...baseProps} attributeValueInvalid />);
const formRow = wrapper.find(EuiFormRow).at(2);

expect(formRow.prop('helpText')).toEqual(REQUIRED_LABEL);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
ANY_AUTH_PROVIDER,
ANY_AUTH_PROVIDER_OPTION_LABEL,
ATTRIBUTE_VALUE_LABEL,
ATTRIBUTE_VALUE_ERROR,
REQUIRED_LABEL,
AUTH_ANY_PROVIDER_LABEL,
AUTH_INDIVIDUAL_PROVIDER_LABEL,
AUTH_PROVIDER_LABEL,
Expand Down Expand Up @@ -129,8 +129,7 @@ export const AttributeSelector: React.FC<Props> = ({
<EuiFormRow
label={ATTRIBUTE_VALUE_LABEL}
fullWidth
isInvalid={attributeValueInvalid}
error={[ATTRIBUTE_VALUE_ERROR]}
helpText={attributeValueInvalid && REQUIRED_LABEL}
>
{attributeName === 'role' ? (
<EuiSelect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ export const ATTRIBUTE_VALUE_LABEL = i18n.translate(
}
);

export const ATTRIBUTE_VALUE_ERROR = i18n.translate(
'xpack.enterpriseSearch.roleMapping.attributeValueError',
{
defaultMessage: 'Attribute value is required',
}
);

export const REMOVE_ROLE_MAPPING_TITLE = i18n.translate(
'xpack.enterpriseSearch.roleMapping.removeRoleMappingTitle',
{
Expand Down

0 comments on commit 96507ee

Please sign in to comment.