mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
[dashboard] allow user re-order top-level tabs (#7390)
This commit is contained in:
@@ -39,7 +39,10 @@ import {
|
||||
} from '../../../../src/dashboard/actions/dashboardLayout';
|
||||
|
||||
import { setUnsavedChanges } from '../../../../src/dashboard/actions/dashboardState';
|
||||
import { addInfoToast } from '../../../../src/messageToasts/actions';
|
||||
import {
|
||||
addWarningToast,
|
||||
ADD_TOAST,
|
||||
} from '../../../../src/messageToasts/actions';
|
||||
|
||||
import {
|
||||
DASHBOARD_GRID_TYPE,
|
||||
@@ -334,7 +337,9 @@ describe('dashboardLayout actions', () => {
|
||||
|
||||
const thunk = handleComponentDrop(dropResult);
|
||||
thunk(dispatch, getState);
|
||||
expect(dispatch.getCall(0).args[0].type).toEqual(addInfoToast('').type);
|
||||
expect(dispatch.getCall(0).args[0].type).toEqual(
|
||||
addWarningToast('').type,
|
||||
);
|
||||
|
||||
expect(dispatch.callCount).toBe(1);
|
||||
});
|
||||
@@ -402,6 +407,64 @@ describe('dashboardLayout actions', () => {
|
||||
|
||||
expect(dispatch.callCount).toBe(2);
|
||||
});
|
||||
|
||||
it('should dispatch a toast if drop top-level tab into nested tab', () => {
|
||||
const { getState, dispatch } = setup({
|
||||
dashboardLayout: {
|
||||
present: {
|
||||
[DASHBOARD_ROOT_ID]: {
|
||||
children: ['TABS-ROOT_TABS'],
|
||||
id: DASHBOARD_ROOT_ID,
|
||||
type: 'ROOT',
|
||||
},
|
||||
'TABS-ROOT_TABS': {
|
||||
children: ['TAB-iMppmTOQy', 'TAB-rt1y8cQ6K9', 'TAB-X_pnCIwPN'],
|
||||
id: 'TABS-ROOT_TABS',
|
||||
meta: {},
|
||||
parents: ['ROOT_ID'],
|
||||
type: TABS_TYPE,
|
||||
},
|
||||
'TABS-ROW_TABS': {
|
||||
children: [
|
||||
'TAB-dKIDBT03bQ',
|
||||
'TAB-PtxY5bbTe',
|
||||
'TAB-Wc2P-yGMz',
|
||||
'TAB-U-xe_si7i',
|
||||
],
|
||||
id: 'TABS-ROW_TABS',
|
||||
meta: {},
|
||||
parents: ['ROOT_ID', 'TABS-ROOT_TABS', 'TAB-X_pnCIwPN'],
|
||||
type: TABS_TYPE,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const dropResult = {
|
||||
source: {
|
||||
id: 'TABS-ROOT_TABS',
|
||||
index: 1,
|
||||
type: TABS_TYPE,
|
||||
},
|
||||
destination: {
|
||||
id: 'TABS-ROW_TABS',
|
||||
index: 1,
|
||||
type: TABS_TYPE,
|
||||
},
|
||||
dragging: {
|
||||
id: 'TAB-rt1y8cQ6K9',
|
||||
meta: { text: 'New Tab' },
|
||||
type: 'TAB',
|
||||
},
|
||||
};
|
||||
|
||||
const thunk1 = handleComponentDrop(dropResult);
|
||||
thunk1(dispatch, getState);
|
||||
|
||||
const thunk2 = dispatch.getCall(0).args[0];
|
||||
thunk2(dispatch, getState);
|
||||
|
||||
expect(dispatch.getCall(1).args[0].type).toEqual(ADD_TOAST);
|
||||
});
|
||||
});
|
||||
|
||||
describe('undoLayoutAction', () => {
|
||||
|
||||
Reference in New Issue
Block a user