Skip to content

Commit

Permalink
[ML] Adds documentation links in the help menu for machine learning (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl authored Dec 18, 2020
1 parent c6757f9 commit f03c58e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<HelpMenuProps> = 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';
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ 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();
const disableCreateAnalyticsButton =
!mlNodesAvailable() ||
!checkPermission('canCreateDataFrameAnalytics') ||
!checkPermission('canStartStopDataFrameAnalytics');
const {
services: { docLinks },
} = useMlKibana();
const helpLink = docLinks.links.ml.guide;
return (
<Fragment>
<NavigationMenu tabId="overview" />
Expand All @@ -39,6 +45,7 @@ export const OverviewPage: FC = () => {
</EuiFlexGroup>
</EuiPageBody>
</EuiPage>
<HelpMenu docLink={helpLink} />
</Fragment>
);
};
Expand Down

0 comments on commit f03c58e

Please sign in to comment.