From 60e06c1692651d5434b69427843e2539f13f4431 Mon Sep 17 00:00:00 2001 From: Smart-Codi Date: Tue, 26 Apr 2022 23:12:47 -0400 Subject: [PATCH] feat: Update ShortKey for stop query running in SqlLab editor (#19692) * feat: Update shortkey for stop query running in sqllab editor * resolve comment * fix invalid import useMemo --- .../components/RunQueryActionButton/index.tsx | 15 +++++++++++++-- .../src/SqlLab/components/SqlEditor/index.jsx | 2 +- .../translations/de/LC_MESSAGES/messages.json | 1 + .../translations/en/LC_MESSAGES/messages.json | 1 + .../translations/es/LC_MESSAGES/messages.json | 1 + .../translations/fr/LC_MESSAGES/messages.json | 1 + .../translations/it/LC_MESSAGES/messages.json | 1 + .../translations/ja/LC_MESSAGES/messages.json | 1 + .../translations/ko/LC_MESSAGES/messages.json | 1 + .../translations/nl/LC_MESSAGES/messages.json | 1 + superset/translations/pt/LC_MESSAGES/message.json | 1 + .../translations/pt_BR/LC_MESSAGES/messages.json | 1 + .../translations/ru/LC_MESSAGES/messages.json | 1 + .../translations/sk/LC_MESSAGES/messages.json | 1 + .../translations/sl/LC_MESSAGES/messages.json | 1 + .../translations/zh/LC_MESSAGES/messages.json | 1 + 16 files changed, 28 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx b/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx index 2a9e0fbaf8d8..9da467685b49 100644 --- a/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import React from 'react'; +import React, { useMemo } from 'react'; import { t, styled, useTheme } from '@superset-ui/core'; import { Menu } from 'src/components/Menu'; @@ -26,6 +26,7 @@ import { DropdownButton, DropdownButtonProps, } from 'src/components/DropdownButton'; +import { detectOS } from 'src/utils/common'; interface Props { allowAsync: boolean; @@ -95,6 +96,8 @@ const RunQueryActionButton = ({ }: Props) => { const theme = useTheme(); + const userOS = detectOS(); + const shouldShowStopBtn = !!queryState && ['running', 'pending'].indexOf(queryState) > -1; @@ -104,6 +107,14 @@ const RunQueryActionButton = ({ const isDisabled = !sql.trim(); + const stopButtonTooltipText = useMemo( + () => + userOS === 'MacOS' + ? t('Stop running (Ctrl + x)') + : t('Stop running (Ctrl + e)'), + [userOS], + ); + return (