graceguo-supercat commented on a change in pull request #13695:
URL: https://github.com/apache/superset/pull/13695#discussion_r597331583



##########
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 would use `reduce` a few month ago...Recently @ktmud gave me a code 
review comment and says `reduce` is hard to read (for many ppl)...like this 
thread:
   https://twitter.com/jaffathecake/status/1213077702300852224?lang=en
   
   So now i try to avoid using `reduce`.




-- 
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]

Reply via email to