etr2460 commented on a change in pull request #13695:
URL: https://github.com/apache/superset/pull/13695#discussion_r597346557
##########
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:
lol TIL!
I do wonder what would happen if we all used `reduce` more often; maybe it
would be as easy to read as `map`! But this works :D
--
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]