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

feat: move keyboard shortcut hints to tooltips #12100

Merged
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
11 changes: 8 additions & 3 deletions superset-frontend/src/SqlLab/components/RunQueryActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ const RunQueryActionButton = ({

if (shouldShowStopBtn) {
return (
<Button {...commonBtnProps} cta onClick={stopQuery}>
<Button
{...commonBtnProps}
cta
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's cta here? i think we can remove it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like the cta prop makes it all caps.

onClick={stopQuery}
tooltip={t('Stop running (Ctrl + x)')}
>
<i className="fa fa-stop" /> {t('Stop')}
</Button>
);
Expand All @@ -67,7 +72,7 @@ const RunQueryActionButton = ({
cta
onClick={() => runQuery(true)}
key="run-async-btn"
tooltip={t('Run query asynchronously (Ctrl + )')}
tooltip={t('Run query (Ctrl + Return)')}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tooltip={t('Run query (Ctrl + Return)')}
tooltip={t('Run Query (Ctrl + Return)')}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The design has Query as lowercase, but let's check with Stephen!

disabled={!sql.trim()}
>
<i className="fa fa-bolt" /> {runBtnText}
Expand All @@ -80,7 +85,7 @@ const RunQueryActionButton = ({
cta
onClick={() => runQuery(false)}
key="run-btn"
tooltip={t('Run query synchronously (Ctrl + )')}
tooltip={t('Run query (Ctrl + Return)')}
disabled={!sql.trim()}
>
<i className="fa fa-refresh" /> {runBtnText}
Expand Down
13 changes: 8 additions & 5 deletions superset-frontend/src/SqlLab/components/SqlEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import Split from 'react-split';
import { t, styled } from '@superset-ui/core';
import debounce from 'lodash/debounce';
import throttle from 'lodash/throttle';
import Mousetrap from 'mousetrap';

import { Tooltip } from 'src/common/components/Tooltip';
import Label from 'src/components/Label';
import Button from 'src/components/Button';
import Timer from 'src/components/Timer';
import Hotkeys from 'src/components/Hotkeys';
import {
Dropdown,
Menu as AntdMenu,
Expand Down Expand Up @@ -155,6 +155,12 @@ class SqlEditor extends React.PureComponent {
this.setState({ height: this.getSqlEditorHeight() });

window.addEventListener('resize', this.handleWindowResize);

// setup hotkeys
const hotkeys = this.getHotkeyConfig();
hotkeys.forEach(keyConfig => {
Mousetrap.bind([keyConfig.key], keyConfig.func);
});
}

componentWillUnmount() {
Expand Down Expand Up @@ -487,7 +493,7 @@ class SqlEditor extends React.PureComponent {
return menuDropdown;
}

renderEditorBottomBar(hotkeys) {
renderEditorBottomBar() {
let ctasControls;
if (
this.props.database &&
Expand Down Expand Up @@ -615,9 +621,6 @@ class SqlEditor extends React.PureComponent {
</Dropdown>
</LimitSelectStyled>
</span>
<span>
<Hotkeys header={t('Keyboard shortcuts')} hotkeys={hotkeys} />
</span>
</Form>
</div>
<div className="rightItems">
Expand Down
7 changes: 6 additions & 1 deletion superset-frontend/src/SqlLab/components/TabbedSqlEditors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { styled, t } from '@superset-ui/core';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';

import { areArraysShallowEqual } from 'src/reduxUtils';
import { Tooltip } from 'src/common/components/Tooltip';
import * as Actions from '../actions/sqlLab';
import SqlEditor from './SqlEditor';
import TabStatusIcon from './TabStatusIcon';
Expand Down Expand Up @@ -409,7 +410,11 @@ class TabbedSqlEditors extends React.PureComponent {
fullWidth={false}
hideAdd={this.props.offline}
onEdit={this.handleEdit}
addIcon={<i data-test="add-tab-icon" className="fa fa-plus-circle" />}
addIcon={
<Tooltip id="add-tab" placement="bottom" title="New tab (Ctrl + t)">
<i data-test="add-tab-icon" className="fa fa-plus-circle" />
</Tooltip>
}
>
{editors}
</EditableTabs>
Expand Down