Skip to content

Commit

Permalink
[Maps] Add help menu (#32561) (#32673)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck authored Mar 7, 2019
1 parent a1f8dcd commit d356b08
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
3 changes: 3 additions & 0 deletions x-pack/plugins/maps/public/angular/map_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { timefilter } from 'ui/timefilter';
import { Provider } from 'react-redux';
import { createMapStore } from '../store/store';
import { GisMap } from '../components/gis_map';
import { addHelpMenuToAppChrome } from '../help_menu_util';
import {
setSelectedLayer,
setRefreshConfig,
Expand Down Expand Up @@ -208,6 +209,8 @@ app.controller('GisMapController', ($scope, $route, config, kbnUrl, localStorage
{ text: $scope.map.title }
]);

addHelpMenuToAppChrome(chrome);

async function doSave(saveOptions) {
await store.dispatch(clearTransientLayerStateAndCloseFlyout());
savedMap.syncWithStore(store.getState());
Expand Down
17 changes: 17 additions & 0 deletions x-pack/plugins/maps/public/help_menu_util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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 from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { HelpMenu } from './shared/components/help_menu';

export function addHelpMenuToAppChrome(chrome) {
chrome.helpExtension.set(domElement => {
render(<HelpMenu/>, domElement);
return () => {
unmountComponentAtNode(domElement);
};
});
}
37 changes: 37 additions & 0 deletions x-pack/plugins/maps/public/shared/components/help_menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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, { Fragment, PureComponent } from 'react';
import { EuiButton, EuiHorizontalRule, EuiSpacer, EuiLink } from '@elastic/eui';
import { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } from 'ui/documentation_links';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';

export class HelpMenu extends PureComponent {
render() {
return (
<Fragment>
<EuiHorizontalRule margin="none" />
<EuiSpacer />
<EuiButton fill iconType="popout" href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/maps.html`} target="_blank">
<FormattedMessage
id="xpack.maps.helpMenu.docLabel"
defaultMessage="Maps documentation"
/>
</EuiButton>
<EuiSpacer />
<EuiLink
href="https://github.com/elastic/kibana/issues/new"
target="_blank"
>
{i18n.translate('xpack.maps.helpMenu.feedbackLinkText', {
defaultMessage: 'Provide feedback for the Maps application'
})}
</EuiLink>
</Fragment>
);
}
}
3 changes: 3 additions & 0 deletions x-pack/plugins/maps/public/shared/components/map_listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { addHelpMenuToAppChrome } from '../../help_menu_util';
import chrome from 'ui/chrome';

export const EMPTY_FILTER = '';

Expand Down Expand Up @@ -55,6 +57,7 @@ export class MapListing extends React.Component {

componentDidMount() {
this.fetchItems();
addHelpMenuToAppChrome(chrome);
}

debouncedFetch = _.debounce(async (filter) => {
Expand Down

0 comments on commit d356b08

Please sign in to comment.