couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject fauxton commit: updated refs/heads/master to 1b85d7b
Date Mon, 20 Feb 2017 10:30:52 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 09c82fca3 -> 1b85d7b32


Improve the way redux reducers are handled


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/1b85d7b3
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/1b85d7b3
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/1b85d7b3

Branch: refs/heads/master
Commit: 1b85d7b32ddf4a0fe02d221646beec5b9bce4239
Parents: 09c82fc
Author: Tim Pinington <timpinington@gmail.com>
Authored: Tue Feb 14 14:39:32 2017 +0000
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Mon Feb 20 12:30:15 2017 +0200

----------------------------------------------------------------------
 .babelrc                                          |  2 +-
 .eslintrc                                         |  3 ++-
 .../permissions/__tests__/container-test.js       |  4 ++--
 app/addons/permissions/base.js                    |  6 ++++--
 .../permissions/container/PermissionsContainer.js | 14 +++++++-------
 app/core/base.js                                  | 11 ++++++++++-
 app/main.js                                       | 18 ++----------------
 package.json                                      |  1 +
 8 files changed, 29 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1b85d7b3/.babelrc
----------------------------------------------------------------------
diff --git a/.babelrc b/.babelrc
index 539cd51..a4555d2 100644
--- a/.babelrc
+++ b/.babelrc
@@ -3,5 +3,5 @@
     "react",
     "es2015"
   ],
-  "plugins": ["transform-object-assign"]
+  "plugins": ["transform-object-assign", "transform-object-rest-spread"]
 }

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1b85d7b3/.eslintrc
----------------------------------------------------------------------
diff --git a/.eslintrc b/.eslintrc
index 0ff1456..f71d8da 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -35,7 +35,8 @@
   "parserOptions": {
     "sourceType": "module",
     "ecmaFeatures": {
-      "jsx": true
+      "jsx": true,
+      "experimentalObjectRestSpread": true
     }
   },
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1b85d7b3/app/addons/permissions/__tests__/container-test.js
----------------------------------------------------------------------
diff --git a/app/addons/permissions/__tests__/container-test.js b/app/addons/permissions/__tests__/container-test.js
index c96b08a..1f9a0fd 100644
--- a/app/addons/permissions/__tests__/container-test.js
+++ b/app/addons/permissions/__tests__/container-test.js
@@ -15,7 +15,7 @@ import { receivedPermissions } from '../actions';
 import React from 'react';
 import { mount } from 'enzyme';
 
-import { createStore, applyMiddleware } from 'redux';
+import { createStore, applyMiddleware, combineReducers } from 'redux';
 
 import thunk from 'redux-thunk';
 import { Provider } from 'react-redux';
@@ -33,7 +33,7 @@ describe('Permissions Container', () => {
 
     const middlewares = [thunk];
     const store = createStore(
-      reducer,
+      combineReducers({ permissions: reducer}),
       applyMiddleware(...middlewares)
     );
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1b85d7b3/app/addons/permissions/base.js
----------------------------------------------------------------------
diff --git a/app/addons/permissions/base.js b/app/addons/permissions/base.js
index 0efe12b..c02fbba 100644
--- a/app/addons/permissions/base.js
+++ b/app/addons/permissions/base.js
@@ -12,11 +12,13 @@
 
 import FauxtonAPI from "../../core/api";
 import Permissions from "./routes";
-import reducer from './reducers';
+import reducers from './reducers';
 import "./assets/less/permissions.less";
 
 Permissions.initialize = function () {};
 
-FauxtonAPI.reducers.push(reducer);
+FauxtonAPI.addReducers({
+  permissions: reducers
+});
 
 export default Permissions;

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1b85d7b3/app/addons/permissions/container/PermissionsContainer.js
----------------------------------------------------------------------
diff --git a/app/addons/permissions/container/PermissionsContainer.js b/app/addons/permissions/container/PermissionsContainer.js
index 0360ee7..f5cbcaf 100644
--- a/app/addons/permissions/container/PermissionsContainer.js
+++ b/app/addons/permissions/container/PermissionsContainer.js
@@ -24,14 +24,14 @@ import {
 } from '../reducers';
 
 
-const mapStateToProps = (state) => {
+const mapStateToProps = ({permissions}) => {
   return {
-    isLoading: getIsLoading(state),
-    adminRoles: getAdminRoles(state),
-    adminNames: getAdminNames(state),
-    memberNames: getMemberNames(state),
-    memberRoles: getMemberRoles(state),
-    security: getSecurity(state)
+    isLoading: getIsLoading(permissions),
+    adminRoles: getAdminRoles(permissions),
+    adminNames: getAdminNames(permissions),
+    memberNames: getMemberNames(permissions),
+    memberRoles: getMemberRoles(permissions),
+    security: getSecurity(permissions)
   };
 };
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1b85d7b3/app/core/base.js
----------------------------------------------------------------------
diff --git a/app/core/base.js b/app/core/base.js
index 00e4f19..0f8cfeb 100644
--- a/app/core/base.js
+++ b/app/core/base.js
@@ -12,6 +12,7 @@
 
 import Backbone from "backbone";
 import _ from "lodash";
+
 var FauxtonAPI = {
   //add default objects
   router: {
@@ -157,6 +158,14 @@ FauxtonAPI.setSession = function (newSession) {
   return FauxtonAPI.session.fetchUser();
 };
 
-FauxtonAPI.reducers = [];
+FauxtonAPI.reducers = {};
+
+
+FauxtonAPI.addReducers = (reducers) => {
+  FauxtonAPI.reducers = {
+    ...FauxtonAPI.reducers,
+    ...reducers
+  };
+};
 
 export default FauxtonAPI;

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1b85d7b3/app/main.js
----------------------------------------------------------------------
diff --git a/app/main.js b/app/main.js
index 5cf474a..d14e974 100644
--- a/app/main.js
+++ b/app/main.js
@@ -19,7 +19,7 @@ import Backbone from 'backbone';
 import $ from 'jquery';
 import AppWrapper from './addons/fauxton/appwrapper';
 
-import { createStore, applyMiddleware } from 'redux';
+import { createStore, applyMiddleware, combineReducers } from 'redux';
 import thunk from 'redux-thunk';
 import { Provider } from 'react-redux';
 
@@ -57,24 +57,10 @@ $(document).on("click", "a:not([data-bypass])", function (evt) {
   }
 });
 
-function getReducers (r) {
-
-  if (!r.length) {
-    return function () {};
-  }
-
-  return FauxtonAPI.reducers.reduce((el, acc) => {
-    acc[el] = el;
-    return acc;
-  }, {});
-}
-
-const reducer = getReducers(FauxtonAPI.reducers);
-
 const middlewares = [thunk];
 
 const store = createStore(
-  reducer,
+  combineReducers(FauxtonAPI.reducers),
   applyMiddleware(...middlewares)
 );
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1b85d7b3/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 95f568b..781e34d 100644
--- a/package.json
+++ b/package.json
@@ -17,6 +17,7 @@
   },
   "devDependencies": {
     "babel-jest": "^18.0.0",
+    "babel-plugin-transform-object-rest-spread": "^6.23.0",
     "bootstrap": "^3.3.7",
     "enzyme": "^2.7.1",
     "es5-shim": "4.5.4",


Mime
View raw message