chore(sqllab): refactor addQueryEditor for new tab (#21711)

This commit is contained in:
JUST.in DO IT
2022-10-07 13:57:39 -07:00
committed by GitHub
parent a5ff0949a6
commit 0c461497ff
5 changed files with 73 additions and 32 deletions

View File

@@ -37,7 +37,7 @@ import { Menu } from 'src/components/Menu';
import Icons from 'src/components/Icons';
import { detectOS } from 'src/utils/common';
import {
addQueryEditor,
addNewQueryEditor,
CtasEnum,
estimateQueryCost,
persistEditorHeight,
@@ -84,7 +84,6 @@ import ShareSqlLabQuery from '../ShareSqlLabQuery';
import SqlEditorLeftBar from '../SqlEditorLeftBar';
import AceEditorWrapper from '../AceEditorWrapper';
import RunQueryActionButton from '../RunQueryActionButton';
import { newQueryTabName } from '../../utils/newQueryTabName';
import QueryLimitSelect from '../QueryLimitSelect';
const appContainer = document.getElementById('app');
@@ -179,8 +178,6 @@ const SqlEditor = ({
},
);
const queryEditors = useSelector(({ sqlLab }) => sqlLab.queryEditors);
const [height, setHeight] = useState(0);
const [autorun, setAutorun] = useState(queryEditor.autorun);
const [ctas, setCtas] = useState('');
@@ -274,13 +271,7 @@ const SqlEditor = ({
key: userOS === 'Windows' ? 'ctrl+q' : 'ctrl+t',
descr: t('New tab'),
func: () => {
const name = newQueryTabName(queryEditors || []);
dispatch(
addQueryEditor({
...queryEditor,
name,
}),
);
dispatch(addNewQueryEditor(queryEditor));
},
},
{