mirror of https://github.com/apache/superset.git
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
This commit is contained in:
parent
1d043e53d0
commit
60e06c1692
|
@ -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 (
|
||||
<StyledButton>
|
||||
<ButtonComponent
|
||||
|
@ -114,7 +125,7 @@ const RunQueryActionButton = ({
|
|||
tooltip={
|
||||
(!isDisabled &&
|
||||
(shouldShowStopBtn
|
||||
? t('Stop running (Ctrl + x)')
|
||||
? stopButtonTooltipText
|
||||
: t('Run query (Ctrl + Return)'))) as string
|
||||
}
|
||||
cta
|
||||
|
|
|
@ -357,7 +357,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,
|
||||
},
|
||||
|
|
|
@ -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"
|
||||
],
|
||||
|
|
|
@ -985,6 +985,7 @@
|
|||
"Run selection": [""],
|
||||
"Run": [""],
|
||||
"Stop running (Ctrl + x)": [""],
|
||||
"Stop running (Ctrl + e)": [""],
|
||||
"Run query (Ctrl + Return)": [""],
|
||||
"Save & Explore": [""],
|
||||
"Overwrite & Explore": [""],
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -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": [""],
|
||||
|
|
|
@ -1105,6 +1105,7 @@
|
|||
"Run selection": [""],
|
||||
"Run": [""],
|
||||
"Stop running (Ctrl + x)": [""],
|
||||
"Stop running (Ctrl + e)": [""],
|
||||
"Run query (Ctrl + Return)": [""],
|
||||
"Save & Explore": [""],
|
||||
"Overwrite & Explore": [""],
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -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": ["Перезаписать и исследовать"],
|
||||
|
|
|
@ -1146,6 +1146,7 @@
|
|||
"Run selection": [""],
|
||||
"Run": [""],
|
||||
"Stop running (Ctrl + x)": [""],
|
||||
"Stop running (Ctrl + e)": [""],
|
||||
"Run query (Ctrl + Return)": [""],
|
||||
"Save & Explore": [""],
|
||||
"Overwrite & Explore": [""],
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -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": ["覆写和浏览"],
|
||||
|
|
Loading…
Reference in New Issue