superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: Refactoring on exploreReducer.js (#4836)
Date Mon, 23 Apr 2018 15:29:07 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 5927e7d  Refactoring on exploreReducer.js (#4836)
5927e7d is described below

commit 5927e7dfe60d6a45c17165702536b9e3d55f9fbc
Author: Hugh A. Miles II <hughmil3s@gmail.com>
AuthorDate: Mon Apr 23 11:29:01 2018 -0400

    Refactoring on exploreReducer.js (#4836)
    
    * refactoring on exploreReducser
    
    * fix building json
---
 .../assets/src/explore/reducers/exploreReducer.js  | 97 +++++++++++++++-------
 1 file changed, 68 insertions(+), 29 deletions(-)

diff --git a/superset/assets/src/explore/reducers/exploreReducer.js b/superset/assets/src/explore/reducers/exploreReducer.js
index e366f28..e6cb827 100644
--- a/superset/assets/src/explore/reducers/exploreReducer.js
+++ b/superset/assets/src/explore/reducers/exploreReducer.js
@@ -5,44 +5,70 @@ 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);
@@ -50,32 +76,45 @@ export default function exploreReducer(state = {}, action) {
       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: getControlsState(state, action.formData),
+      };
     },
     [actions.UPDATE_CHART_TITLE]() {
       const updatedSlice = Object.assign({}, state.slice, { slice_name: action.slice_name
});
-      return Object.assign({}, state, { slice: updatedSlice });
+      return {
+        ...state,
+        slice: updatedSlice,
+      };
     },
     [actions.RESET_FIELDS]() {
-      const controls = getControlsState(state, getFormDataFromControls(state.controls));
-      return Object.assign({}, state, { controls });
+      return {
+        ...state,
+        controls: getControlsState(state, getFormDataFromControls(state.controls)),
+      };
     },
     [actions.CREATE_NEW_SLICE]() {
-      return Object.assign({}, state, {
+      return {
+        ...state,
         slice: action.slice,
         controls: getControlsState(state, action.form_data),
         can_add: action.can_add,
         can_download: action.can_download,
         can_overwrite: action.can_overwrite,
-      });
+      };
     },
   };
   if (action.type in actionHandlers) {

-- 
To stop receiving notification emails like this one, please contact
maximebeauchemin@apache.org.

Mime
View raw message