This is an automated email from the ASF dual-hosted git repository.

amaranhao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git


The following commit(s) were added to refs/heads/main by this push:
     new 6163b5d9 set default local target/source (#1409)
6163b5d9 is described below

commit 6163b5d94c6ab792b07d7a173347c32e3e59a529
Author: Margaret Harrigan <[email protected]>
AuthorDate: Fri Sep 1 20:45:08 2023 -0400

    set default local target/source (#1409)
    
    Co-authored-by: Margaret Harrigan <[email protected]>
---
 app/addons/replication/reducers.js | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/app/addons/replication/reducers.js 
b/app/addons/replication/reducers.js
index 45b3e62b..b89ebcbf 100644
--- a/app/addons/replication/reducers.js
+++ b/app/addons/replication/reducers.js
@@ -142,6 +142,20 @@ const updateFormField = (state, fieldName, value) => {
     }
   }
 
+  // Set default local source/target database to the first in the list (to 
match the default dropdown display)
+  if (fieldName === validFieldMap.replicationSource) {
+    const isLocalDB = updateState[validFieldMap.replicationSource] === 
Constants.REPLICATION_SOURCE.LOCAL;
+    if (isLocalDB && updateState.databases.length > 0) {
+      updateState[validFieldMap.localSource] = updateState.databases[0];
+    }
+  }
+  if (fieldName === validFieldMap.replicationTarget) {
+    const isLocalDB = updateState[validFieldMap.replicationTarget] === 
Constants.REPLICATION_TARGET.EXISTING_LOCAL_DATABASE;
+    if (isLocalDB && updateState.databases.length > 0) {
+      updateState[validFieldMap.localTarget] = updateState.databases[0];
+    }
+  }
+
   return updateState;
 };
 

Reply via email to