From 1c0377bdf171a29ac029a4782bccb2e3d726e5a7 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Mon, 6 Apr 2020 13:50:20 +0100 Subject: [PATCH] [ML] Register ML and Transforms for the kibana home page (#62499) * [ML] Register ML for the kibana home page * adds transforms * tiny refactor * updating comments Co-authored-by: Elastic Machine --- x-pack/plugins/ml/public/plugin.ts | 6 ++++ x-pack/plugins/ml/public/register_feature.ts | 34 +++++++++++++++++++ x-pack/plugins/transform/public/plugin.ts | 6 +++- .../transform/public/register_feature.ts | 29 ++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 x-pack/plugins/ml/public/register_feature.ts create mode 100644 x-pack/plugins/transform/public/register_feature.ts diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index 62b60f81b672f..2472c343d0510 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -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; @@ -28,6 +30,7 @@ export interface MlSetupDependencies { management: ManagementSetup; usageCollection: UsageCollectionSetup; licenseManagement?: LicenseManagementUIPluginSetup; + home: HomePublicPluginSetup; } export class MlPlugin implements Plugin { @@ -53,6 +56,7 @@ export class MlPlugin implements Plugin { management: pluginsSetup.management, usageCollection: pluginsSetup.usageCollection, licenseManagement: pluginsSetup.licenseManagement, + home: pluginsSetup.home, }, { element: params.element, @@ -64,6 +68,8 @@ export class MlPlugin implements Plugin { }, }); + registerFeature(pluginsSetup.home); + initManagementSection(pluginsSetup, core); return {}; } diff --git a/x-pack/plugins/ml/public/register_feature.ts b/x-pack/plugins/ml/public/register_feature.ts new file mode 100644 index 0000000000000..ca60de612c3d5 --- /dev/null +++ b/x-pack/plugins/ml/public/register_feature.ts @@ -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, + }); +}; diff --git a/x-pack/plugins/transform/public/plugin.ts b/x-pack/plugins/transform/public/plugin.ts index cfe84a5ab693d..e6f19bcf1c2bb 100644 --- a/x-pack/plugins/transform/public/plugin.ts +++ b/x-pack/plugins/transform/public/plugin.ts @@ -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, pluginsSetup: PluginsDependencies): void { - const { management } = pluginsSetup; + const { management, home } = pluginsSetup; // Register management section const esSection = management.sections.getSection('elasticsearch'); @@ -33,6 +36,7 @@ export class TransformUiPlugin { }, }); } + registerFeature(home); } public start() {} diff --git a/x-pack/plugins/transform/public/register_feature.ts b/x-pack/plugins/transform/public/register_feature.ts new file mode 100644 index 0000000000000..708dfcb70c67a --- /dev/null +++ b/x-pack/plugins/transform/public/register_feature.ts @@ -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, + }); +};