mirror of
https://github.com/apache/superset.git
synced 2024-09-16 02:29:39 -04:00
fix: most Recently Selected Table Should Appear at the Top of the List on the Left Panel (#19258)
This commit is contained in:
parent
29cba2b00c
commit
4669b6ce11
@ -1005,8 +1005,8 @@ export function queryEditorSetSelectedText(queryEditor, sql) {
|
|||||||
return { type: QUERY_EDITOR_SET_SELECTED_TEXT, queryEditor, sql };
|
return { type: QUERY_EDITOR_SET_SELECTED_TEXT, queryEditor, sql };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mergeTable(table, query) {
|
export function mergeTable(table, query, prepend) {
|
||||||
return { type: MERGE_TABLE, table, query };
|
return { type: MERGE_TABLE, table, query, prepend };
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTableMetadata(table, query, dispatch) {
|
function getTableMetadata(table, query, dispatch) {
|
||||||
@ -1076,12 +1076,16 @@ export function addTable(query, database, tableName, schemaName) {
|
|||||||
name: tableName,
|
name: tableName,
|
||||||
};
|
};
|
||||||
dispatch(
|
dispatch(
|
||||||
mergeTable({
|
mergeTable(
|
||||||
|
{
|
||||||
...table,
|
...table,
|
||||||
isMetadataLoading: true,
|
isMetadataLoading: true,
|
||||||
isExtraMetadataLoading: true,
|
isExtraMetadataLoading: true,
|
||||||
expanded: true,
|
expanded: true,
|
||||||
}),
|
},
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
|
@ -725,7 +725,7 @@ describe('async actions', () => {
|
|||||||
|
|
||||||
describe('addTable', () => {
|
describe('addTable', () => {
|
||||||
it('updates the table schema state in the backend', () => {
|
it('updates the table schema state in the backend', () => {
|
||||||
expect.assertions(5);
|
expect.assertions(6);
|
||||||
|
|
||||||
const database = { disable_data_preview: true };
|
const database = { disable_data_preview: true };
|
||||||
const tableName = 'table';
|
const tableName = 'table';
|
||||||
@ -743,6 +743,7 @@ describe('async actions', () => {
|
|||||||
expect(store.getActions().map(a => a.type)).toEqual(
|
expect(store.getActions().map(a => a.type)).toEqual(
|
||||||
expectedActionTypes,
|
expectedActionTypes,
|
||||||
);
|
);
|
||||||
|
expect(store.getActions()[0].prepend).toBeTruthy();
|
||||||
expect(fetchMock.calls(updateTableSchemaEndpoint)).toHaveLength(1);
|
expect(fetchMock.calls(updateTableSchemaEndpoint)).toHaveLength(1);
|
||||||
expect(fetchMock.calls(getTableMetadataEndpoint)).toHaveLength(1);
|
expect(fetchMock.calls(getTableMetadataEndpoint)).toHaveLength(1);
|
||||||
expect(fetchMock.calls(getExtraTableMetadataEndpoint)).toHaveLength(
|
expect(fetchMock.calls(getExtraTableMetadataEndpoint)).toHaveLength(
|
||||||
|
@ -134,7 +134,7 @@ export default function sqlLabReducer(state = {}, action) {
|
|||||||
}
|
}
|
||||||
// for new table, associate Id of query for data preview
|
// for new table, associate Id of query for data preview
|
||||||
at.dataPreviewQueryId = null;
|
at.dataPreviewQueryId = null;
|
||||||
let newState = addToArr(state, 'tables', at);
|
let newState = addToArr(state, 'tables', at, Boolean(action.prepend));
|
||||||
if (action.query) {
|
if (action.query) {
|
||||||
newState = alterInArr(newState, 'tables', at, {
|
newState = alterInArr(newState, 'tables', at, {
|
||||||
dataPreviewQueryId: action.query.id,
|
dataPreviewQueryId: action.query.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user