You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/02/10 13:30:21 UTC

[GitHub] [superset] simcha90 commented on a change in pull request #13052: fix(explore): pie chart label bugs

simcha90 commented on a change in pull request #13052:
URL: https://github.com/apache/superset/pull/13052#discussion_r573726255



##########
File path: superset-frontend/src/explore/components/controls/VizTypeControl.jsx
##########
@@ -166,15 +166,21 @@ const VizTypeControl = props => {
   const filterString = filter.toLowerCase();
 
   const filteredTypes = DEFAULT_ORDER.filter(type => registry.has(type))
-    .filter(type => !registry.get(type).isNativeFilter)
+    .filter(type => {
+      const behaviors = registry.get(type)?.behaviors || [];
+      return behaviors.includes(Behavior.CROSS_FILTER) || !behaviors.length;
+    })
     .map(type => ({
       key: type,
       value: registry.get(type),
     }))
     .concat(
       registry
         .entries()
-        .filter(entry => !entry.value.isNativeFilter)
+        .filter(entry => {

Review comment:
       may be move it to some utils like
   ```
   getVisibleCharts = ({ behaviours } = {}) => {
         return behaviors?.includes(Behavior.CROSS_FILTER) || !behaviors?.length;
       }
   }
   and use it like:
   
   ```
   .filter(type =>getVisibleCharts(registry.get(type)))
   and
   .filter(entry =>getVisibleCharts(entry.value))
   ```
   

##########
File path: superset-frontend/src/explore/components/controls/VizTypeControl.jsx
##########
@@ -166,15 +166,21 @@ const VizTypeControl = props => {
   const filterString = filter.toLowerCase();
 
   const filteredTypes = DEFAULT_ORDER.filter(type => registry.has(type))
-    .filter(type => !registry.get(type).isNativeFilter)
+    .filter(type => {
+      const behaviors = registry.get(type)?.behaviors || [];
+      return behaviors.includes(Behavior.CROSS_FILTER) || !behaviors.length;
+    })
     .map(type => ({
       key: type,
       value: registry.get(type),
     }))
     .concat(
       registry
         .entries()
-        .filter(entry => !entry.value.isNativeFilter)
+        .filter(entry => {

Review comment:
       may be move it to some utils like
   ```
   getVisibleCharts = ({ behaviours } = {}) => {
         return behaviors?.includes(Behavior.CROSS_FILTER) || !behaviors?.length;
       }
   }
   and use it like:
   
   .filter(type =>getVisibleCharts(registry.get(type)))
   and
   .filter(entry =>getVisibleCharts(entry.value))
   ```
   

##########
File path: superset-frontend/src/explore/components/controls/VizTypeControl.jsx
##########
@@ -166,15 +166,21 @@ const VizTypeControl = props => {
   const filterString = filter.toLowerCase();
 
   const filteredTypes = DEFAULT_ORDER.filter(type => registry.has(type))
-    .filter(type => !registry.get(type).isNativeFilter)
+    .filter(type => {
+      const behaviors = registry.get(type)?.behaviors || [];
+      return behaviors.includes(Behavior.CROSS_FILTER) || !behaviors.length;
+    })
     .map(type => ({
       key: type,
       value: registry.get(type),
     }))
     .concat(
       registry
         .entries()
-        .filter(entry => !entry.value.isNativeFilter)
+        .filter(entry => {

Review comment:
       may be move it to some utils like
   ```
   getVisibleCharts = ({ behaviours } = {}) => {
         return behaviors?.includes(Behavior.CROSS_FILTER) || !behaviors?.length;
       }
   }
   
   and use it like:
   
   .filter(type =>getVisibleCharts(registry.get(type)))
   and
   .filter(entry =>getVisibleCharts(entry.value))
   ```
   




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org