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

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/core_plugins/kibana/ui_setting_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,22 +272,26 @@ export function getUiSettingDefaults() {
'notifications:lifetime:banner': {
value: 3000000,
description: 'The time in milliseconds which a banner notification ' +
'will be displayed on-screen for. Setting to Infinity will disable.'
'will be displayed on-screen for. Setting to Infinity will disable the countdown.' +
' Setting to a negative value will hide these notifications.'
},
'notifications:lifetime:error': {
value: 300000,
description: 'The time in milliseconds which an error notification ' +
'will be displayed on-screen for. Setting to Infinity will disable.'
'will be displayed on-screen for. Setting to Infinity will disable.' +
' Setting to a negative value will hide these notifications.'
},
'notifications:lifetime:warning': {
value: 10000,
description: 'The time in milliseconds which a warning notification ' +
'will be displayed on-screen for. Setting to Infinity will disable.'
'will be displayed on-screen for. Setting to Infinity will disable.' +
' Setting to a negative value will hide these notifications.'
},
'notifications:lifetime:info': {
value: 5000,
description: 'The time in milliseconds which an information notification ' +
'will be displayed on-screen for. Setting to Infinity will disable.'
'will be displayed on-screen for. Setting to Infinity will disable.' +
' Setting to a negative value will hide these notifications.'
},
'metrics:max_buckets': {
value: 2000,
Expand Down
5 changes: 4 additions & 1 deletion src/ui/public/notify/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

return;
}

Expand Down Expand Up @@ -107,6 +107,9 @@ const typeToAlertClassMap = {
};

function add(notif, cb) {
if (notif.lifetime < 0) {
return;
}
_.set(notif, 'info.version', version);
_.set(notif, 'info.buildNum', buildNum);

Expand Down