Skip to content

Commit

Permalink
disabling UI for index management when enabled is false in kibana.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcconaghy committed Nov 6, 2018
1 parent 008d37c commit 45d4e8c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
8 changes: 7 additions & 1 deletion x-pack/plugins/index_management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ export function indexManagement(kibana) {
styleSheetPaths: `${__dirname}/public/index.scss`,
managementSections: [
'plugins/index_management',
]
],
injectDefaultVars(server) {
const config = server.config();
return {
indexManagementUiEnabled: config.get(`${PLUGIN.ID}.enabled`)
};
},
},
init: function (server) {
server.expose('addIndexManagementDataEnricher', addIndexManagementDataEnricher);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
import { management } from 'ui/management';
import { i18n } from '@kbn/i18n';
import { BASE_PATH } from '../common/constants';
import chrome from 'ui/chrome';
if (chrome.getInjected('indexManagementUiEnabled')) {
const esSection = management.getSection('elasticsearch');
esSection.register('index_management', {
visible: true,
display: i18n.translate('xpack.idxMgmt.appTitle', { defaultMessage: 'Index Management' }),
order: 1,
url: `#${BASE_PATH}home`
});
}

const esSection = management.getSection('elasticsearch');
esSection.register('index_management', {
visible: true,
display: i18n.translate('xpack.idxMgmt.appTitle', { defaultMessage: 'Index Management' }),
order: 1,
url: `#${BASE_PATH}home`
});

30 changes: 16 additions & 14 deletions x-pack/plugins/index_management/public/register_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import routes from 'ui/routes';
import template from './main.html';
import { manageAngularLifecycle } from './lib/manage_angular_lifecycle';
import { indexManagementStore } from './store';
import chrome from 'ui/chrome';

const renderReact = async (elem) => {
render(
Expand All @@ -32,21 +33,22 @@ const renderReact = async (elem) => {
elem
);
};

routes.when(`${BASE_PATH}:view?/:id?`, {
template: template,
controllerAs: 'indexManagement',
controller: class IndexManagementController {
constructor($scope, $route, $http) {
if (chrome.getInjected('indexManagementUiEnabled')) {
routes.when(`${BASE_PATH}:view?/:id?`, {
template: template,
controllerAs: 'indexManagement',
controller: class IndexManagementController {
constructor($scope, $route, $http) {
// NOTE: We depend upon Angular's $http service because it's decorated with interceptors,
// e.g. to check license status per request.
setHttpClient($http);
setHttpClient($http);

$scope.$$postDigest(() => {
const elem = document.getElementById('indexManagementReactRoot');
renderReact(elem);
manageAngularLifecycle($scope, $route, elem);
});
$scope.$$postDigest(() => {
const elem = document.getElementById('indexManagementReactRoot');
renderReact(elem);
manageAngularLifecycle($scope, $route, elem);
});
}
}
}
});
});
}

0 comments on commit 45d4e8c

Please sign in to comment.