diff --git a/x-pack/plugins/ml/public/application/components/help_menu/help_menu.tsx b/x-pack/plugins/ml/public/application/components/help_menu/help_menu.tsx new file mode 100644 index 0000000000000..5cf95c773ef8c --- /dev/null +++ b/x-pack/plugins/ml/public/application/components/help_menu/help_menu.tsx @@ -0,0 +1,36 @@ +/* + * 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 React, { FC, useEffect } from 'react'; +import { i18n } from '@kbn/i18n'; +import { useMlKibana } from '../../contexts/kibana'; + +interface HelpMenuProps { + docLink: string; +} + +// Component for adding a documentation link to the help menu +export const HelpMenu: FC = React.memo(({ docLink }) => { + const { chrome } = useMlKibana().services; + + useEffect(() => { + chrome.setHelpExtension({ + appName: i18n.translate('xpack.ml.chrome.help.appName', { + defaultMessage: 'Machine Learning', + }), + links: [ + { + href: docLink, + linkType: 'documentation', + }, + ], + }); + }, []); + + return null; +}); + +HelpMenu.displayName = 'HelpMenu'; diff --git a/x-pack/plugins/ml/public/application/components/help_menu/index.tsx b/x-pack/plugins/ml/public/application/components/help_menu/index.tsx new file mode 100644 index 0000000000000..47682169c51e0 --- /dev/null +++ b/x-pack/plugins/ml/public/application/components/help_menu/index.tsx @@ -0,0 +1,7 @@ +/* + * 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. + */ + +export { HelpMenu } from './help_menu'; diff --git a/x-pack/plugins/ml/public/application/overview/overview_page.tsx b/x-pack/plugins/ml/public/application/overview/overview_page.tsx index 1e8b057381362..bf293ee38ea1a 100644 --- a/x-pack/plugins/ml/public/application/overview/overview_page.tsx +++ b/x-pack/plugins/ml/public/application/overview/overview_page.tsx @@ -14,6 +14,8 @@ import { OverviewContent } from './components/content'; import { NodeAvailableWarning } from '../components/node_available_warning'; import { SavedObjectsWarning } from '../components/saved_objects_warning'; import { UpgradeWarning } from '../components/upgrade'; +import { HelpMenu } from '../components/help_menu'; +import { useMlKibana } from '../contexts/kibana'; export const OverviewPage: FC = () => { const disableCreateAnomalyDetectionJob = !checkPermission('canCreateJob') || !mlNodesAvailable(); @@ -21,6 +23,10 @@ export const OverviewPage: FC = () => { !mlNodesAvailable() || !checkPermission('canCreateDataFrameAnalytics') || !checkPermission('canStartStopDataFrameAnalytics'); + const { + services: { docLinks }, + } = useMlKibana(); + const helpLink = docLinks.links.ml.guide; return ( @@ -39,6 +45,7 @@ export const OverviewPage: FC = () => { + ); };