mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
fix(dashboard): max call size stack error (#24304)
This commit is contained in:
parent
ede6acdb3a
commit
9c7b8b8c78
@ -18,7 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
import { Behavior, FeatureFlag } from '@superset-ui/core';
|
import { Behavior, FeatureFlag } from '@superset-ui/core';
|
||||||
import * as featureFlags from 'src/featureFlags';
|
import * as featureFlags from 'src/featureFlags';
|
||||||
import { nativeFilterGate } from './utils';
|
import { DashboardLayout } from 'src/dashboard/types';
|
||||||
|
import { nativeFilterGate, findTabsWithChartsInScope } from './utils';
|
||||||
|
|
||||||
let isFeatureEnabledMock: jest.MockInstance<boolean, [feature: FeatureFlag]>;
|
let isFeatureEnabledMock: jest.MockInstance<boolean, [feature: FeatureFlag]>;
|
||||||
|
|
||||||
@ -124,3 +125,40 @@ describe('nativeFilterGate', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('findTabsWithChartsInScope should handle a recursive layout structure', () => {
|
||||||
|
const dashboardLayout = {
|
||||||
|
DASHBOARD_VERSION_KEY: 'v2',
|
||||||
|
ROOT_ID: {
|
||||||
|
children: ['GRID_ID'],
|
||||||
|
id: 'ROOT_ID',
|
||||||
|
type: 'ROOT',
|
||||||
|
},
|
||||||
|
GRID_ID: {
|
||||||
|
children: ['TAB-LrujeuD5Qn', 'TABS-kN7tw6vFif'],
|
||||||
|
id: 'GRID_ID',
|
||||||
|
parents: ['ROOT_ID'],
|
||||||
|
type: 'GRID',
|
||||||
|
},
|
||||||
|
'TAB-LrujeuD5Qn': {
|
||||||
|
children: ['TABS-kN7tw6vFif'],
|
||||||
|
id: 'TAB-LrujeuD5Qn',
|
||||||
|
meta: {
|
||||||
|
text: 'View by Totals',
|
||||||
|
},
|
||||||
|
parents: ['ROOT_ID'],
|
||||||
|
type: 'TAB',
|
||||||
|
},
|
||||||
|
'TABS-kN7tw6vFif': {
|
||||||
|
children: ['TAB-LrujeuD5Qn', 'TAB--7BUkKkNl'],
|
||||||
|
id: 'TABS-kN7tw6vFif',
|
||||||
|
meta: {},
|
||||||
|
parents: ['ROOT_ID'],
|
||||||
|
type: 'TABS',
|
||||||
|
},
|
||||||
|
} as any as DashboardLayout;
|
||||||
|
|
||||||
|
expect(Array.from(findTabsWithChartsInScope(dashboardLayout, []))).toEqual(
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
@ -154,7 +154,12 @@ const findTabsWithChartsInScopeHelper = (
|
|||||||
componentId: string,
|
componentId: string,
|
||||||
tabIds: string[],
|
tabIds: string[],
|
||||||
tabsToHighlight: Set<string>,
|
tabsToHighlight: Set<string>,
|
||||||
|
visited: Set<string>,
|
||||||
) => {
|
) => {
|
||||||
|
if (visited.has(componentId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
visited.add(componentId);
|
||||||
if (
|
if (
|
||||||
dashboardLayout?.[componentId]?.type === CHART_TYPE &&
|
dashboardLayout?.[componentId]?.type === CHART_TYPE &&
|
||||||
chartsInScope.includes(dashboardLayout[componentId]?.meta?.chartId)
|
chartsInScope.includes(dashboardLayout[componentId]?.meta?.chartId)
|
||||||
@ -175,6 +180,7 @@ const findTabsWithChartsInScopeHelper = (
|
|||||||
childId,
|
childId,
|
||||||
isComponentATab(dashboardLayout, childId) ? [...tabIds, childId] : tabIds,
|
isComponentATab(dashboardLayout, childId) ? [...tabIds, childId] : tabIds,
|
||||||
tabsToHighlight,
|
tabsToHighlight,
|
||||||
|
visited,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -187,6 +193,7 @@ export const findTabsWithChartsInScope = (
|
|||||||
const rootChildId = dashboardRoot.children[0];
|
const rootChildId = dashboardRoot.children[0];
|
||||||
const hasTopLevelTabs = rootChildId !== DASHBOARD_GRID_ID;
|
const hasTopLevelTabs = rootChildId !== DASHBOARD_GRID_ID;
|
||||||
const tabsInScope = new Set<string>();
|
const tabsInScope = new Set<string>();
|
||||||
|
const visited = new Set<string>();
|
||||||
if (hasTopLevelTabs) {
|
if (hasTopLevelTabs) {
|
||||||
dashboardLayout[rootChildId]?.children?.forEach(tabId =>
|
dashboardLayout[rootChildId]?.children?.forEach(tabId =>
|
||||||
findTabsWithChartsInScopeHelper(
|
findTabsWithChartsInScopeHelper(
|
||||||
@ -195,6 +202,7 @@ export const findTabsWithChartsInScope = (
|
|||||||
tabId,
|
tabId,
|
||||||
[tabId],
|
[tabId],
|
||||||
tabsInScope,
|
tabsInScope,
|
||||||
|
visited,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -207,6 +215,7 @@ export const findTabsWithChartsInScope = (
|
|||||||
element.id,
|
element.id,
|
||||||
[element.id],
|
[element.id],
|
||||||
tabsInScope,
|
tabsInScope,
|
||||||
|
visited,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user