couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [4/4] fauxton commit: updated refs/heads/master to b19065e
Date Thu, 14 Apr 2016 16:06:08 GMT
get ready for react 15

PR: #700
PR-URL: https://github.com/apache/couchdb-fauxton/pull/700
Reviewed-By: garren smith <garren.smith@gmail.com>


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

Branch: refs/heads/master
Commit: 8217fb80cdc56a1c01b477bcc318bd9c9f75f4e9
Parents: f21e761
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Tue Apr 12 14:22:42 2016 +0200
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Thu Apr 14 18:05:51 2016 +0200

----------------------------------------------------------------------
 .../components/react-components.react.jsx       | 13 ++++++++--
 .../components/tests/badgesSpec.react.jsx       |  9 +++----
 .../tests/codeEditorPanelSpec.react.jsx         |  2 +-
 .../tests/deleteDatabaseModalSpec.react.jsx     |  5 ++--
 app/addons/components/tests/docSpec.react.jsx   |  6 ++---
 .../databases/tests/componentsSpec.react.jsx    | 25 ++++++++++++--------
 .../tests/pagination.componentSpec.react.jsx    |  4 ++--
 .../fauxton/tests/componentsSpec.react.jsx      | 24 +++++++++----------
 8 files changed, 52 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/8217fb80/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 1dadcd4..0ad9b85 100644
