Skip to content

Commit

Permalink
[ML] Fix management section register.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Sep 23, 2020
1 parent d0b75d9 commit 3fc99f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
26 changes: 12 additions & 14 deletions x-pack/plugins/ml/public/application/management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ import type { MlStartDependencies } from '../../plugin';
import type { ManagementAppMountParams } from '../../../../../../src/plugins/management/public';

export function registerManagementSection(
management: ManagementSetup | undefined,
management: ManagementSetup,
core: CoreSetup<MlStartDependencies>
) {
if (management !== undefined) {
return management.sections.section.insightsAndAlerting.registerApp({
id: 'jobsListLink',
title: i18n.translate('xpack.ml.management.jobsListTitle', {
defaultMessage: 'Machine Learning Jobs',
}),
order: 2,
async mount(params: ManagementAppMountParams) {
const { mountApp } = await import('./jobs_list');
return mountApp(core, params);
},
});
}
return management.sections.section.insightsAndAlerting.registerApp({
id: 'jobsListLink',
title: i18n.translate('xpack.ml.management.jobsListTitle', {
defaultMessage: 'Machine Learning Jobs',
}),
order: 2,
async mount(params: ManagementAppMountParams) {
const { mountApp } = await import('./jobs_list');
return mountApp(core, params);
},
});
}
11 changes: 2 additions & 9 deletions x-pack/plugins/ml/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
MlCardState,
} = await import('./register_helper');

const managementApp = registerManagementSection(pluginsSetup.management, core);

if (isMlEnabled(license)) {
// add ML to home page
if (pluginsSetup.home) {
Expand All @@ -137,22 +135,17 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {

// register various ML plugin features which require a full license
if (isFullLicense(license)) {
if (canManageMLJobs && managementApp) {
managementApp.enable();
if (canManageMLJobs && pluginsSetup.management !== undefined) {
registerManagementSection(pluginsSetup.management, core).enable();
}
registerEmbeddables(pluginsSetup.embeddable, core);
registerMlUiActions(pluginsSetup.uiActions, core);
} else if (managementApp) {
managementApp.disable();
}
} else {
// if ml is disabled in elasticsearch, disable ML in kibana
this.appUpdater.next(() => ({
status: AppStatus.inaccessible,
}));
if (managementApp) {
managementApp.disable();
}
}
});

Expand Down

0 comments on commit 3fc99f9

Please sign in to comment.