villebro commented on a change in pull request #19064:
URL: https://github.com/apache/superset/pull/19064#discussion_r821677437



##########
File path: 
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
##########
@@ -46,16 +46,30 @@ type DashboardContainerProps = {
   topLevelTabs?: LayoutItem;
 };
 
+const useNativeFilterScopes = () => {
+  const nativeFilters = useSelector<RootState, Filters>(
+    state => state.nativeFilters?.filters,
+  );
+  return useMemo(
+    () =>
+      Object.values(nativeFilters ?? {}).map(filter => ({
+        id: filter.id,
+        scope: filter.scope,
+        type: filter.type,
+      })),
+    [JSON.stringify(nativeFilters)],
+  );
+};
+
 const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
   const dashboardLayout = useSelector<RootState, DashboardLayout>(
     state => state.dashboardLayout.present,
   );
-  const nativeFilters = useSelector<RootState, Filters>(
-    state => state.nativeFilters?.filters,
-  );
+  const nativeFiltersScopes = useNativeFilterScopes();

Review comment:
       nit, let's choose one for consistency (I tend to prefer this one):
   ```suggestion
     const nativeFilterScopes = useNativeFilterScopes();
   ```

##########
File path: superset-frontend/src/dashboard/util/activeDashboardFilters.js
##########
@@ -61,8 +60,26 @@ export function getAppliedFilterValues(chartId) {
   }
   return appliedFilterValuesByChart[chartId];
 }
+export function getChartIdsInFilterScope(filterScope, charts, layout) {
+  const layoutItems = Object.values(layout);
+  return Object.values(charts)
+    .filter(
+      chart =>
+        !filterScope.excluded.includes(chart.id) &&
+        layoutItems
+          .find(
+            layoutItem =>
+              layoutItem?.type === CHART_TYPE &&
+              layoutItem.meta?.chartId === chart.id,
+          )
+          ?.parents?.some(elementId =>
+            filterScope.rootPath.includes(elementId),
+          ),
+    )
+    .map(chart => chart.id);
+}

Review comment:
       As this file is JS, should we consider breaking this out into a TS file 
of its own, like `getChartIdsInFilterScope.ts` and then doing an `export 
default function getChartIdsInFilterScope` there? These functions are heavy as 
it is, and not having types makes it even heavier.




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

To unsubscribe, e-mail: [email protected]

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