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

adding validation and UI feedback for threshold watch expression #34948

Merged
merged 8 commits into from
Apr 12, 2019

Conversation

bmcconaghy
Copy link
Contributor

This PR adds in validation for the threshold watch expression and fixes a few things with the validation for the other form fields on the threshold watch edit screen.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bmcconaghy looking good! left a few comments.

}));
errors.index.push(
i18n.translate(
'xpack.watcher.sections.watchEdit.titlePanel.enterOneOrMoreIndicesValidationMessage',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should the i18n strings follow a consistent pattern?

xpack.watcher.sections.watchEdit.threshold.error.requiredNameText (above) vs.
xpack.watcher.sections.watchEdit.titlePanel.enterOneOrMoreIndicesValidationMessage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll want to go through and fix all these at some point. These were copied from the existing ones, but I think I'd rather fix the naming all in one go as a different PR.

value={groupByTypes[watch.groupBy].text}
isActive={groupByPopoverOpen}
value={`${groupByTypes[watch.groupBy].text} ${
watch.groupBy === 'all'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think there's a constants file that can probably be used here instead of hard-coding all - group_by_types.ts

defaultMessage: 'Please fix the errors in the expression below.',
}
);
const expressionFields = ['termSize', 'termField', 'threshold', 'timeWindowSize'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should aggField be added to this as well?

Screen Shot 2019-04-11 at 2 42 39 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup good catch

value={`${groupByTypes[watch.groupBy].text} ${
watch.groupBy === 'all'
? ''
: (watch.termSize || '') +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think this would be easier to read using template literals?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is gross, will see if I can clean it up

@@ -403,11 +420,12 @@ const ThresholdWatchEditUi = ({
button={
<EuiExpression
description={`OF`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be translated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, a few other places need it too

@@ -421,34 +439,39 @@ const ThresholdWatchEditUi = ({
<EuiPopoverTitle>of</EuiPopoverTitle>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@bmcconaghy
Copy link
Contributor Author

@alisonelizabeth pushed fixes for those things, thanks for finding them. Can you take another look?

@elasticmachine
Copy link
Contributor

💔 Build Failed

@bmcconaghy
Copy link
Contributor Author

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@alisonelizabeth
Copy link
Contributor

@bmcconaghy thanks for making the changes!

a couple other small things i noticed while testing:

  • I think we should probably follow the old implementation and not display the expression until an index is selected
  • thanks for adding aggField to the validation. is it also possible to set the popover to open in this scenario?

Screen Shot 2019-04-12 at 9 00 21 AM

@bmcconaghy
Copy link
Contributor Author

@alisonelizabeth fixed the things you found, thanks again for good spotting. Re: opening up the popovers for errors, I think that could get messy as there could be more than one error and having all those popovers open at the same time would be confusing. Mind taking another look?

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@bmcconaghy bmcconaghy merged commit ed4701e into elastic:watcher-port Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants