mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
refactor(sqllab): nonblocking switch query editor (#29108)
This commit is contained in:
@@ -301,6 +301,9 @@ describe('getInitialState', () => {
|
||||
name: expectedValue,
|
||||
}),
|
||||
);
|
||||
expect(
|
||||
getInitialState(apiDataWithLocalStorage).sqlLab.lastUpdatedActiveTab,
|
||||
).toEqual(apiDataWithTabState.active_tab.id.toString());
|
||||
});
|
||||
|
||||
it('skip unsaved changes for expired data', () => {
|
||||
|
||||
@@ -110,6 +110,7 @@ export default function getInitialState({
|
||||
};
|
||||
});
|
||||
const tabHistory = activeTab ? [activeTab.id.toString()] : [];
|
||||
let lastUpdatedActiveTab = activeTab ? activeTab.id.toString() : '';
|
||||
let tables = {} as Record<string, Table>;
|
||||
let editorTabLastUpdatedAt = Date.now();
|
||||
if (activeTab) {
|
||||
@@ -217,6 +218,7 @@ export default function getInitialState({
|
||||
if (sqlLab.tabHistory) {
|
||||
tabHistory.push(...sqlLab.tabHistory);
|
||||
}
|
||||
lastUpdatedActiveTab = tabHistory.slice(tabHistory.length - 1)[0] || '';
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -250,6 +252,7 @@ export default function getInitialState({
|
||||
editorTabLastUpdatedAt,
|
||||
queryCostEstimates: {},
|
||||
unsavedQueryEditor,
|
||||
lastUpdatedActiveTab,
|
||||
},
|
||||
localStorageUsageInKilobytes: 0,
|
||||
common,
|
||||
|
||||
@@ -742,6 +742,9 @@ export default function sqlLabReducer(state = {}, action) {
|
||||
[actions.SET_EDITOR_TAB_LAST_UPDATE]() {
|
||||
return { ...state, editorTabLastUpdatedAt: action.timestamp };
|
||||
},
|
||||
[actions.SET_LAST_UPDATED_ACTIVE_TAB]() {
|
||||
return { ...state, lastUpdatedActiveTab: action.queryEditorId };
|
||||
},
|
||||
};
|
||||
if (action.type in actionHandlers) {
|
||||
return actionHandlers[action.type]();
|
||||
|
||||
Reference in New Issue
Block a user