You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by mi...@apache.org on 2015/09/18 01:44:18 UTC

fauxton commit: updated refs/heads/master to c321c5d

Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master a8d8886e8 -> c321c5d05


Fix for modal, to show actual newlines, instead of '\n'


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

Branch: refs/heads/master
Commit: c321c5d0543439a6a72ba85069e5e5c10d41f9f8
Parents: a8d8886
Author: Michelle Phung <mi...@apache.org>
Authored: Wed Sep 16 18:14:07 2015 -0400
Committer: Michelle Phung <mi...@apache.org>
Committed: Thu Sep 17 19:42:24 2015 -0400

----------------------------------------------------------------------
 app/addons/components/react-components.react.jsx    |  2 ++
 .../components/tests/stringEditModalSpec.react.jsx  | 16 ++++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/c321c5d0/app/addons/components/react-components.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/components/react-components.react.jsx b/app/addons/components/react-components.react.jsx
index 3dc4b25..6107dde 100644
--- a/app/addons/components/react-components.react.jsx
+++ b/app/addons/components/react-components.react.jsx
@@ -592,6 +592,8 @@ function (app, FauxtonAPI, React, Components, ace, beautifyHelper) {
     },
 
     setValue: function (val) {
+      // we do the JSON.parse so the string editor modal shows newlines
+      val = JSON.parse('"' + val + '"');      //returns an object, expects a JSON string
       this.editor.setValue(val, -1);
     },
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/c321c5d0/app/addons/components/tests/stringEditModalSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/components/tests/stringEditModalSpec.react.jsx b/app/addons/components/tests/stringEditModalSpec.react.jsx
index a0b7539..d67e356 100644
--- a/app/addons/components/tests/stringEditModalSpec.react.jsx
+++ b/app/addons/components/tests/stringEditModalSpec.react.jsx
@@ -68,8 +68,20 @@ define([
         assert.ok(spy.calledOnce);
         assert.ok(spy.calledWith(string));
       });
-    });
 
-  });
+      it('replaces "\\n" with actual newlines', function () {
+        var spy = sinon.spy();
+        modalEl = TestUtils.renderIntoDocument(
+          <ReactComponents.StringEditModal visible={true} onSave={spy} />,
+          container
+        );
+
+        var string = 'I am a string\\nwith\\nlinebreaks\\nin\\nit';
 
+        modalEl.setValue(string);
+        TestUtils.Simulate.click($(modalEl.getDOMNode()).find('#string-edit-save-btn')[0]);
+        assert.ok(spy.calledOnce);
+      });
+    });
+  });
 });