Skip to content

Commit

Permalink
fix: params in sql lab are jumpy in the ace editor (apache#16536)
Browse files Browse the repository at this point in the history
* fix jumpy params

* remove cypress tests
  • Loading branch information
eschutho authored Sep 7, 2021
1 parent 37c2020 commit 519baa6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 * ';
Expand All @@ -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(
Expand Down
29 changes: 13 additions & 16 deletions superset-frontend/src/SqlLab/actions/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,31 +949,28 @@ 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}`),
postPayload: { template_params: 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.',
),
),
);
),
);
};
}

Expand Down

0 comments on commit 519baa6

Please sign in to comment.