Skip to content

Commit

Permalink
Merge pull request elastic#7672 from ycombinator/notifier-constants
Browse files Browse the repository at this point in the history
Specify "constants" for notifier query string parameters
  • Loading branch information
ycombinator authored Jul 8, 2016
2 parents c14f4d0 + 44663fe commit fe4dea3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/ui/public/notify/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,23 @@ Notifier.applyConfig = function (config) {
// to be notified when the first fatal error occurs, push a function into this array.
Notifier.fatalCallbacks = [];

// "Constants"
Notifier.QS_PARAM_MESSAGE = 'notif_msg';
Notifier.QS_PARAM_LEVEL = 'notif_lvl';
Notifier.QS_PARAM_LOCATION = 'notif_loc';

Notifier.pullMessageFromUrl = ($location) => {
const queryString = $location.search();
if (!queryString.notif_msg) {
return;
}
const message = queryString.notif_msg;
const config = queryString.notif_loc ? { location: queryString.notif_loc } : {};
const level = queryString.notif_lvl || 'info';
const message = queryString[Notifier.QS_PARAM_MESSAGE];
const config = queryString[Notifier.QS_PARAM_LOCATION] ? { location: queryString[Notifier.QS_PARAM_LOCATION] } : {};
const level = queryString[Notifier.QS_PARAM_LEVEL] || 'info';

$location.search('notif_msg', null);
$location.search('notif_loc', null);
$location.search('notif_lvl', null);
$location.search(Notifier.QS_PARAM_MESSAGE, null);
$location.search(Notifier.QS_PARAM_LOCATION, null);
$location.search(Notifier.QS_PARAM_LEVEL, null);

const notifier = new Notifier(config);
notifier[level](message);
Expand Down

0 comments on commit fe4dea3

Please sign in to comment.