You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2021/05/27 04:55:09 UTC

[superset] branch master updated: fix(native-filters): remove indicators outside scope (#14838)

This is an automated email from the ASF dual-hosted git repository.

villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new bd2c087  fix(native-filters): remove indicators outside scope (#14838)
bd2c087 is described below

commit bd2c087f78941ed443834e2d191b34f0160874a7
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Thu May 27 07:53:52 2021 +0300

    fix(native-filters): remove indicators outside scope (#14838)
    
    * fix(native-filters): remove indicators outside scope
    
    * lint
---
 .../dashboard/components/FiltersBadge/selectors.ts | 36 +++++++++-------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/superset-frontend/src/dashboard/components/FiltersBadge/selectors.ts b/superset-frontend/src/dashboard/components/FiltersBadge/selectors.ts
index 7560f85..e20cecc 100644
--- a/superset-frontend/src/dashboard/components/FiltersBadge/selectors.ts
+++ b/superset-frontend/src/dashboard/components/FiltersBadge/selectors.ts
@@ -192,20 +192,15 @@ export const selectNativeIndicatorsForChart = (
 
   const getStatus = ({
     value,
-    isAffectedByScope,
     column,
     type = DataMaskType.NativeFilters,
   }: {
     value: any;
-    isAffectedByScope: boolean;
     column?: string;
     type?: DataMaskType;
   }): IndicatorStatus => {
     // a filter is only considered unset if it's value is null
     const hasValue = value !== null;
-    if (!isAffectedByScope) {
-      return IndicatorStatus.Unset;
-    }
     if (type === DataMaskType.CrossFilters && hasValue) {
       return IndicatorStatus.CrossFilterApplied;
     }
@@ -223,14 +218,13 @@ export const selectNativeIndicatorsForChart = (
 
   let nativeFilterIndicators: any = [];
   if (isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS)) {
-    nativeFilterIndicators = Object.values(nativeFilters.filters).map(
-      nativeFilter => {
-        const isAffectedByScope = getTreeCheckedItems(
-          nativeFilter.scope,
-          dashboardLayout,
-        ).some(
+    nativeFilterIndicators = Object.values(nativeFilters.filters)
+      .filter(nativeFilter =>
+        getTreeCheckedItems(nativeFilter.scope, dashboardLayout).some(
           layoutItem => dashboardLayout[layoutItem]?.meta?.chartId === chartId,
-        );
+        ),
+      )
+      .map(nativeFilter => {
         const column = nativeFilter.targets[0]?.column?.name;
         let value = dataMask[nativeFilter.id]?.filterState?.value ?? null;
         if (!Array.isArray(value) && value !== null) {
@@ -240,25 +234,24 @@ export const selectNativeIndicatorsForChart = (
           column,
           name: nativeFilter.name,
           path: [nativeFilter.id],
-          status: getStatus({ value, isAffectedByScope, column }),
+          status: getStatus({ value, column }),
           value,
         };
-      },
-    );
+      });
   }
 
   let crossFilterIndicators: any = [];
   if (isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS)) {
     crossFilterIndicators = Object.values(chartConfiguration)
-      .map(chartConfig => {
-        const scope = chartConfig?.crossFilters?.scope;
-        const isAffectedByScope = getTreeCheckedItems(
-          scope,
+      .filter(chartConfig =>
+        getTreeCheckedItems(
+          chartConfig?.crossFilters?.scope,
           dashboardLayout,
         ).some(
           layoutItem => dashboardLayout[layoutItem]?.meta?.chartId === chartId,
-        );
-
+        ),
+      )
+      .map(chartConfig => {
         let value = dataMask[chartConfig.id]?.filterState?.value ?? null;
         if (!Array.isArray(value) && value !== null) {
           value = [value];
@@ -270,7 +263,6 @@ export const selectNativeIndicatorsForChart = (
           path: [`${chartConfig.id}`],
           status: getStatus({
             value,
-            isAffectedByScope,
             type: DataMaskType.CrossFilters,
           }),
           value,