Skip to content

Commit

Permalink
Merge pull request elastic#57 from spalger/autoloadSupport
Browse files Browse the repository at this point in the history
[autoload] support autoload without breaking bwc
  • Loading branch information
Rashid Khan committed Feb 3, 2016
2 parents c307844 + a099523 commit d03729c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@
var path = require('path');

module.exports = function (kibana) {
var mainFile = 'plugins/timelion/app';

var ownDescriptor = Object.getOwnPropertyDescriptor(kibana, 'autoload');
var protoDescriptor = Object.getOwnPropertyDescriptor(kibana.constructor.prototype, 'autoload');
var descriptor = ownDescriptor || protoDescriptor || {};
if (descriptor.get) {
// the autoload list has been replaced with a getter that complains about
// improper access, bypass that getter by seeing if it is defined
mainFile = 'plugins/timelion/app_with_autoload';
}

return new kibana.Plugin({
require: ['kibana', 'elasticsearch'],
uiExports: {
app: {
title: 'Timelion',
description: 'Time series expressions for everything',
icon: 'plugins/timelion/icon.svg',
main: 'plugins/timelion/app',
main: mainFile,
injectVars: function (server, options) {
var config = server.config();
return {
Expand Down Expand Up @@ -51,4 +62,4 @@ module.exports = function (kibana) {
},
init: require('./init.js'),
});
};;
};
2 changes: 2 additions & 0 deletions public/app_with_autoload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require('ui/autoload/all');
require('./app');

0 comments on commit d03729c

Please sign in to comment.