Skip to content

Commit

Permalink
[ML] Register ML and Transforms for the kibana home page (#62499)
Browse files Browse the repository at this point in the history
* [ML] Register ML for the kibana home page

* adds transforms

* tiny refactor

* updating comments

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
jgowdyelastic and elasticmachine authored Apr 6, 2020
1 parent e732196 commit 4386d5f
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
6 changes: 6 additions & 0 deletions x-pack/plugins/ml/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import { SharePluginStart } from 'src/plugins/share/public';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';

import { DataPublicPluginStart } from 'src/plugins/data/public';
import { HomePublicPluginSetup } from 'src/plugins/home/public';
import { SecurityPluginSetup } from '../../security/public';
import { LicensingPluginSetup } from '../../licensing/public';
import { initManagementSection } from './application/management';
import { LicenseManagementUIPluginSetup } from '../../license_management/public';
import { setDependencyCache } from './application/util/dependency_cache';
import { PLUGIN_ID, PLUGIN_ICON } from '../common/constants/app';
import { registerFeature } from './register_feature';

export interface MlStartDependencies {
data: DataPublicPluginStart;
Expand All @@ -28,6 +30,7 @@ export interface MlSetupDependencies {
management: ManagementSetup;
usageCollection: UsageCollectionSetup;
licenseManagement?: LicenseManagementUIPluginSetup;
home: HomePublicPluginSetup;
}

export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
Expand All @@ -53,6 +56,7 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
management: pluginsSetup.management,
usageCollection: pluginsSetup.usageCollection,
licenseManagement: pluginsSetup.licenseManagement,
home: pluginsSetup.home,
},
{
element: params.element,
Expand All @@ -64,6 +68,8 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
},
});

registerFeature(pluginsSetup.home);

initManagementSection(pluginsSetup, core);
return {};
}
Expand Down
34 changes: 34 additions & 0 deletions x-pack/plugins/ml/public/register_feature.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';
import {
HomePublicPluginSetup,
FeatureCatalogueCategory,
} from '../../../../src/plugins/home/public';
import { PLUGIN_ID } from '../common/constants/app';

export const registerFeature = (home: HomePublicPluginSetup) => {
// register ML for the kibana home screen.
// so the file data visualizer appears to allow people to import data
home.environment.update({ ml: true });

// register ML so it appears on the Kibana home page
home.featureCatalogue.register({
id: PLUGIN_ID,
title: i18n.translate('xpack.ml.machineLearningTitle', {
defaultMessage: 'Machine Learning',
}),
description: i18n.translate('xpack.ml.machineLearningDescription', {
defaultMessage:
'Automatically model the normal behavior of your time series data to detect anomalies.',
}),
icon: 'machineLearningApp',
path: '/app/ml',
showOnHomePage: true,
category: FeatureCatalogueCategory.DATA,
});
};
6 changes: 5 additions & 1 deletion x-pack/plugins/transform/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import { i18n as kbnI18n } from '@kbn/i18n';
import { CoreSetup } from 'src/core/public';
import { DataPublicPluginStart } from 'src/plugins/data/public';
import { ManagementSetup } from 'src/plugins/management/public';
import { HomePublicPluginSetup } from 'src/plugins/home/public';
import { registerFeature } from './register_feature';

export interface PluginsDependencies {
data: DataPublicPluginStart;
management: ManagementSetup;
home: HomePublicPluginSetup;
}

export class TransformUiPlugin {
public setup(coreSetup: CoreSetup<PluginsDependencies>, pluginsSetup: PluginsDependencies): void {
const { management } = pluginsSetup;
const { management, home } = pluginsSetup;

// Register management section
const esSection = management.sections.getSection('elasticsearch');
Expand All @@ -33,6 +36,7 @@ export class TransformUiPlugin {
},
});
}
registerFeature(home);
}

public start() {}
Expand Down
29 changes: 29 additions & 0 deletions x-pack/plugins/transform/public/register_feature.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';
import {
HomePublicPluginSetup,
FeatureCatalogueCategory,
} from '../../../../src/plugins/home/public';

export const registerFeature = (home: HomePublicPluginSetup) => {
// register Transforms so it appears on the Kibana home page
home.featureCatalogue.register({
id: 'transform',
title: i18n.translate('xpack.transform.transformsTitle', {
defaultMessage: 'Transforms',
}),
description: i18n.translate('xpack.transform.transformsDescription', {
defaultMessage:
'Use transforms to pivot existing Elasticsearch indices into summarized or entity-centric indices.',
}),
icon: 'managementApp', // there is currently no Transforms icon, so using the general management app icon
path: '/app/kibana#/management/elasticsearch/transform',
showOnHomePage: true,
category: FeatureCatalogueCategory.ADMIN,
});
};

0 comments on commit 4386d5f

Please sign in to comment.