From dfebe6b2a19d5daf5ae45c0e8cdf0e96de777cac Mon Sep 17 00:00:00 2001 From: SpiderMan Date: Wed, 13 Apr 2022 10:22:59 -0400 Subject: [PATCH 1/3] feat: Update shortkey for stop query running in sqllab editor --- .../src/SqlLab/components/RunQueryActionButton/index.tsx | 7 ++++++- .../src/SqlLab/components/SqlEditor/index.jsx | 2 +- superset/translations/de/LC_MESSAGES/messages.json | 1 + superset/translations/en/LC_MESSAGES/messages.json | 1 + superset/translations/es/LC_MESSAGES/messages.json | 1 + superset/translations/fr/LC_MESSAGES/messages.json | 1 + superset/translations/it/LC_MESSAGES/messages.json | 1 + superset/translations/ja/LC_MESSAGES/messages.json | 1 + superset/translations/ko/LC_MESSAGES/messages.json | 1 + superset/translations/nl/LC_MESSAGES/messages.json | 1 + superset/translations/pt/LC_MESSAGES/message.json | 1 + superset/translations/pt_BR/LC_MESSAGES/messages.json | 1 + superset/translations/ru/LC_MESSAGES/messages.json | 1 + superset/translations/sk/LC_MESSAGES/messages.json | 1 + superset/translations/sl/LC_MESSAGES/messages.json | 1 + superset/translations/zh/LC_MESSAGES/messages.json | 1 + 16 files changed, 21 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx b/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx index 2a9e0fbaf8d8..4be7b3534061 100644 --- a/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx @@ -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; @@ -114,7 +117,9 @@ const RunQueryActionButton = ({ tooltip={ (!isDisabled && (shouldShowStopBtn - ? t('Stop running (Ctrl + x)') + ? userOS === 'MacOS' + ? t('Stop running (Ctrl + x)') + : t('Stop running (Ctrl + e)') : t('Run query (Ctrl + Return)'))) as string } cta diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx index 7899cbf71908..4ca934546945 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx +++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx @@ -342,7 +342,7 @@ class SqlEditor extends React.PureComponent { }, { name: 'stopQuery', - key: 'ctrl+x', + key: userOS === 'MacOS' ? 'ctrl+x' : 'ctrl+e', descr: t('Stop query'), func: this.stopQuery, }, diff --git a/superset/translations/de/LC_MESSAGES/messages.json b/superset/translations/de/LC_MESSAGES/messages.json index 81b02949dd77..98cd4e694704 100644 --- a/superset/translations/de/LC_MESSAGES/messages.json +++ b/superset/translations/de/LC_MESSAGES/messages.json @@ -3653,6 +3653,7 @@ "Stop": ["Stopp"], "Stop query": ["Abfrage anhalten"], "Stop running (Ctrl + x)": ["Ausführung abbrechen (Strg + x)"], + "Stop running (Ctrl + e)": ["Ausführung abbrechen (Strg + e)"], "Stopped an unsafe database connection": [ "Eine unsichere Datenbankverbindung wurde beendet" ], diff --git a/superset/translations/en/LC_MESSAGES/messages.json b/superset/translations/en/LC_MESSAGES/messages.json index 7e74c204afb4..912c9fde7068 100644 --- a/superset/translations/en/LC_MESSAGES/messages.json +++ b/superset/translations/en/LC_MESSAGES/messages.json @@ -985,6 +985,7 @@ "Run selection": [""], "Run": [""], "Stop running (Ctrl + x)": [""], + "Stop running (Ctrl + e)": [""], "Run query (Ctrl + Return)": [""], "Save & Explore": [""], "Overwrite & Explore": [""], diff --git a/superset/translations/es/LC_MESSAGES/messages.json b/superset/translations/es/LC_MESSAGES/messages.json index ba0f1642f65a..a7f2a4738b95 100644 --- a/superset/translations/es/LC_MESSAGES/messages.json +++ b/superset/translations/es/LC_MESSAGES/messages.json @@ -1432,6 +1432,7 @@ "Run selection": ["Probar Conexión"], "Run": ["Ejecutar"], "Stop running (Ctrl + x)": ["Detener (Ctrl + x)"], + "Stop running (Ctrl + e)": ["Detener (Ctrl + e)"], "Run query (Ctrl + Return)": ["Ejecutar consulta (Ctrl + Enter)"], "Save & Explore": ["Guardar y Explorar"], "Overwrite & Explore": ["Sobreescribir y Explorar"], diff --git a/superset/translations/fr/LC_MESSAGES/messages.json b/superset/translations/fr/LC_MESSAGES/messages.json index 1652dc82f961..ddcf3d746d88 100644 --- a/superset/translations/fr/LC_MESSAGES/messages.json +++ b/superset/translations/fr/LC_MESSAGES/messages.json @@ -1898,6 +1898,7 @@ "Run selection": ["Exécuter la sélection"], "Run": ["Exécuter"], "Stop running (Ctrl + x)": ["Arrêter l'exécution (Ctrl + x)"], + "Stop running (Ctrl + e)": ["Arrêter l'exécution (Ctrl + e)"], "Run query (Ctrl + Return)": ["Exécuter la requête (Ctrl + Return)"], "Save & Explore": ["Sauver et explorer"], "Overwrite & Explore": ["Modifier et explorer"], diff --git a/superset/translations/it/LC_MESSAGES/messages.json b/superset/translations/it/LC_MESSAGES/messages.json index 17573079b2f6..3ae239dce553 100644 --- a/superset/translations/it/LC_MESSAGES/messages.json +++ b/superset/translations/it/LC_MESSAGES/messages.json @@ -1066,6 +1066,7 @@ "Run selection": ["Seleziona una colonna"], "Run": [""], "Stop running (Ctrl + x)": [""], + "Stop running (Ctrl + e)": [""], "Run query (Ctrl + Return)": [""], "Save & Explore": ["Salva una slice"], "Overwrite & Explore": ["Sovrascrivi la slice %s"], diff --git a/superset/translations/ja/LC_MESSAGES/messages.json b/superset/translations/ja/LC_MESSAGES/messages.json index ac886ef463a8..d0f2f9b93f46 100644 --- a/superset/translations/ja/LC_MESSAGES/messages.json +++ b/superset/translations/ja/LC_MESSAGES/messages.json @@ -1300,6 +1300,7 @@ "Run selection": [""], "Run": ["実行"], "Stop running (Ctrl + x)": ["実行を停止 (Ctrl + x)"], + "Stop running (Ctrl + e)": ["実行を停止 (Ctrl + e)"], "Run query (Ctrl + Return)": ["クエリを実行 (Ctrl + Return)"], "Save & Explore": [""], "Overwrite & Explore": [""], diff --git a/superset/translations/ko/LC_MESSAGES/messages.json b/superset/translations/ko/LC_MESSAGES/messages.json index 04b4f191a0a4..3949e99ed673 100644 --- a/superset/translations/ko/LC_MESSAGES/messages.json +++ b/superset/translations/ko/LC_MESSAGES/messages.json @@ -1105,6 +1105,7 @@ "Run selection": [""], "Run": [""], "Stop running (Ctrl + x)": [""], + "Stop running (Ctrl + e)": [""], "Run query (Ctrl + Return)": [""], "Save & Explore": [""], "Overwrite & Explore": [""], diff --git a/superset/translations/nl/LC_MESSAGES/messages.json b/superset/translations/nl/LC_MESSAGES/messages.json index 5f0f98513258..19ab66a085eb 100644 --- a/superset/translations/nl/LC_MESSAGES/messages.json +++ b/superset/translations/nl/LC_MESSAGES/messages.json @@ -3065,6 +3065,7 @@ "Run selection": ["Selectie uitvoeren"], "Run": ["Uitvoeren"], "Stop running (Ctrl + x)": ["Stop de uitvoering (Ctrl + x)"], + "Stop running (Ctrl + e)": ["Stop de uitvoering (Ctrl + e)"], "Run query (Ctrl + Return)": ["Query uitvoeren (Ctrl + Return)"], "Save & Explore": ["Opslaan en verkennen"], "Overwrite & Explore": ["Overschrijven en verkennen"], diff --git a/superset/translations/pt/LC_MESSAGES/message.json b/superset/translations/pt/LC_MESSAGES/message.json index 491bf8a5e7aa..9ea04398fbd8 100644 --- a/superset/translations/pt/LC_MESSAGES/message.json +++ b/superset/translations/pt/LC_MESSAGES/message.json @@ -1148,6 +1148,7 @@ "Run Selection": ["Executar a query selecionada"], "Run": [""], "Stop running (Ctrl + x)": [""], + "Stop running (Ctrl + e)": [""], "Run query (Ctrl + Return)": [""], "Save & Explore": ["Grave uma visualização"], "Overwrite & Explore": ["Substitua a visualização %s"], diff --git a/superset/translations/pt_BR/LC_MESSAGES/messages.json b/superset/translations/pt_BR/LC_MESSAGES/messages.json index 5dd86d91c155..370a179c4df2 100644 --- a/superset/translations/pt_BR/LC_MESSAGES/messages.json +++ b/superset/translations/pt_BR/LC_MESSAGES/messages.json @@ -1445,6 +1445,7 @@ "Run selection": ["Executar seleção"], "Run": ["Executar"], "Stop running (Ctrl + x)": ["Parar execução (Ctrl + x)"], + "Stop running (Ctrl + e)": ["Parar execução (Ctrl + e)"], "Run query (Ctrl + Return)": ["Executar query (Ctrl + Return)"], "Save & Explore": ["Salvar e explorar"], "Overwrite & Explore": ["Sobrescrever & explorar"], diff --git a/superset/translations/ru/LC_MESSAGES/messages.json b/superset/translations/ru/LC_MESSAGES/messages.json index 713ea6c2dac0..c100ba7f66c3 100644 --- a/superset/translations/ru/LC_MESSAGES/messages.json +++ b/superset/translations/ru/LC_MESSAGES/messages.json @@ -1347,6 +1347,7 @@ "Run selection": ["Выполнить выбранный запрос"], "Run": ["Выполнить"], "Stop running (Ctrl + x)": ["Остановить (Ctrl + x)"], + "Stop running (Ctrl + e)": ["Остановить (Ctrl + e)"], "Run query (Ctrl + Return)": ["Выполнить запрос (Ctrl + Return)"], "Save & Explore": ["Сохранить и исследовать"], "Overwrite & Explore": ["Перезаписать и исследовать"], diff --git a/superset/translations/sk/LC_MESSAGES/messages.json b/superset/translations/sk/LC_MESSAGES/messages.json index b47c025ea0db..ba2b175e2030 100644 --- a/superset/translations/sk/LC_MESSAGES/messages.json +++ b/superset/translations/sk/LC_MESSAGES/messages.json @@ -1146,6 +1146,7 @@ "Run selection": [""], "Run": [""], "Stop running (Ctrl + x)": [""], + "Stop running (Ctrl + e)": [""], "Run query (Ctrl + Return)": [""], "Save & Explore": [""], "Overwrite & Explore": [""], diff --git a/superset/translations/sl/LC_MESSAGES/messages.json b/superset/translations/sl/LC_MESSAGES/messages.json index 7c434181052e..c5ac73ad0c42 100644 --- a/superset/translations/sl/LC_MESSAGES/messages.json +++ b/superset/translations/sl/LC_MESSAGES/messages.json @@ -1858,6 +1858,7 @@ "Run selection": ["Zaženi izbrano"], "Run": ["Zaženi"], "Stop running (Ctrl + x)": ["Ustavi (Ctrl + x)"], + "Stop running (Ctrl + e)": ["Ustavi (Ctrl + e)"], "Run query (Ctrl + Return)": ["Zaženi poizvedbo (Ctrl + Return)"], "Save & Explore": ["Shrani & Razišči"], "Overwrite & Explore": ["Prepiši & Razišči"], diff --git a/superset/translations/zh/LC_MESSAGES/messages.json b/superset/translations/zh/LC_MESSAGES/messages.json index 3b3157bde9d2..1fe419612a41 100644 --- a/superset/translations/zh/LC_MESSAGES/messages.json +++ b/superset/translations/zh/LC_MESSAGES/messages.json @@ -1204,6 +1204,7 @@ "Run selection": ["运行选定的查询"], "Run": ["执行"], "Stop running (Ctrl + x)": ["停止运行 (Ctrl + x)"], + "Stop running (Ctrl + e)": ["停止运行 (Ctrl + e)"], "Run query (Ctrl + Return)": ["执行运行 (Ctrl + Return)"], "Save & Explore": ["保存和浏览"], "Overwrite & Explore": ["覆写和浏览"], From b24f5f31d0ece43dcce155112fcaada39a06b6cd Mon Sep 17 00:00:00 2001 From: SpiderMan Date: Thu, 14 Apr 2022 15:26:01 -0400 Subject: [PATCH 2/3] resolve comment --- .../components/RunQueryActionButton/index.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx b/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx index 4be7b3534061..b8fa27cc12d7 100644 --- a/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx +++ b/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx @@ -27,6 +27,7 @@ import { DropdownButtonProps, } from 'src/components/DropdownButton'; import { detectOS } from 'src/utils/common'; +import { useMemo } from '@storybook/addons'; interface Props { allowAsync: boolean; @@ -107,6 +108,14 @@ const RunQueryActionButton = ({ const isDisabled = !sql.trim(); + const stopButtonTooltipText = useMemo( + () => + userOS === 'MacOS' + ? t('Stop running (Ctrl + x)') + : t('Stop running (Ctrl + e)'), + [userOS], + ); + return ( Date: Thu, 21 Apr 2022 14:53:31 -0400 Subject: [PATCH 3/3] fix invalid import useMemo --- .../src/SqlLab/components/RunQueryActionButton/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx b/superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx index b8fa27cc12d7..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'; @@ -27,7 +27,6 @@ import { DropdownButtonProps, } from 'src/components/DropdownButton'; import { detectOS } from 'src/utils/common'; -import { useMemo } from '@storybook/addons'; interface Props { allowAsync: boolean;