Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Code]: add setup guide link in help menu and pre-define document links #34902

Merged
merged 1 commit into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions x-pack/plugins/code/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import chrome from 'ui/chrome';
// @ts-ignore
import { uiModules } from 'ui/modules';
import { App } from './components/app';
import { HelpMenu } from './components/help_menu';
import { store } from './stores';

const app = uiModules.get('apps/code');
Expand Down Expand Up @@ -50,3 +51,10 @@ chrome.breadcrumbs.set([
href: '#/',
},
]);

chrome.helpExtension.set(domNode => {
render(<HelpMenu />, domNode);
return () => {
unmountComponentAtNode(domNode);
};
});
10 changes: 7 additions & 3 deletions x-pack/plugins/code/public/components/admin_page/setup_guide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import styled from 'styled-components';
import { documentationLinks } from '../../lib/documentation_links';
import { RootState } from '../../reducers';

const Root = styled.div`
Expand Down Expand Up @@ -76,7 +77,7 @@ const steps = [
You can add a repo to Code by simply putting in the git address of the repo. Usually this
is the same git address you use to run the git clone command, you can find more details
about the formats of git addresses that Code accepts&nbsp;
<Link to="">here</Link>.
<a href={documentationLinks.gitFormat}>here</a>.
</p>
</EuiText>
),
Expand All @@ -88,7 +89,8 @@ const steps = [
<p>
Once the repo is added and indexed successfully, you can verify that the repo is
searchable and the code intelligence is available. You can find more details of how the
search and code intelligence work in <Link to="">our docs</Link>.
search and code intelligence work in{' '}
<a href={documentationLinks.codeIntelligence}>our docs</a>.
</p>
</EuiText>
),
Expand All @@ -102,7 +104,9 @@ const toastMessage = (
We’ve made some changes to roles and permissions in Kibana. Read more about what these changes
mean for you below.{' '}
</p>
<EuiButton size="s" href="">Learn More</EuiButton>
<EuiButton size="s" href="">
Learn More
</EuiButton>
</div>
);

Expand Down
56 changes: 56 additions & 0 deletions x-pack/plugins/code/public/components/help_menu/help_menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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 chrome from 'ui/chrome';
import { EuiButton, EuiHorizontalRule, EuiText, EuiSpacer, EuiPortal } from '@elastic/eui';
import { documentationLinks } from '../../lib/documentation_links';

export class HelpMenu extends React.PureComponent {
state = { isFlyoutVisible: false };

showFlyout = () => {
this.setState({ isFlyoutVisible: true });
};

hideFlyout = () => {
this.setState({ isFlyoutVisible: false });
};

public render() {
return (
<React.Fragment>
<EuiHorizontalRule margin="none" />
<EuiSpacer />
<EuiText size="s">
<p>For Code specific information</p>
</EuiText>
<EuiSpacer />
<EuiButton fill iconType="popout" href={chrome.addBasePath('/app/code#/setup-guide')}>
Setup Guide
</EuiButton>
<EuiSpacer />
<EuiButton fill iconType="popout" href={documentationLinks.code} target="_blank">
Code documentation
</EuiButton>

{
// TODO: add shortcut information
/*
<EuiSpacer />
<EuiButton onClick={this.showFlyout} target="_blank">
Keyboard shortcuts
</EuiButton>
{this.state.isFlyoutVisible && (
<EuiPortal>
<ShortcutsProvider onClose={this.hideFlyout} />
</EuiPortal>
)} */
}
</React.Fragment>
);
}
}
7 changes: 7 additions & 0 deletions x-pack/plugins/code/public/components/help_menu/index.ts
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';
14 changes: 14 additions & 0 deletions x-pack/plugins/code/public/lib/documentation_links.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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 { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } from 'ui/documentation_links';

// TODO make sure document links are right
export const documentationLinks = {
code: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/code.html`,
codeIntelligence: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/code.html`,
gitFormat: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/code.html`,
};