Skip to content

Commit

Permalink
disabling UI feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Jul 28, 2020
1 parent a51e2ef commit 8195b9f
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 86 deletions.
41 changes: 16 additions & 25 deletions x-pack/plugins/ml/public/application/management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,28 @@
*/

import { i18n } from '@kbn/i18n';
import { take } from 'rxjs/operators';

import { CoreSetup } from 'kibana/public';
import { MlStartDependencies, MlSetupDependencies } from '../../plugin';
import { ManagementSetup } from 'src/plugins/management/public';
import { MlStartDependencies } from '../../plugin';

import { ManagementAppMountParams } from '../../../../../../src/plugins/management/public';
import { PLUGIN_ID } from '../../../common/constants/app';
import { MINIMUM_FULL_LICENSE } from '../../../common/license';

export function initManagementSection(
pluginsSetup: MlSetupDependencies,
management: ManagementSetup | undefined,
core: CoreSetup<MlStartDependencies>
) {
const licensing = pluginsSetup.licensing.license$.pipe(take(1));
licensing.subscribe((license) => {
const management = pluginsSetup.management;
if (
management !== undefined &&
license.check(PLUGIN_ID, MINIMUM_FULL_LICENSE).state === 'valid'
) {
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);
},
});
}
});
if (management !== undefined) {
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);
},
});
}
}
118 changes: 59 additions & 59 deletions x-pack/plugins/ml/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import { UiActionsSetup, UiActionsStart } from '../../../../src/plugins/ui_actio
import { registerMlUiActions } from './ui_actions';
import { KibanaLegacyStart } from '../../../../src/plugins/kibana_legacy/public';
import { MlUrlGenerator, MlUrlGeneratorState, ML_APP_URL_GENERATOR } from './url_generator';
import { isMlEnabled } from '../common/license';
import { isMlEnabled, isFullLicense } from '../common/license';
import { MINIMUM_FULL_LICENSE } from '../../../common/license';

export interface MlStartDependencies {
data: DataPublicPluginStart;
Expand Down Expand Up @@ -66,69 +67,68 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
constructor(private initializerContext: PluginInitializerContext) {}

async setup(core: MlCoreSetup, pluginsSetup: MlSetupDependencies) {
// const license = pluginsSetup.licensing.license$.pipe(take(1));
const license = await pluginsSetup.licensing.license$.pipe(take(1)).toPromise();
// licensing.subscribe((license) => {
// console.dir(license.getFeature('ml'));
// console.dir(license.getFeature('graph'));
if (isMlEnabled(license) === false) {
return {};
}
const baseUrl = core.http.basePath.prepend('/app/ml');
const licensing = pluginsSetup.licensing.license$.pipe(take(1));
licensing.subscribe((license) => {
if (isMlEnabled(license) === false) {
return;
}

pluginsSetup.share.urlGenerators.registerUrlGenerator(
new MlUrlGenerator({
appBasePath: baseUrl,
useHash: core.uiSettings.get('state:storeInSessionStorage'),
})
);
const baseUrl = core.http.basePath.prepend('/app/ml');

core.application.register({
id: PLUGIN_ID,
title: i18n.translate('xpack.ml.plugin.title', {
defaultMessage: 'Machine Learning',
}),
order: 5000,
euiIconType: PLUGIN_ICON,
appRoute: '/app/ml',
category: DEFAULT_APP_CATEGORIES.kibana,
mount: async (params: AppMountParameters) => {
const [coreStart, pluginsStart] = await core.getStartServices();
const kibanaVersion = this.initializerContext.env.packageInfo.version;
const { renderApp } = await import('./application/app');
return renderApp(
coreStart,
{
data: pluginsStart.data,
share: pluginsStart.share,
kibanaLegacy: pluginsStart.kibanaLegacy,
security: pluginsSetup.security,
licensing: pluginsSetup.licensing,
management: pluginsSetup.management,
usageCollection: pluginsSetup.usageCollection,
licenseManagement: pluginsSetup.licenseManagement,
home: pluginsSetup.home,
embeddable: pluginsSetup.embeddable,
uiActions: pluginsStart.uiActions,
kibanaVersion,
},
{
element: params.element,
appBasePath: params.appBasePath,
onAppLeave: params.onAppLeave,
history: params.history,
}
);
},
});
pluginsSetup.share.urlGenerators.registerUrlGenerator(
new MlUrlGenerator({
appBasePath: baseUrl,
useHash: core.uiSettings.get('state:storeInSessionStorage'),
})
);

registerFeature(pluginsSetup.home);
core.application.register({
id: PLUGIN_ID,
title: i18n.translate('xpack.ml.plugin.title', {
defaultMessage: 'Machine Learning',
}),
order: 5000,
euiIconType: PLUGIN_ICON,
appRoute: '/app/ml',
category: DEFAULT_APP_CATEGORIES.kibana,
mount: async (params: AppMountParameters) => {
const [coreStart, pluginsStart] = await core.getStartServices();
const kibanaVersion = this.initializerContext.env.packageInfo.version;
const { renderApp } = await import('./application/app');
return renderApp(
coreStart,
{
data: pluginsStart.data,
share: pluginsStart.share,
kibanaLegacy: pluginsStart.kibanaLegacy,
security: pluginsSetup.security,
licensing: pluginsSetup.licensing,
management: pluginsSetup.management,
usageCollection: pluginsSetup.usageCollection,
licenseManagement: pluginsSetup.licenseManagement,
home: pluginsSetup.home,
embeddable: pluginsSetup.embeddable,
uiActions: pluginsStart.uiActions,
kibanaVersion,
},
{
element: params.element,
appBasePath: params.appBasePath,
onAppLeave: params.onAppLeave,
history: params.history,
}
);
},
});

initManagementSection(pluginsSetup, core);
registerEmbeddables(pluginsSetup.embeddable, core);
registerMlUiActions(pluginsSetup.uiActions, core);
// });
registerFeature(pluginsSetup.home);

if (isFullLicense(license)) {
initManagementSection(pluginsSetup.management, core);
}
registerEmbeddables(pluginsSetup.embeddable, core);
registerMlUiActions(pluginsSetup.uiActions, core);
});
return {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ function getSwitcher(license$: Observable<ILicense>, logger: Logger): Capabiliti
try {
const license = await license$.pipe(take(1)).toPromise();
const mlCaps = capabilities.ml as MlCapabilities;
// console.dir(license.getFeature('ml'));
// console.dir(license.getFeature('graph'));
if (isMlEnabled(license) === false) {
disableAllCapabilities(mlCaps);
return capabilities;
Expand Down

0 comments on commit 8195b9f

Please sign in to comment.