Skip to content

Commit 03aa6b8

Browse files
committed
custom notifier dynamic lifetime based on type
1 parent 259c480 commit 03aa6b8

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/ui/public/notify/notifier.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,24 @@ Notifier.prototype.custom = function (msg, config, cb) {
424424
throw new Error('config param is required, and must be an object');
425425
}
426426

427+
const getLifetime = (type) => {
428+
switch (type) {
429+
case 'banner':
430+
return Notifier.config.bannerLifetime;
431+
case 'warning':
432+
return Notifier.config.warningLifetime;
433+
case 'danger':
434+
return Notifier.config.errorLifetime;
435+
default: // info
436+
return Notifier.config.infoLifetime;
437+
}
438+
};
439+
427440
const mergedConfig = _.assign({
428-
type: 'custom',
441+
type: 'info',
429442
title: 'Notification',
430443
content: formatMsg(msg, this.from),
431-
lifetime: Notifier.config.infoLifetime,
444+
lifetime: getLifetime(config.type)
432445
}, config);
433446

434447
const hasActions = _.get(mergedConfig, 'actions.length');

0 commit comments

Comments
 (0)