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

Improvements to threshold watch #36688

Conversation

alisonelizabeth
Copy link
Contributor

@alisonelizabeth alisonelizabeth commented May 20, 2019

This PR fixes/improves a few things on the threshold watch page:

  • Changed watch actions select dropdown to EUI context menu
  • UI improvements to threshold watch form
    • Webhook action form fields inline (I think the original suggestion was to make this one text field, e.g., "webhook url", however, since the advanced watch and threshold watch share some of the same logic, this makes it a little more complicated. I think it's something we can maybe revisit in phase II)
    • Added title to EUI expression
    • Made the indices form row full width to give the combo box a little more room
    • Fixed misalignment of comparator fields when invalid
  • Added validation for negative interval, no time field
  • Removed hard-coded string and cleaned up time options logic
  • Updated watch_visualization.tsx to use the use_request hook; this adds support for error state

Screenshots

Screen Shot 2019-05-20 at 9 15 37 AM

Screen Shot 2019-05-20 at 9 14 30 AM

Screen Shot 2019-05-09 at 4 12 12 PM

Screen Shot 2019-05-20 at 9 14 18 AM

Screen Shot 2019-05-20 at 9 14 49 AM

Screen Shot 2019-05-20 at 9 14 58 AM

Screen Shot 2019-05-20 at 9 16 21 AM

@alisonelizabeth alisonelizabeth added Feature:Watcher non-issue Indicates to automation that a pull request should not appear in the release notes labels May 20, 2019
@alisonelizabeth alisonelizabeth added the Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more label May 20, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@alisonelizabeth alisonelizabeth changed the title Threshold actions improvements Improvements to threshold watch May 20, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

This looks awesome! I just had a couple suggestions.

Also, I spotted this console warning but didn't dig into it.

image

}}
/>
</EuiFormRow>
<EuiFlexGroup justifyContent="spaceBetween">
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of prepending the port and path fields with a colon and slash to hint to the user that they don't need to supply those?

image

            <EuiFieldNumber
              prepend={(
                <EuiText size="xs">
                  <strong>:</strong>
                </EuiText>
              )}
              fullWidth
              name="port"
              value={port || ''}
              onChange={e => {
                editAction({ key: 'port', value: parseInt(e.target.value, 10) });
              }}
              onBlur={() => {
                if (!port) {
                  editAction({ key: 'port', value: '' });
                }
              }}
            />
            <EuiFieldText
              prepend={(
                <EuiText size="xs">
                  <strong>/</strong>
                </EuiText>
              )}
              fullWidth
              name="path"
              value={path || ''}
              onChange={e => {
                editAction({ key: 'path', value: e.target.value });
              }}
            />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea, thanks! Updated the code.

}}
>
<EuiFlexGroup>
<EuiFlexItem grow={false} style={{ alignSelf: 'center' }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

We have to avoid inline styles in order to not violate our CSP. Can you create a custom class instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch - fixed!

const theFields = await getFields(indices);
setFields(theFields);
setWatchProperty('timeFields', theFields);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit: can we use a name that identifies these fields a bit more than "theFields"? e.g. "timeFields"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, it is a little confusing. This is used in a couple different places of the code in reference to all ES fields, and then there is some manipulation in areas to filter only time fields. I renamed this to esFields, and timeFields, where used. Let me know if you think that's clearer.

@@ -383,10 +384,19 @@ const ThresholdWatchEditUi = ({ intl, pageTitle }: { intl: InjectedIntl; pageTit
<EuiSpacer />
{shouldShowThresholdExpression ? (
<Fragment>
<EuiTitle size="s">
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use EuiHelpText placed below the expression instead of this error between the title and expression? I think this will follow the pattern of how we surface other field-level errors. And I think we can simplify the error message to "Your expression has errors."

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion.

I don't think the EuiExpression comes with help text out of the box. However, I went ahead and moved the EuiText that existed for this below the expression and reduced the font. Let me know what you think.

Screen Shot 2019-05-21 at 8 36 45 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks great to me!

@elasticmachine
Copy link
Contributor

💔 Build Failed

@alisonelizabeth
Copy link
Contributor Author

alisonelizabeth commented May 21, 2019

@cjcenizal thanks for the feedback!

I believe I addressed all of your comments, if you can take another look when you get a chance. I also fixed a couple other things I noticed while I was making changes:

  • I noticed the chart was a little glitchy with the reloads, so updated the useEffect hook to only be called when relevant watch props have changed
  • Updated Save button to secondary color with icon and loading state; also made text dynamic depending on if it's a new watch or editing an existing watch
  • Fixed another react warning related to a number input changing from uncontrolled to controlled

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

LGTM! Just had a couple questions.

@@ -716,7 +717,7 @@ const ThresholdWatchEditUi = ({ intl, pageTitle }: { intl: InjectedIntl; pageTit
errors={errors}
>
<EuiFieldNumber
value={watch.threshold[i]}
value={watch.threshold[i] || ''}
Copy link
Contributor

Choose a reason for hiding this comment

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

If watch.threshold[i] is 0 then this will set value to the empty string. Is that what we want? Or should we check for undefined and null instead of just falsiness, e.g. watch.threshold[i] == null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, fixed.

@@ -655,8 +662,8 @@ const ThresholdWatchEditUi = ({ intl, pageTitle }: { intl: InjectedIntl; pageTit
.join(` ${andThresholdText} `)}
isActive={
watchThresholdPopoverOpen ||
errors.threshold0.length ||
(errors.threshold1 && errors.threshold1.length)
!!errors.threshold0.length ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also wrap this expression inside of Boolean to achieve the same effect? Might be a bit simpler to read.

isActive={Boolean(
  watchThresholdPopoverOpen ||
  errors.threshold0.length ||
  (errors.threshold1 && errors.threshold1.length)
)}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed. thanks for the suggestion - fixed!

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@alisonelizabeth alisonelizabeth merged commit 84a5905 into elastic:watcher-port May 22, 2019
@alisonelizabeth alisonelizabeth deleted the threshold-actions-improvements branch May 22, 2019 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Watcher non-issue Indicates to automation that a pull request should not appear in the release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants