[WATCHER] remove validation for email action body attribute (#42009) (#42181)

This commit is contained in:
Alison Goryachev 2019-07-29 15:58:53 -04:00 committed by GitHub
parent 149fc700aa
commit 45740d858a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 26 deletions

View file

@ -421,13 +421,7 @@ describe.skip('<ThresholdWatchEdit /> create route', () => {
expect(exists('watchActionAccordion')).toBe(true);
// First, provide invalid fields and verify
form.setInputValue('emailBodyInput', '');
expect(form.getErrorsMessages()).toContain('Email body is required.');
expect(find('simulateActionButton').props().disabled).toEqual(true);
// Next, provide valid field and verify
// Provide valid fields and verify
find('watchActionAccordion.mockComboBox').simulate('change', [
{ label: EMAIL_RECIPIENT, value: EMAIL_RECIPIENT },
]); // Using mocked EuiComboBox

View file

@ -34,7 +34,6 @@ export class EmailAction extends BaseAction {
validate() {
const errors = {
to: [],
body: [],
};
if (!this.to || !this.to.length) {
@ -44,13 +43,6 @@ export class EmailAction extends BaseAction {
})
);
}
if (!this.body) {
errors.body.push(
i18n.translate('xpack.watcher.watchActions.email.emailBodyIsRequiredValidationMessage', {
defaultMessage: 'Email body is required.',
})
);
}
return errors;
}

View file

@ -87,12 +87,8 @@ export const EmailActionFields: React.FunctionComponent<Props> = ({
/>
</EuiFormRow>
<ErrableFormRow
id="emailBody"
errorKey="body"
<EuiFormRow
fullWidth
errors={errors}
isShowingErrors={hasErrors && body !== undefined}
label={i18n.translate(
'xpack.watcher.sections.watchEdit.threshold.emailAction.bodyTextAreaFieldLabel',
{
@ -108,13 +104,8 @@ export const EmailActionFields: React.FunctionComponent<Props> = ({
onChange={e => {
editAction({ key: 'body', value: e.target.value });
}}
onBlur={() => {
if (!body) {
editAction({ key: 'body', value: '' });
}
}}
/>
</ErrableFormRow>
</EuiFormRow>
</Fragment>
);
};