etr2460 commented on a change in pull request #13695:
URL: https://github.com/apache/superset/pull/13695#discussion_r597315200
##########
File path:
superset-frontend/spec/javascripts/dashboard/util/getFilterScopeFromNodesTree_spec.js
##########
@@ -381,5 +381,96 @@ describe('getFilterScopeFromNodesTree', () => {
immune: [105, 103, 102, 101, 108, 104],
});
});
+
+ // test case 3:
+ // - filter_109
+ // - chart_106
+ // - Tab 1
+ // - Nested_Tab1
+ // - chart_101
+ // - chart_102
+ // - Nested_Tab2
+ // - chart_103
+ // - chart_104
+
+ const nodes3 = [
Review comment:
this const can live in the test case right? since it's not being used by
any other tests
##########
File path: superset-frontend/src/dashboard/util/getFilterScopeFromNodesTree.js
##########
@@ -22,11 +22,29 @@ import { flatMap, isEmpty } from 'lodash';
import { CHART_TYPE, TAB_TYPE } from './componentTypes';
import { getChartIdAndColumnFromFilterKey } from './getDashboardFilterKey';
+function getChartsFromTabsNotInScope({ tabs = [], tabsInScope = [] }) {
+ const chartsNotInScope = [];
+ tabs.forEach(({ value: tab, children: tabChildren }) => {
+ if (tabChildren && !tabsInScope.includes(tab)) {
+ tabChildren.forEach(({ value: subTab, children: subTabChildren }) => {
+ if (subTabChildren && !tabsInScope.includes(subTab)) {
+ chartsNotInScope.push(
+ ...subTabChildren.filter(({ type }) => type === CHART_TYPE),
+ );
+ }
+ });
+ }
+ });
+
+ // return chartId only
+ return chartsNotInScope.map(({ value }) => value);
Review comment:
I feel like this could probably be done more succinctly with a `reduce`?
I can try to work my way through it as a suggestion if you'd like
##########
File path: superset-frontend/src/dashboard/util/getFilterScopeFromNodesTree.js
##########
@@ -22,11 +22,29 @@ import { flatMap, isEmpty } from 'lodash';
import { CHART_TYPE, TAB_TYPE } from './componentTypes';
import { getChartIdAndColumnFromFilterKey } from './getDashboardFilterKey';
+function getChartsFromTabsNotInScope({ tabs = [], tabsInScope = [] }) {
Review comment:
maybe `getChartIdsFromTabsNotInScope`? To clarify that this isn't
returning chart objects
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]