Skip to content

Commit

Permalink
remap keyboard shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Oct 17, 2023
1 parent 033e41f commit bf9ad0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export enum KeyboardShortcut {
CMD_OPT_F = 'cmd+opt+f',
CTRL_F = 'ctrl+f',
CTRL_H = 'ctrl+h',
CTRL_SHIFT_F = 'ctrl+shift+f',
}

export const KEY_MAP = {
Expand All @@ -49,6 +50,7 @@ export const KEY_MAP = {
[KeyboardShortcut.CTRL_Q]: userOS === 'Windows' ? t('New tab') : undefined,
[KeyboardShortcut.CTRL_T]: userOS !== 'Windows' ? t('New tab') : undefined,
[KeyboardShortcut.CTRL_P]: t('Previous Line'),
[KeyboardShortcut.CTRL_SHIFT_F]: t('Format SQL'),
// default ace editor shortcuts
[KeyboardShortcut.CMD_F]: userOS === 'MacOS' ? t('Find') : undefined,
[KeyboardShortcut.CTRL_F]: userOS !== 'MacOS' ? t('Find') : undefined,
Expand Down
19 changes: 3 additions & 16 deletions superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ import {
} from 'src/utils/localStorageHelpers';
import { EmptyStateBig } from 'src/components/EmptyState';
import getBootstrapData from 'src/utils/getBootstrapData';
import Badge from 'src/components/Badge';
import { isEmpty } from 'lodash';
import TemplateParamsEditor from '../TemplateParamsEditor';
import SouthPane from '../SouthPane';
Expand Down Expand Up @@ -232,8 +231,6 @@ const elementStyle = (
}px)`,
});

const KEYBOARD_SHORTCUT_FOR_FORMAT = 'ctrl+shift+f';

const SqlEditor: React.FC<Props> = ({
tables,
queryEditor,
Expand Down Expand Up @@ -394,8 +391,8 @@ const SqlEditor: React.FC<Props> = ({
},
{
name: 'formatQuery',
key: KEYBOARD_SHORTCUT_FOR_FORMAT,
descr: t('Format query'),
key: KeyboardShortcut.CTRL_SHIFT_F,
descr: KEY_MAP[KeyboardShortcut.CTRL_SHIFT_F],
func: () => {
formatCurrentQuery();
},
Expand Down Expand Up @@ -638,17 +635,7 @@ const SqlEditor: React.FC<Props> = ({
/>
</Menu.Item>
)}
<Menu.Item
onClick={formatCurrentQuery}
css={{ display: 'flex', justifyContent: 'space-between' }}
>
<span>{t('Format SQL')}</span>
<Badge
count={KEYBOARD_SHORTCUT_FOR_FORMAT}
color={theme.colors.grayscale.light2}
textColor={theme.colors.grayscale.dark1}
/>
</Menu.Item>
<Menu.Item onClick={formatCurrentQuery}>{t('Format SQL')}</Menu.Item>
{!isEmpty(scheduledQueriesConf) && (
<Menu.Item>
<ScheduleQueryButton
Expand Down

0 comments on commit bf9ad0e

Please sign in to comment.