fix: params in sql lab are jumpy in the ace editor (#16536)

* fix jumpy params

* remove cypress tests
This commit is contained in:
Elizabeth Thompson
2021-09-07 09:38:45 -07:00
committed by GitHub
parent 37c2020035
commit 519baa6f00
2 changed files with 15 additions and 18 deletions

View File

@@ -613,7 +613,7 @@ describe('async actions', () => {
describe('queryEditorSetSql', () => {
describe('with backend persistence flag on', () => {
it('does not update the tab state in the backend', () => {
it('updates the tab state in the backend', () => {
expect.assertions(2);
const sql = 'SELECT * ';
@@ -629,7 +629,7 @@ describe('async actions', () => {
});
});
describe('with backend persistence flag off', () => {
it('updates the tab state in the backend', () => {
it('does not update the tab state in the backend', () => {
const backendPersistenceOffMock = jest
.spyOn(featureFlags, 'isFeatureEnabled')
.mockImplementation(

View File

@@ -949,6 +949,11 @@ export function queryEditorSetQueryLimit(queryEditor, queryLimit) {
export function queryEditorSetTemplateParams(queryEditor, templateParams) {
return function (dispatch) {
dispatch({
type: QUERY_EDITOR_SET_TEMPLATE_PARAMS,
queryEditor,
templateParams,
});
const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE)
? SupersetClient.put({
endpoint: encodeURI(`/tabstateview/${queryEditor.id}`),
@@ -956,24 +961,16 @@ export function queryEditorSetTemplateParams(queryEditor, templateParams) {
})
: Promise.resolve();
return sync
.then(() =>
dispatch({
type: QUERY_EDITOR_SET_TEMPLATE_PARAMS,
queryEditor,
templateParams,
}),
)
.catch(() =>
dispatch(
addDangerToast(
t(
'An error occurred while setting the tab template parameters. ' +
'Please contact your administrator.',
),
return sync.catch(() =>
dispatch(
addDangerToast(
t(
'An error occurred while setting the tab template parameters. ' +
'Please contact your administrator.',
),
),
);
),
);
};
}