diff --git a/package.json b/package.json
index d0559f6aedc0..7e2e8217d1a5 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,8 @@
"private": false,
"version": "4.2.0-snapshot",
"build": {
- "num": 8095
+ "number": 8173,
+ "sha": "0102888deb393e4141369fbd1644a5d77f8732da"
},
"main": "src/server/KbnServer.js",
"homepage": "https://www.elastic.co/products/kibana",
@@ -131,7 +132,6 @@
"grunt-contrib-copy": "^0.8.0",
"grunt-esvm": "^1.1.3",
"grunt-karma": "^0.12.0",
- "grunt-replace": "^0.7.9",
"grunt-run": "spalger/grunt-run#master",
"grunt-s3": "^0.2.0-alpha.3",
"grunt-simple-mocha": "^0.4.0",
diff --git a/src/plugins/kibana/index.js b/src/plugins/kibana/index.js
index 34f9a8246152..eab524a31695 100644
--- a/src/plugins/kibana/index.js
+++ b/src/plugins/kibana/index.js
@@ -34,9 +34,12 @@ module.exports = function (kibana) {
'leaflet'
),
- constants: function (server, options) {
+ injectVars: function (server, options) {
+ let config = server.config();
+
return {
- defaultAppId: options.defaultAppId
+ kbnIndex: config.get('kibana.index'),
+ esShardTimeout: config.get('elasticsearch.shardTimeout')
};
}
}
diff --git a/src/plugins/kibana/public/kibana.js b/src/plugins/kibana/public/kibana.js
index 687edb367895..92a78b052749 100644
--- a/src/plugins/kibana/public/kibana.js
+++ b/src/plugins/kibana/public/kibana.js
@@ -4,14 +4,18 @@ require('plugins/kibana/dashboard/index');
require('plugins/kibana/settings/index');
require('plugins/kibana/doc/index');
+var chrome = require('ui/chrome');
+var routes = require('ui/routes');
+var modules = require('ui/modules');
+
var kibanaLogoUrl = require('ui/images/kibana.png');
-require('ui/routes')
+routes
.otherwise({
redirectTo: '/discover'
});
-require('ui/chrome')
+chrome
.setBrand({
'logo': 'url(' + kibanaLogoUrl + ') left no-repeat',
'smallLogo': 'url(' + kibanaLogoUrl + ') left no-repeat'
@@ -49,3 +53,4 @@ require('ui/chrome')
courier.start();
});
});
+
diff --git a/src/plugins/kibana/public/settings/sections/about/index.html b/src/plugins/kibana/public/settings/sections/about/index.html
index d90e9ee6f204..06adc3de469f 100644
--- a/src/plugins/kibana/public/settings/sections/about/index.html
+++ b/src/plugins/kibana/public/settings/sections/about/index.html
@@ -18,7 +18,7 @@
Commit SHA |
- {{commitSha | limitTo:7}} |
+ {{buildSha | limitTo:7}} |
diff --git a/src/plugins/kibana/public/settings/sections/about/index.js b/src/plugins/kibana/public/settings/sections/about/index.js
index fb5048967a85..fec9ad2da316 100644
--- a/src/plugins/kibana/public/settings/sections/about/index.js
+++ b/src/plugins/kibana/public/settings/sections/about/index.js
@@ -7,10 +7,10 @@ define(function (require) {
});
require('ui/modules').get('apps/settings')
- .controller('settingsAbout', function ($scope, kbnVersion, buildNum, commitSha) {
+ .controller('settingsAbout', function ($scope, kbnVersion, buildNum, buildSha) {
$scope.kbnVersion = kbnVersion;
$scope.buildNum = buildNum;
- $scope.commitSha = commitSha;
+ $scope.buildSha = buildSha;
});
return {
diff --git a/src/plugins/testsBundle/testsEntryTemplate.js b/src/plugins/testsBundle/testsEntryTemplate.js
index b1b695cd2447..7bdedff98a65 100644
--- a/src/plugins/testsBundle/testsEntryTemplate.js
+++ b/src/plugins/testsBundle/testsEntryTemplate.js
@@ -2,7 +2,7 @@
module.exports = require('lodash').template(
`
/**
- * Optimized application entry file
+ * Test entry file
*
* This is programatically created and updated, do not modify
*
@@ -19,6 +19,13 @@ env.pluginInfo.sort().forEach(function (plugin, i) {
*
*/
+window.__KBN__ = {
+ vars: {
+ kbnIndex: '.kibana',
+ esShardTimeout: 1500
+ }
+};
+
require('ui/testHarness');
<%
diff --git a/src/server/config/Config.js b/src/server/config/Config.js
index a7deb444348f..3e7a98a0eea6 100644
--- a/src/server/config/Config.js
+++ b/src/server/config/Config.js
@@ -58,18 +58,22 @@ module.exports = class Config {
if (_.isObject(env)) env = env.name;
if (!env) env = process.env.NODE_ENV || 'production';
+ let dev = env === 'development';
+ let prod = env === 'production';
+
// pass the environment as context so that it can be refed in config
let context = {
env: env,
- prod: env === 'production',
- dev: env === 'development',
- notProd: env !== 'production',
- notDev: env !== 'development',
+ prod: prod,
+ dev: dev,
+ notProd: !prod,
+ notDev: !dev,
version: _.get(pkg, 'version'),
- buildNum: env === 'development' ? Math.pow(2, 53) - 1 : _.get(pkg, 'build.num', NaN)
+ buildNum: dev ? Math.pow(2, 53) - 1 : _.get(pkg, 'build.number', NaN),
+ buildSha: dev ? 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' : _.get(pkg, 'build.sha', '')
};
- if (!context.dev && !context.prod && !context.test) {
+ if (!context.dev && !context.prod) {
throw new TypeError(
`Unexpected environment "${env}", expected one of "development" or "production"`
);
diff --git a/src/server/config/schema.js b/src/server/config/schema.js
index 0b373398185e..a019c7df915f 100644
--- a/src/server/config/schema.js
+++ b/src/server/config/schema.js
@@ -9,7 +9,8 @@ let fromRoot = utils('fromRoot');
module.exports = Joi.object({
pkg: Joi.object({
version: Joi.string().default(Joi.ref('$version')),
- buildNum: Joi.number().default(Joi.ref('$buildNum'))
+ buildNum: Joi.number().default(Joi.ref('$buildNum')),
+ buildSha: Joi.string().default(Joi.ref('$buildSha')),
}).default(),
env: Joi.object({
diff --git a/src/server/plugins/Plugin.js b/src/server/plugins/Plugin.js
index 702e4275a1ca..9f8eced5271e 100644
--- a/src/server/plugins/Plugin.js
+++ b/src/server/plugins/Plugin.js
@@ -47,6 +47,12 @@ module.exports = class Plugin {
let register = (server, options, next) => {
this.server = server;
+ // bind the server and options to all
+ // apps created by this plugin
+ for (let app of this.apps) {
+ app.getInjectedVars = _.partial(app.getInjectedVars, server, options);
+ }
+
server.log(['plugins', 'debug'], {
tmpl: 'Initializing plugin <%= plugin.id %>',
plugin: this
diff --git a/src/ui/UiApp.js b/src/ui/UiApp.js
index 686c8cb314b4..dd5e45bbb1f2 100644
--- a/src/ui/UiApp.js
+++ b/src/ui/UiApp.js
@@ -19,7 +19,12 @@ class UiApp {
this.hidden = this.spec.hidden;
this.autoloadOverrides = this.spec.autoload;
this.templateName = this.spec.templateName || 'uiApp';
+
+ // once this resolves, no reason to run it again
this.getModules = _.once(this.getModules);
+
+ // variables that are injected into the browser, must serialize to JSON
+ this.getInjectedVars = this.spec.injectVars || _.noop;
}
getModules() {
diff --git a/src/ui/UiExports.js b/src/ui/UiExports.js
index 4c1ea9812961..c314a67378f2 100644
--- a/src/ui/UiExports.js
+++ b/src/ui/UiExports.js
@@ -13,6 +13,8 @@ class UiExports {
}
consumePlugin(plugin) {
+ plugin.apps = new UiAppCollection(this);
+
var types = _.keys(plugin.uiExportsSpecs);
if (!types) return false;
@@ -46,7 +48,8 @@ class UiExports {
case 'apps':
return (plugin, specs) => {
for (let spec of [].concat(specs || [])) {
- this.apps.new(_.defaults({}, spec, { id: plugin.id }));
+ let app = this.apps.new(_.defaults({}, spec, { id: plugin.id }));
+ plugin.apps.add(app);
}
};
diff --git a/src/ui/index.js b/src/ui/index.js
index 5d03cd13091b..c906be2b572b 100644
--- a/src/ui/index.js
+++ b/src/ui/index.js
@@ -81,18 +81,15 @@ module.exports = async (kbnServer, server, config) => {
app: app,
appCount: uiExports.apps.size,
version: kbnServer.version,
- buildSha: _.get(kbnServer, 'build.sha', '@@buildSha'),
- buildNumber: _.get(kbnServer, 'build.number', '@@buildNum'),
- cacheBust: _.get(kbnServer, 'build.number', ''),
- kbnIndex: config.get('kibana.index'),
- esShardTimeout: config.get('elasticsearch.shardTimeout'),
+ buildNum: config.get('pkg.buildNum'),
+ buildSha: config.get('pkg.buildSha'),
+ vars: app.getInjectedVars()
};
return this.view(app.templateName, {
app: app,
- cacheBust: payload.cacheBust,
- kibanaPayload: payload,
loadingGif: loadingGif,
+ kibanaPayload: payload
});
});
};
diff --git a/src/ui/public/chrome/api/angular.js b/src/ui/public/chrome/api/angular.js
index ac30527a3b1d..6dfcefe902a8 100644
--- a/src/ui/public/chrome/api/angular.js
+++ b/src/ui/public/chrome/api/angular.js
@@ -6,22 +6,20 @@ module.exports = function (chrome, internals) {
chrome.setupAngular = function () {
var kibana = modules.get('kibana');
- var esUrl = (function () {
+ _.forOwn(chrome.getInjected(), function (val, name) {
+ kibana.value(name, val);
+ });
+
+ kibana
+ .value('kbnVersion', internals.version)
+ .value('buildNum', internals.buildNum)
+ .value('buildSha', internals.buildSha)
+ .value('sessionId', Date.now())
+ .value('esUrl', (function () {
var a = document.createElement('a');
a.href = '/elasticsearch';
return a.href;
- }());
-
- kibana
- .constant('kbnVersion', internals.version)
- .constant('buildNum', internals.buildNumber)
- .constant('kbnIndex', internals.kbnIndex)
- .constant('esShardTimeout', internals.esShardTimeout)
- .constant('esUrl', esUrl)
- .constant('commitSha', internals.buildSha)
- .constant('cacheBust', internals.cacheBust)
- .constant('minimumElasticsearchVersion', '2.0.0')
- .constant('sessionId', Date.now())
+ }()))
.directive('kbnChrome', function ($rootScope) {
return {
compile: function ($el) {
diff --git a/src/ui/public/chrome/api/apps.js b/src/ui/public/chrome/api/apps.js
index 44280701b87d..b5432408f4cf 100644
--- a/src/ui/public/chrome/api/apps.js
+++ b/src/ui/public/chrome/api/apps.js
@@ -31,4 +31,9 @@ module.exports = function (chrome, internals) {
return internals.app.id;
};
+ chrome.getInjected = function (name, def) {
+ if (name == null) return _.clone(internals.vars) || {};
+ return _.get(internals.vars, name, def);
+ };
+
};
diff --git a/tasks/config/replace.js b/tasks/config/replace.js
deleted file mode 100644
index cb83a3ab34af..000000000000
--- a/tasks/config/replace.js
+++ /dev/null
@@ -1,36 +0,0 @@
-module.exports = function (grunt) {
- var { join } = require('path');
-
- var build = grunt.config.get('build');
- var src = grunt.config.get('src');
- var app = grunt.config.get('app');
-
- var config = {
- options: {
- patterns: [
- { match: 'version', replacement: '<%= pkg.version %>' },
- { match: 'buildNum', replacement: '<%= buildNum %>' },
- { match: 'commitSha', replacement: '<%= commitSha %>' }
- ]
- },
- dist: {
- files: [
- {
- src: [join(src, 'server', 'bin', 'kibana.sh')],
- dest: join(build, 'dist', 'kibana', 'bin', 'kibana'),
- mode: parseInt('0755', 8)
- },
- {
- src: [join(src, 'server', 'bin', 'kibana.bat')],
- dest: join(build, 'dist', 'kibana', 'bin', 'kibana.bat')
- },
- {
- src: [join(src, 'server', 'config', 'index.js')],
- dest: join(build, 'dist', 'kibana', 'src', 'config', 'index.js')
- }
- ]
- }
- };
-
- return config;
-};
diff --git a/tasks/dist_package_json.js b/tasks/dist_package_json.js
index e44f783399fb..fca775f089e6 100644
--- a/tasks/dist_package_json.js
+++ b/tasks/dist_package_json.js
@@ -10,7 +10,7 @@ module.exports = function (grunt) {
version: pkg.version,
build: {
number: grunt.config.get('buildNum'),
- sha: grunt.config.get('commitSha')
+ sha: grunt.config.get('buildSha')
},
repository: pkg.repository,
dependencies: pkg.dependencies
diff --git a/tasks/get_build_props.js b/tasks/get_build_props.js
index f6e4f4078f6c..9c2dc1547619 100644
--- a/tasks/get_build_props.js
+++ b/tasks/get_build_props.js
@@ -1,7 +1,7 @@
module.exports = function (grunt) {
var exec = require('child_process').execSync;
grunt.registerTask('get_build_props', function () {
- grunt.config.set('commitSha', String(exec('git rev-parse HEAD')).trim());
+ grunt.config.set('buildSha', String(exec('git rev-parse HEAD')).trim());
grunt.config.set('buildNum', parseFloat(exec('git log --format="%h" | wc -l')).trim());
});
};