mistercrunch commented on a change in pull request #4836: Refactoring on 
exploreReducer.js
URL: 
https://github.com/apache/incubator-superset/pull/4836#discussion_r183274530
 
 

 ##########
 File path: superset/assets/src/explore/reducers/exploreReducer.js
 ##########
 @@ -5,77 +5,118 @@ import * as actions from '../actions/exploreActions';
 export default function exploreReducer(state = {}, action) {
   const actionHandlers = {
     [actions.TOGGLE_FAVE_STAR]() {
-      return Object.assign({}, state, { isStarred: action.isStarred });
+      return {
+        ...state,
+        isStarred: action.isStarred,
+      };
     },
     [actions.FETCH_DATASOURCE_STARTED]() {
-      return Object.assign({}, state, { isDatasourceMetaLoading: true });
+      return {
+        ...state,
+        isDatasourceMetaLoading: true,
+      };
     },
     [actions.FETCH_DATASOURCE_SUCCEEDED]() {
-      return Object.assign({}, state, { isDatasourceMetaLoading: false });
+      return {
+        ...state,
+        isDatasourceMetaLoading: false,
+      };
     },
     [actions.FETCH_DATASOURCE_FAILED]() {
-      // todo(alanna) handle failure/error state
-      return Object.assign({}, state,
-        {
-          isDatasourceMetaLoading: false,
-          controlPanelAlert: action.error,
-        });
+      return {
+        ...state,
+        isDatasourceMetaLoading: false,
+        controlPanelAlert: action.error,
+      };
     },
     [actions.SET_DATASOURCE]() {
-      return Object.assign({}, state, { datasource: action.datasource });
+
+      return {
+        ...state,
+        datasource: action.datasource,
+      };
     },
     [actions.FETCH_DATASOURCES_STARTED]() {
-      return Object.assign({}, state, { isDatasourcesLoading: true });
+
+      return {
+        ...state,
+        isDatasourcesLoading: true,
+      };
     },
     [actions.FETCH_DATASOURCES_SUCCEEDED]() {
-      return Object.assign({}, state, { isDatasourcesLoading: false });
+
+      return {
+        ...state,
+        isDatasourcesLoading: false,
+      };
     },
     [actions.FETCH_DATASOURCES_FAILED]() {
-      // todo(alanna) handle failure/error state
-      return Object.assign({}, state,
-        {
-          isDatasourcesLoading: false,
-          controlPanelAlert: action.error,
-        });
+
+      return {
+        ...state,
+        isDatasourcesLoading: false,
+        controlPanelAlert: action.error,
+      };
     },
     [actions.SET_DATASOURCES]() {
-      return Object.assign({}, state, { datasources: action.datasources });
+      return {
+        ...state,
+        datasources: action.datasources,
+      };
     },
     [actions.REMOVE_CONTROL_PANEL_ALERT]() {
-      return Object.assign({}, state, { controlPanelAlert: null });
+      return {
+        ...state,
+        controlPanelAlert: null,
+      };
     },
     [actions.SET_FIELD_VALUE]() {
       const controls = Object.assign({}, state.controls);
       const control = Object.assign({}, controls[action.controlName]);
       control.value = action.value;
       control.validationErrors = action.validationErrors;
       controls[action.controlName] = control;
-      const changes = { controls };
+      const changes = {
+        controls,
+      };
       if (control.renderTrigger) {
         changes.triggerRender = true;
       }
-      return Object.assign({}, state, changes);
+      return {
+        ...state,
+        ...changes,
+      };
     },
     [actions.SET_EXPLORE_CONTROLS]() {
       const controls = getControlsState(state, action.formData);
-      return Object.assign({}, state, { controls });
+      return {
+        ...state,
+        ...controls,
 
 Review comment:
   From my understanding this will spread the content of `controls`  into the 
root of `state`. Meaning if I translate your current statement here into the 
pre-ES6 notation I'll get `Object.assign({}, state, controls);` which is 
different from `Object.assign({}, state, { controls });`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to