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 39a6f33
Date Mon, 16 Feb 2015 10:32:18 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 91375454f -> 39a6f3387


View name resets

When creating a new view if a user changed the reduce editor settings the view name would
reset
back to original
This fixes COUCHDB-2582


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

Branch: refs/heads/master
Commit: 39a6f3387d88a0eccd84ba54f50d4b2d0f599951
Parents: 9137545
Author: Garren Smith <garren.smith@gmail.com>
Authored: Mon Feb 16 12:12:27 2015 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Mon Feb 16 12:12:27 2015 +0200

----------------------------------------------------------------------
 app/addons/documents/index-editor/actions.js     | 14 ++++++++++----
 app/addons/documents/index-editor/actiontypes.js |  4 ++--
 .../documents/index-editor/components.react.jsx  |  4 ++--
 app/addons/documents/index-editor/stores.js      | 13 +++++++++++--
 .../tests/viewIndex.componentsSpec.react.jsx     | 19 +++++++++++++++----
 5 files changed, 40 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/39a6f338/app/addons/documents/index-editor/actions.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/index-editor/actions.js b/app/addons/documents/index-editor/actions.js
index e8d9a41..c731b90 100644
--- a/app/addons/documents/index-editor/actions.js
+++ b/app/addons/documents/index-editor/actions.js
@@ -66,6 +66,13 @@ function (app, FauxtonAPI, Documents, ActionTypes) {
       });
     },
 
