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/15 10:47:53 UTC

[GitHub] [superset] ktmud commented on a change in pull request #13094: fix: Fix switching viz type to and from Filter box

ktmud commented on a change in pull request #13094:
URL: https://github.com/apache/superset/pull/13094#discussion_r576099738



##########
File path: superset-frontend/src/explore/reducers/exploreReducer.js
##########
@@ -121,17 +121,35 @@ export default function exploreReducer(state = {}, action) {
       });
       const hasErrors = errors && errors.length > 0;
 
+      const controls =
+        action.controlName === 'viz_type' &&
+        action.value !== state.controls.viz_type.value
+          ? {
+              ...getControlsState(
+                state,
+                getFormDataFromControls({
+                  ...state.controls,
+                  viz_type: control,
+                }),
+              ),
+              [action.controlName]: {
+                ...control,
+                validationErrors: errors,
+              },
+            }
+          : {
+              ...state.controls,
+              [action.controlName]: {
+                ...control,
+                validationErrors: errors,
+              },
+            };

Review comment:
       These lines are a little difficult to grok, creating a new variable might make it easier to read:
   
   ```js
         const currentControlsState =
           action.controlName === 'viz_type' &&
           action.value !== state.controls.viz_type.value
             ? // rebuild the full control state if switching viz type
               getControlsState(
                 state,
                 getFormDataFromControls({
                   ...state.controls,
                   viz_type: control,
                 }),
               )
             : state.controls;
   
         return {
           ...state,
           form_data: new_form_data,
           triggerRender: control.renderTrigger && !hasErrors,
           controls: {
             ...currentControlsState,
             [action.controlName]: {
               ...control,
               validationErrors: errors,
             },
           },
         };
   ```




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