diff --git a/x-pack/plugins/ml/public/application/management/index.ts b/x-pack/plugins/ml/public/application/management/index.ts index 5b281424ebf22..e633aef59297e 100644 --- a/x-pack/plugins/ml/public/application/management/index.ts +++ b/x-pack/plugins/ml/public/application/management/index.ts @@ -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 ) { - 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); + }, + }); } diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index 16b9b1a4e02f3..034ed090e2212 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -113,8 +113,6 @@ export class MlPlugin implements Plugin { MlCardState, } = await import('./register_helper'); - const managementApp = registerManagementSection(pluginsSetup.management, core); - if (isMlEnabled(license)) { // add ML to home page if (pluginsSetup.home) { @@ -137,22 +135,17 @@ export class MlPlugin implements Plugin { // 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(); - } } });