+    changeViewName: function (name) {
+      FauxtonAPI.dispatch({
+        type: ActionTypes.VIEW_NAME_CHANGE,
+        name: name
+      });
+    },
+
     editIndex: function (options) {
       FauxtonAPI.dispatch({
         type: ActionTypes.EDIT_INDEX,
@@ -97,7 +104,7 @@ function (app, FauxtonAPI, Documents, ActionTypes) {
       var result = designDoc.setDdocView(viewInfo.viewName,
                             viewInfo.map,
                             viewInfo.reduce);
-      
+
       if (result) {
         FauxtonAPI.dispatch({
          type: ActionTypes.SAVE_VIEW
@@ -121,9 +128,9 @@ function (app, FauxtonAPI, Documents, ActionTypes) {
               type: ActionTypes.VIEW_SAVED
             });
 
-            var fragment = '/database/' + 
+            var fragment = '/database/' +
               viewInfo.database.safeID() +
-              '/' + designDoc.safeID() + 
+              '/' + designDoc.safeID() +
               '/_view/' +
               app.utils.safeURLName(viewInfo.viewName);
 
@@ -166,4 +173,3 @@ function (app, FauxtonAPI, Documents, ActionTypes) {
     }
   };
 });
-

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/39a6f338/app/addons/documents/index-editor/actiontypes.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/index-editor/actiontypes.js b/app/addons/documents/index-editor/actiontypes.js
index 26d1698..b2463da 100644
--- a/app/addons/documents/index-editor/actiontypes.js
+++ b/app/addons/documents/index-editor/actiontypes.js
@@ -20,7 +20,7 @@ define([], function () {
     VIEW_CREATED: 'VIEW_CREATED',
     SAVE_VIEW: 'SAVE_VIEW',
     DESIGN_DOC_CHANGE: 'DESIGN_DOC_CHANGE',
-    NEW_DESIGN_DOC: 'NEW_DESIGN_DOC'
+    NEW_DESIGN_DOC: 'NEW_DESIGN_DOC',
+    VIEW_NAME_CHANGE: 'VIEW_NAME_CHANGE'
   };
 });
-

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/39a6f338/app/addons/documents/index-editor/components.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/documents/index-editor/components.react.jsx b/app/addons/documents/index-editor/components.react.jsx
index acecbeb..c1c81af 100644
--- a/app/addons/documents/index-editor/components.react.jsx
+++ b/app/addons/documents/index-editor/components.react.jsx
@@ -189,7 +189,7 @@ function(app, FauxtonAPI, React, Stores, Actions, Components, beautifyHelper)
{
       return (
         <div className="control-group">
           <label htmlFor="ace-function">
-            {this.props.title} 
+            {this.props.title}
             {docsLink}
           </label>
           <div className="js-editor" id={this.props.id}>{this.props.code}</div>
@@ -426,7 +426,7 @@ function(app, FauxtonAPI, React, Stores, Actions, Components, beautifyHelper)
{
     },
 
     viewChange: function (event) {
-      this.setState({viewName: event.target.value});
+      Actions.changeViewName(event.target.value);
     },
 
     render: function () {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/39a6f338/app/addons/documents/index-editor/stores.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/index-editor/stores.js b/app/addons/documents/index-editor/stores.js
index 7b9222b..cff8ba6 100644
--- a/app/addons/documents/index-editor/stores.js
+++ b/app/addons/documents/index-editor/stores.js
@@ -104,6 +104,10 @@ function(FauxtonAPI, ActionTypes) {
       return this._viewName;
     },
 
+    setViewName: function (name) {
+      this._viewName = name;
+    },
+
     showEditor: function () {
       return this._showEditor;
     },
@@ -161,6 +165,11 @@ function(FauxtonAPI, ActionTypes) {
           this.triggerChange();
         break;
 
+        case ActionTypes.VIEW_NAME_CHANGE:
+          this.setViewName(action.name);
+          this.triggerChange();
+        break;
+
         case ActionTypes.EDIT_NEW_INDEX:
           this.editIndex(action.options);
           this.triggerChange();
@@ -177,12 +186,12 @@ function(FauxtonAPI, ActionTypes) {
         break;
 
         case ActionTypes.DESIGN_DOC_CHANGE:
-          this.setDesignDocId(action.designDocId, action.newDesignDoc); 
+          this.setDesignDocId(action.designDocId, action.newDesignDoc);
           this.triggerChange();
         break;
 
         case ActionTypes.NEW_DESIGN_DOC:
-          this.setDesignDocId('', true); 
+          this.setDesignDocId('', true);
           this.triggerChange();
         break;
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/39a6f338/app/addons/documents/tests/viewIndex.componentsSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/viewIndex.componentsSpec.react.jsx b/app/addons/documents/tests/viewIndex.componentsSpec.react.jsx
index 4f6cb14..74eddca 100644
--- a/app/addons/documents/tests/viewIndex.componentsSpec.react.jsx
+++ b/app/addons/documents/tests/viewIndex.componentsSpec.react.jsx
@@ -54,7 +54,6 @@ define([
         React.unmountComponentAtNode(container);
       });
 
-
       it('should toggle editor on click', function () {
         TestUtils.Simulate.click($(toggleEl.getDOMNode()).find('a')[0]);
         assert.ok(toggleEditor.calledOnce);
@@ -171,7 +170,7 @@ define([
           value: 'new-doc-entered'
         }
       });
-      
+
       assert.ok(spy.calledWith('_design/new-doc-entered', true));
     });
 
@@ -209,6 +208,18 @@ define([
       assert.ok(editorEl.hasValidCode());
     });
 
+    it('calls changeViewName on view name change', function () {
+      var viewName = 'new-name';
+      var spy = sinon.spy(Actions, 'changeViewName');
+      var el = $(editorEl.getDOMNode()).find('#index-name')[0];
+      TestUtils.Simulate.change(el, {
+        target: {
+          value: viewName
+        }
+      });
+      assert.ok(spy.calledWith(viewName));
+    });
+
   });
 
   describe('Beautify', function () {
@@ -223,7 +234,7 @@ define([
     });
 
     it('should be empty for multi-lined code', function () {
-      var correctCode = 'function() {\n    console.log("hello");\n}'; 
+      var correctCode = 'function() {\n    console.log("hello");\n}';
       beautifyEl = TestUtils.renderIntoDocument(<Views.Beautify code={correctCode}/>,
container);
       assert.ok(_.isNull(beautifyEl.getDOMNode()));
     });
@@ -236,7 +247,7 @@ define([
 
     it('on click beautifies code', function () {
       var fixedCode;
-      var correctCode = 'function() {\n    console.log("hello");\n}'; 
+      var correctCode = 'function() {\n    console.log("hello");\n}';
 
       var beautifiedCode = function (code) {
         fixedCode = code;


Mime
View raw message