diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index 1f98de380312a..8a25c1c49e255 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -30,16 +30,20 @@ import type { EmbeddableSetup } from 'src/plugins/embeddable/public'; import { AppStatus, AppUpdater, DEFAULT_APP_CATEGORIES } from '../../../../src/core/public'; import type { UiActionsSetup, UiActionsStart } from '../../../../src/plugins/ui_actions/public'; import type { KibanaLegacyStart } from '../../../../src/plugins/kibana_legacy/public'; +import { MlCardState } from '../../../../src/plugins/index_pattern_management/public'; import type { LicenseManagementUIPluginSetup } from '../../license_management/public'; import type { LicensingPluginSetup } from '../../licensing/public'; import type { SecurityPluginSetup } from '../../security/public'; import { PLUGIN_ICON_SOLUTION, PLUGIN_ID } from '../common/constants/app'; +import { ML_APP_URL_GENERATOR } from '../common/constants/ml_url_generator'; +import { isFullLicense, isMlEnabled } from '../common/license'; import { setDependencyCache } from './application/util/dependency_cache'; -import { ML_APP_URL_GENERATOR } from '../common/constants/ml_url_generator'; -import { registerUrlGenerator } from './ml_url_generator'; +import { registerFeature } from './register_feature'; +// Not importing from `ml_url_generator/index` here to avoid importing unnecessary code +import { registerUrlGenerator } from './ml_url_generator/ml_url_generator'; export interface MlStartDependencies { data: DataPublicPluginStart; @@ -112,46 +116,39 @@ export class MlPlugin implements Plugin { const licensing = pluginsSetup.licensing.license$.pipe(take(1)); licensing.subscribe(async (license) => { const [coreStart] = await core.getStartServices(); - - const { - isFullLicense, - isMlEnabled, - registerEmbeddables, - registerFeature, - registerManagementSection, - registerMlUiActions, - MlCardState, - } = await import('./register_helper'); + const { capabilities } = coreStart.application; if (isMlEnabled(license)) { // add ML to home page if (pluginsSetup.home) { registerFeature(pluginsSetup.home); } - const { capabilities } = coreStart.application; // register ML for the index pattern management no data screen. pluginsSetup.indexPatternManagement.environment.update({ ml: () => capabilities.ml.canFindFileStructure ? MlCardState.ENABLED : MlCardState.HIDDEN, }); - - const canManageMLJobs = capabilities.management?.insightsAndAlerting?.jobsListLink ?? false; - - // register various ML plugin features which require a full license - if (isFullLicense(license)) { - if (canManageMLJobs && pluginsSetup.management !== undefined) { - registerManagementSection(pluginsSetup.management, core).enable(); - } - registerEmbeddables(pluginsSetup.embeddable, core); - registerMlUiActions(pluginsSetup.uiActions, core); - } } else { // if ml is disabled in elasticsearch, disable ML in kibana this.appUpdater.next(() => ({ status: AppStatus.inaccessible, })); } + + // register various ML plugin features which require a full license + const { registerEmbeddables, registerManagementSection, registerMlUiActions } = await import( + './register_helper' + ); + + if (isMlEnabled(license) && isFullLicense(license)) { + const canManageMLJobs = capabilities.management?.insightsAndAlerting?.jobsListLink ?? false; + if (canManageMLJobs && pluginsSetup.management !== undefined) { + registerManagementSection(pluginsSetup.management, core).enable(); + } + registerEmbeddables(pluginsSetup.embeddable, core); + registerMlUiActions(pluginsSetup.uiActions, core); + } }); return { diff --git a/x-pack/plugins/ml/public/register_helper.ts b/x-pack/plugins/ml/public/register_helper.ts index b24ec44363775..50ec53a10ece9 100644 --- a/x-pack/plugins/ml/public/register_helper.ts +++ b/x-pack/plugins/ml/public/register_helper.ts @@ -4,10 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -export { MlCardState } from '../../../../src/plugins/index_pattern_management/public'; - -export { isFullLicense, isMlEnabled } from '../common/license'; - export { registerEmbeddables } from './embeddables'; export { registerFeature } from './register_feature'; export { registerManagementSection } from './application/management'; diff --git a/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts b/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts index 7e9b73686a23b..c3dde872fa4a6 100644 --- a/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts +++ b/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts @@ -16,8 +16,7 @@ export default function ({ getService }: FtrProviderContext) { const testUsers = [USER.ML_POWERUSER, USER.ML_POWERUSER_SPACES]; - // flaky UI behavior makes this test fail, see https://github.com/elastic/kibana/issues/78965 - describe.skip('for user with full ML access', function () { + describe('for user with full ML access', function () { this.tags(['skipFirefox', 'mlqa']); describe('with no data loaded', function () {