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

@@ -32,6 +32,7 @@ import {
} from 'src/components/MessageToasts/actions';
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
import COMMON_ERR_MESSAGES from 'src/utils/errorMessages';
import { newQueryTabName } from '../utils/newQueryTabName';
export const RESET_STATE = 'RESET_STATE';
export const ADD_QUERY_EDITOR = 'ADD_QUERY_EDITOR';
@@ -590,6 +591,22 @@ export function addQueryEditor(queryEditor) {
};
}
export function addNewQueryEditor(queryEditor) {
return function (dispatch, getState) {
const {
sqlLab: { queryEditors },
} = getState();
const name = newQueryTabName(queryEditors || []);
return dispatch(
addQueryEditor({
...queryEditor,
name,
}),
);
};
}
export function cloneQueryToNewTab(query, autorun) {
return function (dispatch, getState) {
const state = getState();