--- a/app/addons/components/react-components.react.jsx
+++ b/app/addons/components/react-components.react.jsx
@@ -1041,7 +1041,8 @@ define([
         <div className="checkbox inline">
           <input
             id={'checkbox-' + this.props.docIdentifier}
-            checked={this.props.checked ? 'checked="checked"' : null}
+            checked={this.props.checked}
+            data-checked={this.props.checked}
             type="checkbox"
             onChange={this.onChange}
             className="js-row-select" />
@@ -1287,7 +1288,15 @@ define([
 
     renderChildren: function () {
       return React.Children.map(this.props.children, function (child, key) {
-        return React.cloneElement(child, this.props);
+
+        const props = {};
+        Object.keys(this.props).filter((k) => {
+          return this.props.hasOwnProperty(k);
+        }).map((k) => {
+          return props[k] = this.props[k];
+        });
+
+        return React.cloneElement(child, props);
       }.bind(this));
     },
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/8217fb80/app/addons/components/tests/badgesSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/components/tests/badgesSpec.react.jsx b/app/addons/components/tests/badgesSpec.react.jsx
index bd6c0e5..5504cc1 100644
--- a/app/addons/components/tests/badgesSpec.react.jsx
+++ b/app/addons/components/tests/badgesSpec.react.jsx
@@ -14,8 +14,9 @@ define([
   '../react-components.react',
   '../../../../test/mocha/testUtils',
   'react',
+  'react-dom',
   'react-addons-test-utils',
-], function (FauxtonAPI, ReactComponents, utils, React, TestUtils) {
+], function (FauxtonAPI, ReactComponents, utils, React, ReactDOM, TestUtils) {
 
   var assert = utils.assert;
 
@@ -26,7 +27,7 @@ define([
     });
 
     afterEach(function () {
-      React.unmountComponentAtNode(React.findDOMNode(instance).parentNode);
+      ReactDOM.unmountComponentAtNode(ReactDOM.findDOMNode(instance).parentNode);
     });
 
     it('renders a list of badges', function () {
@@ -35,7 +36,7 @@ define([
         container
       );
 
-      var $el = $(instance.getDOMNode());
+      var $el = $(ReactDOM.findDOMNode(instance));
 
       assert.equal($el.find('.component-badge').length, 2);
     });
@@ -46,7 +47,7 @@ define([
         container
       );
 
-      var $el = $(instance.getDOMNode());
+      var $el = $(ReactDOM.findDOMNode(instance));
 
       assert.equal($el.find('.component-badge').text(), 'foofoo×barfoo×');
     });

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/8217fb80/app/addons/components/tests/codeEditorPanelSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/components/tests/codeEditorPanelSpec.react.jsx b/app/addons/components/tests/codeEditorPanelSpec.react.jsx
index 5ec0160..7d76162 100644
--- a/app/addons/components/tests/codeEditorPanelSpec.react.jsx
+++ b/app/addons/components/tests/codeEditorPanelSpec.react.jsx
@@ -77,7 +77,7 @@ define([
         // confirm there are no newlines in the code at this point
         assert.equal(codeEditorEl.getValue().match(/\n/g), null);
 
-        TestUtils.Simulate.click($(React.findDOMNode(codeEditorEl)).find('.beautify')[0]);
+        TestUtils.Simulate.click($(ReactDOM.findDOMNode(codeEditorEl)).find('.beautify')[0]);
 
         // now confirm newlines are found
         assert.equal(codeEditorEl.getValue().match(/\n/g).length, 2);

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/8217fb80/app/addons/components/tests/deleteDatabaseModalSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/components/tests/deleteDatabaseModalSpec.react.jsx b/app/addons/components/tests/deleteDatabaseModalSpec.react.jsx
index 08bf806..609bb43 100644
--- a/app/addons/components/tests/deleteDatabaseModalSpec.react.jsx
+++ b/app/addons/components/tests/deleteDatabaseModalSpec.react.jsx
@@ -15,8 +15,9 @@ define([
   '../../../../test/mocha/testUtils',
   'react-bootstrap',
   'react',
+  'react-dom',
   'react-addons-test-utils',
-], function (FauxtonAPI, ReactComponents, utils, ReactBootstrap, React, TestUtils) {
+], function (FauxtonAPI, ReactComponents, utils, ReactBootstrap, React, ReactDOM, TestUtils)
{
 
   var assert = utils.assert;
   var Modal = ReactBootstrap.Modal;
@@ -30,7 +31,7 @@ define([
     });
 
     afterEach(function () {
-      React.unmountComponentAtNode(container);
+      ReactDOM.unmountComponentAtNode(container);
     });
 
     it('submitting is disabled when initially rendered', function () {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/8217fb80/app/addons/components/tests/docSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/components/tests/docSpec.react.jsx b/app/addons/components/tests/docSpec.react.jsx
index 633972a..1eb52bd 100644
--- a/app/addons/components/tests/docSpec.react.jsx
+++ b/app/addons/components/tests/docSpec.react.jsx
@@ -35,7 +35,7 @@ define([
     });
 
     afterEach(function () {
-      ReactDOM.unmountComponentAtNode(container);
+      ReactDOM.unmountComponentAtNode(ReactDOM.findDOMNode(el).parentNode);
     });
 
     it('hosts child elements', function () {
@@ -61,7 +61,7 @@ define([
         <ReactComponents.Document isDeletable={true} checked={true} docIdentifier="foo"
/>,
         container
       );
-      assert.equal($(ReactDOM.findDOMNode(el)).find('input[type="checkbox"]').attr('checked'),
'checked');
+      assert.equal($(ReactDOM.findDOMNode(el)).find('[data-checked="true"]').length, 1);
     });
 
     it('you can uncheck it', function () {
@@ -69,7 +69,7 @@ define([
         <ReactComponents.Document isDeletable={true} docIdentifier="foo" />,
         container
       );
-      assert.equal($(ReactDOM.findDOMNode(el)).find('input[type="checkbox"]').attr('checked'),
undefined);
+      assert.equal($(ReactDOM.findDOMNode(el)).find('[data-checked="true"]').length, 0);
     });
 
     it('it calls an onchange callback', function () {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/8217fb80/app/addons/databases/tests/componentsSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/databases/tests/componentsSpec.react.jsx b/app/addons/databases/tests/componentsSpec.react.jsx
index f4b9f69..a1a5442 100644
--- a/app/addons/databases/tests/componentsSpec.react.jsx
+++ b/app/addons/databases/tests/componentsSpec.react.jsx
@@ -96,14 +96,17 @@ define([
     });
 
     it('renders base data of DBs', function () {
-      assert.equal(1 + 2, dbEl.getDOMNode().getElementsByTagName('tr').length);
-      assert.equal("db1", dbEl.getDOMNode().getElementsByTagName('tr')[1].getElementsByTagName('td')[0].innerText.trim());
-      assert.equal("2.0 MB", dbEl.getDOMNode().getElementsByTagName('tr')[1].getElementsByTagName('td')[1].innerText.trim());
-      assert.equal("88", dbEl.getDOMNode().getElementsByTagName('tr')[1].getElementsByTagName('td')[2].innerText.trim());
-      assert.equal(0, dbEl.getDOMNode().getElementsByTagName('tr')[1].getElementsByTagName('td')[2].getElementsByTagName("i").length);
-      assert.equal(3, dbEl.getDOMNode().getElementsByTagName('tr')[1].getElementsByTagName('td')[4].getElementsByTagName("a").length);
-      assert.equal("db2", dbEl.getDOMNode().getElementsByTagName('tr')[2].getElementsByTagName('td')[0].innerText.trim());
-      assert.equal(1, dbEl.getDOMNode().getElementsByTagName('tr')[2].getElementsByTagName('td')[2].getElementsByTagName("i").length);
+
+      const el = ReactDOM.findDOMNode(dbEl);
+
+      assert.equal(1 + 2, el.getElementsByTagName('tr').length);
+      assert.equal("db1", el.getElementsByTagName('tr')[1].getElementsByTagName('td')[0].innerText.trim());
+      assert.equal("2.0 MB", el.getElementsByTagName('tr')[1].getElementsByTagName('td')[1].innerText.trim());
+      assert.equal("88", el.getElementsByTagName('tr')[1].getElementsByTagName('td')[2].innerText.trim());
+      assert.equal(0, el.getElementsByTagName('tr')[1].getElementsByTagName('td')[2].getElementsByTagName("i").length);
+      assert.equal(3, el.getElementsByTagName('tr')[1].getElementsByTagName('td')[4].getElementsByTagName("a").length);
+      assert.equal("db2", el.getElementsByTagName('tr')[2].getElementsByTagName('td')[0].innerText.trim());
+      assert.equal(1, el.getElementsByTagName('tr')[2].getElementsByTagName('td')[2].getElementsByTagName("i").length);
     });
 
   });
@@ -131,7 +134,8 @@ define([
     it("Creates a database with given name", function () {
       createCalled = false;
       passedDbName = null;
-      TestUtils.findRenderedDOMComponentWithTag(addEl, 'input').getDOMNode().value = "testdb";
+      const el = TestUtils.findRenderedDOMComponentWithTag(addEl, 'input');
+      ReactDOM.findDOMNode(el).value = "testdb";
       addEl.onAddDatabase();
       assert.equal(true, createCalled);
       assert.equal("testdb", passedDbName);
@@ -185,7 +189,8 @@ define([
     it("jumps to an existing DB from input", function () {
       jumpCalled = false;
       passedDbName = null;
-      TestUtils.findRenderedDOMComponentWithTag(jumpEl, 'input').getDOMNode().value = "db2";
+      const input = TestUtils.findRenderedDOMComponentWithTag(jumpEl, 'input');
+      input.value = "db2";
       jumpEl.jumpToDb();
       assert.equal(true, jumpCalled);
       assert.equal("db2", passedDbName);

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/8217fb80/app/addons/documents/pagination/tests/pagination.componentSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/documents/pagination/tests/pagination.componentSpec.react.jsx b/app/addons/documents/pagination/tests/pagination.componentSpec.react.jsx
index 560daa7..4b2358b 100644
--- a/app/addons/documents/pagination/tests/pagination.componentSpec.react.jsx
+++ b/app/addons/documents/pagination/tests/pagination.componentSpec.react.jsx
@@ -65,7 +65,7 @@ define([
           container
         );
         var regexp = new RegExp(customLabel);
-        assert.ok(regexp.test(React.findDOMNode(selectorEl).outerHTML));
+        assert.ok(regexp.test(ReactDOM.findDOMNode(selectorEl).outerHTML));
       });
 
       it('applies custom options', function () {
@@ -76,7 +76,7 @@ define([
             perPage={10} />,
           container
         );
-        var options = $(React.findDOMNode(selectorEl)).find('option');
+        var options = $(ReactDOM.findDOMNode(selectorEl)).find('option');
         assert.equal(options.length, 3);
         assert.equal(options[0].innerHTML, "1");
         assert.equal(options[1].innerHTML, "2");

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/8217fb80/app/addons/fauxton/tests/componentsSpec.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/tests/componentsSpec.react.jsx b/app/addons/fauxton/tests/componentsSpec.react.jsx
index a4c8554..74e0cf7 100644
--- a/app/addons/fauxton/tests/componentsSpec.react.jsx
+++ b/app/addons/fauxton/tests/componentsSpec.react.jsx
@@ -42,23 +42,23 @@ define([
     });
 
     it('renders trayid and custom classes', function () {
-      assert(trayEl.getDOMNode().getAttribute('class').indexOf('traytest') >= 0);
+      assert(ReactDOM.findDOMNode(trayEl).getAttribute('class').indexOf('traytest') >=
0);
     });
 
     it('is initially closed', function () {
-      assert.equal('none', trayEl.getDOMNode().style.display);
+      assert.equal('none', ReactDOM.findDOMNode(trayEl).style.display);
     });
 
     it('shows when requested', function () {
       trayEl.setVisible(true, function () {
-        assert.equal('block', trayEl.getDOMNode().style.display);
+        assert.equal('block', ReactDOM.findDOMNode(trayEl).style.display);
       });
     });
 
     it('hides when requested', function () {
       trayEl.show(function () {
         trayEl.setVisible(false, function () {
-          assert.equal('none', trayEl.getDOMNode().style.display);
+          assert.equal('none', ReactDOM.findDOMNode(trayEl).style.display);
         });
       });
     });
@@ -71,14 +71,14 @@ define([
 
     it('toggles open with callback', function () {
       trayEl.toggle(function () {
-        assert.equal('block', trayEl.getDOMNode().style.display);
+        assert.equal('block', ReactDOM.findDOMNode(trayEl).style.display);
       });
     });
 
     it('toggles close again with callback', function () {
       trayEl.show(function () {
         trayEl.toggle(function () {
-          assert.equal('none', trayEl.getDOMNode().style.display);
+          assert.equal('none', ReactDOM.findDOMNode(trayEl).style.display);
         });
       });
     });
@@ -140,7 +140,7 @@ define([
         container
       );
 
-      var lis = pageEl.getDOMNode().getElementsByTagName("li");
+      var lis = ReactDOM.findDOMNode(pageEl).getElementsByTagName("li");
       assert.equal(1 + 3 + 1, lis.length);
       assert(nvl(lis[0].getAttribute("class")).indexOf("disabled") < 0);
       assert(nvl(lis[1].getAttribute("class")).indexOf("active") < 0);
@@ -157,7 +157,7 @@ define([
         container
       );
 
-      var lis = pageEl.getDOMNode().getElementsByTagName("li");
+      var lis = ReactDOM.findDOMNode(pageEl).getElementsByTagName("li");
       assert.equal(1 + 6 + 1, lis.length);
     });
 
@@ -166,7 +166,7 @@ define([
         <Views.Pagination page={3} total={600} />,
         container
       );
-      var lis = pageEl.getDOMNode().getElementsByTagName("li");
+      var lis = ReactDOM.findDOMNode(pageEl).getElementsByTagName("li");
       assert.equal(1 + 10 + 1, lis.length);
       assert(nvl(lis[3].getAttribute("class")).indexOf("active") >= 0);
       assert.equal("3", lis[3].innerText);
@@ -180,7 +180,7 @@ define([
         container
       );
 
-      var lis = pageEl.getDOMNode().getElementsByTagName("li");
+      var lis = ReactDOM.findDOMNode(pageEl).getElementsByTagName("li");
       assert.equal(1 + 10 + 1, lis.length);
       assert(nvl(lis[6].getAttribute("class")).indexOf("active") >= 0);
       assert.equal("7", lis[3].innerText);
@@ -194,7 +194,7 @@ define([
         container
       );
 
-      var lis = pageEl.getDOMNode().getElementsByTagName("li");
+      var lis = ReactDOM.findDOMNode(pageEl).getElementsByTagName("li");
       assert.equal(1 + 10 + 1, lis.length);
       assert(nvl(lis[9].getAttribute("class")).indexOf("active") >= 0);
       assert.equal("23", lis[3].innerText);
@@ -208,7 +208,7 @@ define([
         <Views.Pagination page={1} total={1000} maxNavPages={maxNavPages} />,
         container
       );
-      var lis = pageEl.getDOMNode().getElementsByTagName("li");
+      var lis = ReactDOM.findDOMNode(pageEl).getElementsByTagName("li");
       assert.equal(1 + maxNavPages + 1, lis.length);
     });
 


Mime
View raw message