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

Fix issue with "Infinity" value not working #12980

Conversation

stacey-gammon
Copy link
Contributor

@stacey-gammon stacey-gammon commented Jul 19, 2017

Typing in "Infinity" into an advanced setting makes it a string, not the special javascript "Infinity" value, so look for both when determine lifetime notification. Also, treat negative numbers as "hide this notification".

Fixes #7565

Note to test this, you have to refresh the page after changing the advanced setting, to get the new notification value picked up.

cc @LeeDr

@stacey-gammon stacey-gammon requested review from jbudz and pickypg and removed request for jbudz July 19, 2017 18:35
Copy link
Member

@pickypg pickypg left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -63,7 +63,7 @@ function timerCanceler(notif, cb = _.noop, key) {
function startNotifTimer(notif, cb) {
const interval = 1000;

if (notif.lifetime === Infinity || notif.lifetime === 0) {
if (notif.lifetime === 'Infinity' || notif.lifetime === Infinity || notif.lifetime === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem like the right place to handle this case. The reason the string 'Infinity' is intended to be supported in this PR is because of a use case with the advanced settings UI itself, so it seems like this value should be serialized there long before it gets passed to the notifier.

Copy link
Member

Choose a reason for hiding this comment

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

I can appreciate that, but I think the benefit of doing it here is that every place that uses the advanced config options can ignore the output and hand it off here. Unless we want to provide a getter on the config object that can parse this for every caller.

@stacey-gammon
Copy link
Contributor Author

Ripped out "negative numbers mean don't show", until that can be resolved separately. Parsing number types into floats so Infinity will always get translated correctly and we don't need to manually check for the string "Infinity". cc @epixa @pickypg

Copy link
Member

@pickypg pickypg left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -125,6 +125,8 @@ will set the initial value if one is not already set.`);
const currentValue = config.isDefault(key) ? defaultValue : userValue;
if (type === 'json') {
return JSON.parse(currentValue);
} else if (type === 'number') {
return parseFloat(currentValue);
Copy link
Member

Choose a reason for hiding this comment

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

👍 This was easier than I expected. Kudos on finding this part.

@stacey-gammon stacey-gammon merged commit 3d37e02 into elastic:master Jul 20, 2017
@LeeDr LeeDr added bug Fixes for quality problems that affect the customer experience v6.0.0-beta1 labels Jul 27, 2017
@stacey-gammon stacey-gammon deleted the fix/Infinity-negative-banner-lifetimes branch October 24, 2017 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience v6.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants