-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Improvements to threshold watch #36688
Conversation
3a21a9f
to
76936da
Compare
Pinging @elastic/es-ui |
💔 Build Failed |
76936da
to
5beab8a
Compare
💚 Build Succeeded |
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}} | ||
/> | ||
</EuiFormRow> | ||
<EuiFlexGroup justifyContent="spaceBetween"> |
There was a problem hiding this comment.
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?
<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 });
}}
/>
There was a problem hiding this comment.
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' }}> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me!
💔 Build Failed |
@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:
|
💔 Build Failed |
fbc229d
to
a7d39c0
Compare
💚 Build Succeeded |
There was a problem hiding this 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] || ''} |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 || |
There was a problem hiding this comment.
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)
)}
There was a problem hiding this comment.
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!
💚 Build Succeeded |
This PR fixes/improves a few things on the threshold watch page:
indices
form row full width to give the combo box a little more roomuse_request
hook; this adds support for error stateScreenshots