Notifier version/build set via metadata
Version and build number can no longer be manually set on the Notifier object and instead are set at load-time based on the contents of ui/metadata.
This commit is contained in:
parent
a4a7206ef4
commit
d3e8456e32
|
@ -3,11 +3,13 @@ define(function (require) {
|
|||
var _ = require('lodash');
|
||||
var $ = require('jquery');
|
||||
|
||||
var metadata = require('ui/metadata');
|
||||
|
||||
var notifs = [];
|
||||
var setTO = setTimeout;
|
||||
var clearTO = clearTimeout;
|
||||
var version;
|
||||
var buildNum;
|
||||
var version = metadata.version;
|
||||
var buildNum = metadata.buildNum;
|
||||
var consoleGroups = ('group' in window.console) && ('groupCollapsed' in window.console) && ('groupEnd' in window.console);
|
||||
|
||||
var fatalSplashScreen = require('ui/notify/partials/fatal_splash_screen.html');
|
||||
|
@ -42,6 +44,9 @@ define(function (require) {
|
|||
}
|
||||
|
||||
function add(notif, cb) {
|
||||
_.set(notif, 'info.version', version);
|
||||
_.set(notif, 'info.buildNum', buildNum);
|
||||
|
||||
if (notif.lifetime !== Infinity) {
|
||||
notif.timerId = setTO(function () {
|
||||
closeNotif(cb, 'ignore').call(notif);
|
||||
|
@ -87,7 +92,7 @@ define(function (require) {
|
|||
return rtn;
|
||||
}
|
||||
|
||||
function formatInfo(version, buildNum) {
|
||||
function formatInfo() {
|
||||
var info = [];
|
||||
|
||||
if (!_.isUndefined(version)) {
|
||||
|
@ -109,10 +114,6 @@ define(function (require) {
|
|||
return err.stack;
|
||||
}
|
||||
|
||||
function infoAsObject(version, buildNum) {
|
||||
return { version, buildNum };
|
||||
}
|
||||
|
||||
/**
|
||||
* Functionality to check that
|
||||
*/
|
||||
|
@ -137,14 +138,6 @@ define(function (require) {
|
|||
clearTO = clear;
|
||||
};
|
||||
|
||||
Notifier.setVersion = function (ver) {
|
||||
version = ver;
|
||||
};
|
||||
|
||||
Notifier.setBuildNum = function (number) {
|
||||
buildNum = number;
|
||||
};
|
||||
|
||||
// simply a pointer to the global notif list
|
||||
Notifier.prototype._notifs = notifs;
|
||||
|
||||
|
@ -220,7 +213,7 @@ define(function (require) {
|
|||
}
|
||||
|
||||
var html = fatalToastTemplate({
|
||||
info: formatInfo(version, buildNum),
|
||||
info: formatInfo(),
|
||||
msg: formatMsg(err, this.from),
|
||||
stack: formatStack(err)
|
||||
});
|
||||
|
@ -248,7 +241,6 @@ define(function (require) {
|
|||
return add({
|
||||
type: 'danger',
|
||||
content: formatMsg(err, this.from),
|
||||
info: infoAsObject(version, buildNum),
|
||||
icon: 'warning',
|
||||
title: 'Error',
|
||||
lifetime: Infinity,
|
||||
|
@ -266,7 +258,6 @@ define(function (require) {
|
|||
return add({
|
||||
type: 'warning',
|
||||
content: formatMsg(msg, this.from),
|
||||
info: infoAsObject(version, buildNum),
|
||||
icon: 'warning',
|
||||
title: 'Warning',
|
||||
lifetime: 10000,
|
||||
|
@ -283,7 +274,6 @@ define(function (require) {
|
|||
return add({
|
||||
type: 'info',
|
||||
content: formatMsg(msg, this.from),
|
||||
info: infoAsObject(version, buildNum),
|
||||
icon: 'info-circle',
|
||||
title: 'Debug',
|
||||
lifetime: 5000,
|
||||
|
|
|
@ -7,18 +7,14 @@ describe('Notifier', function () {
|
|||
var message = 'Oh, the humanity!';
|
||||
var notifier;
|
||||
var params;
|
||||
var version;
|
||||
var buildNum;
|
||||
var version = window.__KBN__.version;
|
||||
var buildNum = window.__KBN__.buildNum;
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
|
||||
beforeEach(function () {
|
||||
params = { location: 'foo' };
|
||||
version = '1.2.3';
|
||||
buildNum = 12345;
|
||||
while (Notifier.prototype._notifs.pop()); // clear global notifications
|
||||
Notifier.setVersion(undefined);
|
||||
Notifier.setBuildNum(undefined);
|
||||
notifier = new Notifier(params);
|
||||
});
|
||||
|
||||
|
@ -154,14 +150,12 @@ describe('Notifier', function () {
|
|||
function testVersionInfo(fnName) {
|
||||
context('when version is configured', function () {
|
||||
it('adds version to notification', function () {
|
||||
Notifier.setVersion(version);
|
||||
var notification = notify(fnName);
|
||||
expect(notification.info.version).to.equal(version);
|
||||
});
|
||||
});
|
||||
context('when build number is configured', function () {
|
||||
it('adds buildNum to notification', function () {
|
||||
Notifier.setBuildNum(buildNum);
|
||||
var notification = notify(fnName);
|
||||
expect(notification.info.buildNum).to.equal(buildNum);
|
||||
});
|
||||
|
|
|
@ -19,11 +19,9 @@ define(function (require) {
|
|||
return Notifier;
|
||||
});
|
||||
|
||||
module.run(function ($timeout, kbnVersion, buildNum) {
|
||||
module.run(function ($timeout) {
|
||||
// provide alternate methods for setting timeouts, which will properly trigger digest cycles
|
||||
Notifier.setTimerFns($timeout, $timeout.cancel);
|
||||
Notifier.setVersion(kbnVersion);
|
||||
Notifier.setBuildNum(buildNum);
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue