You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/07/24 02:32:44 UTC

[GitHub] Antonio-Maranhao closed pull request #1109: Fix setup misc bugs

Antonio-Maranhao closed pull request #1109: Fix setup misc bugs
URL: https://github.com/apache/couchdb-fauxton/pull/1109
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/app/addons/setup/actions.js b/app/addons/setup/actions.js
index 95dd3525e..6a05b5dd4 100644
--- a/app/addons/setup/actions.js
+++ b/app/addons/setup/actions.js
@@ -197,9 +197,8 @@ export const addNode = (isOrWasAdminParty, credentials, setupNode, additionalNod
     }
     const addNodeResponse = await post(baseUrl, addNodeData, {raw: true});
 
-
     if (!addNodeResponse.ok) {
-      const json = await enableRemoteNodeResponse.json();
+      const json = await addNodeResponse.json();
       const error = json.reason ? json.reason : json.error;
       return showError(error);
     }
diff --git a/app/addons/setup/reducers.js b/app/addons/setup/reducers.js
index 203949d43..67dd031dd 100644
--- a/app/addons/setup/reducers.js
+++ b/app/addons/setup/reducers.js
@@ -56,9 +56,9 @@ export default function setup(state = initialState, action) {
     case SETUP_BIND_ADDRESS_FOR_SINGLE_NODE:
       return updateState(state, 'setupNode.bindAddress', options.value);
     case SETUP_PORT_FOR_SINGLE_NODE:
-      return updateState(state, 'setupNode.port', options.value);
+      return updateStateIfNotNaN(state, 'setupNode.port', parseInt(options.value));
     case SETUP_PORT_ADDITIONAL_NODE:
-      return updateState(state, 'additionalNode.port', parseInt(options.value));
+      return updateStateIfNotNaN(state, 'additionalNode.port', parseInt(options.value));
     case SETUP_BIND_ADDRESS_ADDITIONAL_NODE:
       return updateState(state, 'additionalNode.bindAddress', options.value);
     case SETUP_REMOTE_ADDRESS_ADDITIONAL_NODE:
@@ -71,8 +71,7 @@ export default function setup(state = initialState, action) {
     case SETUP_RESET_ADDITIONAL_NODE:
       return resetAdditionalNode(getStateCopy(state));
     case SETUP_NODE_COUNT:
-      const nodeCount = Math.min(options.value, 3);
-      return updateState(state, 'setupNode.nodeCount', nodeCount);
+      return updateStateIfNotNaN(state, 'setupNode.nodeCount', parseInt(options.value));
     default:
       return state;
   }
@@ -95,6 +94,14 @@ export const getStateCopy = (state) => {
   };
 };
 
+export const updateStateIfNotNaN = (state, path, value) => {
+  let stateCopy = getStateCopy(state);
+  if (_.isNaN(value)) {
+    return stateCopy;
+  }
+  return _.set(stateCopy, path, value);
+};
+
 /**
  * Update a particular value for a state
  * @param state The state to update


 

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


With regards,
Apache Git Services