Skip to content

Commit f1905ec

Browse files
[ML] Fix registering home screen panel (#79080)
* [ML] Import tweak. * [ML] Attempt at fixing flaky registering. * [ML] Re-enable tests. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent edce4eb commit f1905ec

File tree

3 files changed

+22
-30
lines changed

3 files changed

+22
-30
lines changed

x-pack/plugins/ml/public/plugin.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ import type { EmbeddableSetup } from 'src/plugins/embeddable/public';
3030
import { AppStatus, AppUpdater, DEFAULT_APP_CATEGORIES } from '../../../../src/core/public';
3131
import type { UiActionsSetup, UiActionsStart } from '../../../../src/plugins/ui_actions/public';
3232
import type { KibanaLegacyStart } from '../../../../src/plugins/kibana_legacy/public';
33+
import { MlCardState } from '../../../../src/plugins/index_pattern_management/public';
3334

3435
import type { LicenseManagementUIPluginSetup } from '../../license_management/public';
3536
import type { LicensingPluginSetup } from '../../licensing/public';
3637
import type { SecurityPluginSetup } from '../../security/public';
3738

3839
import { PLUGIN_ICON_SOLUTION, PLUGIN_ID } from '../common/constants/app';
40+
import { ML_APP_URL_GENERATOR } from '../common/constants/ml_url_generator';
41+
import { isFullLicense, isMlEnabled } from '../common/license';
3942

4043
import { setDependencyCache } from './application/util/dependency_cache';
41-
import { ML_APP_URL_GENERATOR } from '../common/constants/ml_url_generator';
42-
import { registerUrlGenerator } from './ml_url_generator';
44+
import { registerFeature } from './register_feature';
45+
// Not importing from `ml_url_generator/index` here to avoid importing unnecessary code
46+
import { registerUrlGenerator } from './ml_url_generator/ml_url_generator';
4347

4448
export interface MlStartDependencies {
4549
data: DataPublicPluginStart;
@@ -112,46 +116,39 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
112116
const licensing = pluginsSetup.licensing.license$.pipe(take(1));
113117
licensing.subscribe(async (license) => {
114118
const [coreStart] = await core.getStartServices();
115-
116-
const {
117-
isFullLicense,
118-
isMlEnabled,
119-
registerEmbeddables,
120-
registerFeature,
121-
registerManagementSection,
122-
registerMlUiActions,
123-
MlCardState,
124-
} = await import('./register_helper');
119+
const { capabilities } = coreStart.application;
125120

126121
if (isMlEnabled(license)) {
127122
// add ML to home page
128123
if (pluginsSetup.home) {
129124
registerFeature(pluginsSetup.home);
130125
}
131-
const { capabilities } = coreStart.application;
132126

133127
// register ML for the index pattern management no data screen.
134128
pluginsSetup.indexPatternManagement.environment.update({
135129
ml: () =>
136130
capabilities.ml.canFindFileStructure ? MlCardState.ENABLED : MlCardState.HIDDEN,
137131
});
138-
139-
const canManageMLJobs = capabilities.management?.insightsAndAlerting?.jobsListLink ?? false;
140-
141-
// register various ML plugin features which require a full license
142-
if (isFullLicense(license)) {
143-
if (canManageMLJobs && pluginsSetup.management !== undefined) {
144-
registerManagementSection(pluginsSetup.management, core).enable();
145-
}
146-
registerEmbeddables(pluginsSetup.embeddable, core);
147-
registerMlUiActions(pluginsSetup.uiActions, core);
148-
}
149132
} else {
150133
// if ml is disabled in elasticsearch, disable ML in kibana
151134
this.appUpdater.next(() => ({
152135
status: AppStatus.inaccessible,
153136
}));
154137
}
138+
139+
// register various ML plugin features which require a full license
140+
const { registerEmbeddables, registerManagementSection, registerMlUiActions } = await import(
141+
'./register_helper'
142+
);
143+
144+
if (isMlEnabled(license) && isFullLicense(license)) {
145+
const canManageMLJobs = capabilities.management?.insightsAndAlerting?.jobsListLink ?? false;
146+
if (canManageMLJobs && pluginsSetup.management !== undefined) {
147+
registerManagementSection(pluginsSetup.management, core).enable();
148+
}
149+
registerEmbeddables(pluginsSetup.embeddable, core);
150+
registerMlUiActions(pluginsSetup.uiActions, core);
151+
}
155152
});
156153

157154
return {

x-pack/plugins/ml/public/register_helper.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
export { MlCardState } from '../../../../src/plugins/index_pattern_management/public';
8-
9-
export { isFullLicense, isMlEnabled } from '../common/license';
10-
117
export { registerEmbeddables } from './embeddables';
128
export { registerFeature } from './register_feature';
139
export { registerManagementSection } from './application/management';

x-pack/test/functional/apps/ml/permissions/full_ml_access.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ export default function ({ getService }: FtrProviderContext) {
1616

1717
const testUsers = [USER.ML_POWERUSER, USER.ML_POWERUSER_SPACES];
1818

19-
// flaky UI behavior makes this test fail, see https://github.com/elastic/kibana/issues/78965
20-
describe.skip('for user with full ML access', function () {
19+
describe('for user with full ML access', function () {
2120
this.tags(['skipFirefox', 'mlqa']);
2221

2322
describe('with no data loaded', function () {

0 commit comments

Comments
 (0)