-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Canvas] Adds doc links and keyboard shortcut cheatsheat to help menu (…
…#31335) (#31727) * Added docs link and keyboard shortcuts to global help menu * Fixed tooltip * Removed aeroelastic keyboard event handlers * typography and copy changes * Removed doc links from workpad manager * Added input target check to workpad page keyhandler * Fixed ungrouping * Displays arrow symbols instead of arrow key word * Removed tabIndex * Fix: reintroduce additional call on keyboard event
- Loading branch information
Showing
14 changed files
with
342 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
x-pack/plugins/canvas/public/components/help_menu/help_menu.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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, EuiText, EuiSpacer, EuiPortal } from '@elastic/eui'; | ||
import { documentationLinks } from '../../lib/documentation_links'; | ||
import { KeyboardShortcutsDoc } from '../keyboard_shortcuts_doc'; | ||
|
||
export class HelpMenu extends PureComponent { | ||
state = { isFlyoutVisible: false }; | ||
|
||
showFlyout = () => { | ||
this.setState({ isFlyoutVisible: true }); | ||
}; | ||
|
||
hideFlyout = () => { | ||
this.setState({ isFlyoutVisible: false }); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Fragment> | ||
<EuiHorizontalRule margin="none" /> | ||
<EuiSpacer /> | ||
<EuiText size="s"> | ||
<p>For Canvas specific information</p> | ||
</EuiText> | ||
<EuiSpacer /> | ||
<EuiButton fill iconType="popout" href={documentationLinks.canvas} target="_blank"> | ||
Canvas documentation | ||
</EuiButton> | ||
<EuiSpacer /> | ||
<EuiButton onClick={this.showFlyout} target="_blank"> | ||
Keyboard shortcuts | ||
</EuiButton> | ||
|
||
{this.state.isFlyoutVisible && ( | ||
<EuiPortal> | ||
<KeyboardShortcutsDoc onClose={this.hideFlyout} /> | ||
</EuiPortal> | ||
)} | ||
</Fragment> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
7 changes: 7 additions & 0 deletions
7
x-pack/plugins/canvas/public/components/keyboard_shortcuts_doc/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { KeyboardShortcutsDoc } from './keyboard_shortcuts_doc'; |
92 changes: 92 additions & 0 deletions
92
x-pack/plugins/canvas/public/components/keyboard_shortcuts_doc/keyboard_shortcuts_doc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* 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 PropTypes from 'prop-types'; | ||
import { | ||
EuiFlyout, | ||
EuiFlyoutHeader, | ||
EuiFlyoutBody, | ||
EuiDescriptionList, | ||
EuiHorizontalRule, | ||
EuiCode, | ||
EuiSpacer, | ||
EuiTitle, | ||
} from '@elastic/eui'; | ||
import { keymap } from '../../lib/keymap'; | ||
import { getClientPlatform } from '../../lib/get_client_platform'; | ||
import { getId } from '../../lib/get_id'; | ||
|
||
const getPrettyShortcut = shortcut => { | ||
if (!shortcut) { | ||
return ''; | ||
} | ||
|
||
let result = shortcut.replace(/command/i, '⌘'); | ||
result = result.replace(/option/i, '⌥'); | ||
result = result.replace(/left/i, '←'); | ||
result = result.replace(/right/i, '→'); | ||
result = result.replace(/up/i, '↑'); | ||
result = result.replace(/down/i, '↓'); | ||
|
||
return ( | ||
<span key={getId('span')}> | ||
{result | ||
.split(/(\+)/g) //splits the array by '+' and keeps the '+'s as elements in the array | ||
.map(key => (key === '+' ? ` ${key} ` : <EuiCode key={getId('shortcut')}>{key}</EuiCode>))} | ||
</span> | ||
); | ||
}; | ||
|
||
const getDescriptionListItems = shortcuts => | ||
Object.values(shortcuts).map(shortcutKeyMap => { | ||
const os = getClientPlatform(); | ||
const osShortcuts = shortcutKeyMap[os]; | ||
return { | ||
title: shortcutKeyMap.help, | ||
description: osShortcuts.reduce((acc, shortcut, i) => { | ||
if (i !== 0) { | ||
acc.push(' or '); | ||
} | ||
acc.push(getPrettyShortcut(shortcut)); | ||
return acc; | ||
}, []), | ||
}; | ||
}); | ||
|
||
export const KeyboardShortcutsDoc = props => ( | ||
<EuiFlyout closeButtonAriaLabel="Closes keyboard shortcuts reference" size="s" {...props}> | ||
<EuiFlyoutHeader hasBorder> | ||
<EuiTitle size="s"> | ||
<h2>Keyboard Shortcuts</h2> | ||
</EuiTitle> | ||
</EuiFlyoutHeader> | ||
<EuiFlyoutBody> | ||
{Object.values(keymap).map(namespace => { | ||
const { displayName, ...shortcuts } = namespace; | ||
return ( | ||
<div key={getId('shortcuts')} className="canvasKeyboardShortcut"> | ||
<EuiTitle size="xs"> | ||
<h4>{displayName}</h4> | ||
</EuiTitle> | ||
<EuiHorizontalRule margin="s" /> | ||
<EuiDescriptionList | ||
textStyle="reverse" | ||
type="column" | ||
listItems={getDescriptionListItems(shortcuts)} | ||
compressed | ||
/> | ||
<EuiSpacer /> | ||
</div> | ||
); | ||
})} | ||
</EuiFlyoutBody> | ||
</EuiFlyout> | ||
); | ||
|
||
KeyboardShortcutsDoc.propTypes = { | ||
onClose: PropTypes.func.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.