couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benk...@apache.org
Subject fauxton commit: updated refs/heads/master to 860a808
Date Mon, 11 May 2015 18:58:38 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 54b118562 -> 860a808b4


DatabasePagination now supports passing custom URL prefix


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

Branch: refs/heads/master
Commit: 860a808b49a1c536ee265a09ec573ace666630a6
Parents: 54b1185
Author: Ben Keen <ben.keen@gmail.com>
Authored: Mon May 11 10:36:11 2015 -0700
Committer: Ben Keen <ben.keen@gmail.com>
Committed: Mon May 11 11:58:22 2015 -0700

----------------------------------------------------------------------
 app/addons/databases/components.react.jsx           |  9 ++++++++-
 app/addons/databases/tests/componentsSpec.react.jsx | 15 +++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/860a808b/app/addons/databases/components.react.jsx
----------------------------------------------------------------------
diff --git a/app/addons/databases/components.react.jsx b/app/addons/databases/components.react.jsx
index 0bf290c..a40c74b 100644
--- a/app/addons/databases/components.react.jsx
+++ b/app/addons/databases/components.react.jsx
@@ -269,6 +269,11 @@ define([
   });
 
   var DatabasePagination = React.createClass({
+    getDefaultProps: function () {
+      return {
+        linkPath: '_all_dbs'
+      };
+    },
 
     getStoreState: function () {
       return {
@@ -296,10 +301,12 @@ define([
     render: function () {
       var page = this.state.page;
       var total = this.props.total || this.state.databaseNames.length;
+      var urlPrefix = '#/' + this.props.linkPath + '?page=';
+
       return (
         <footer className="all-db-footer pagination-footer">
           <div id="database-pagination">
-            <ComponentsReact.Pagination page={page} total={total} urlPrefix="#/_all_dbs?page="
/>
+            <ComponentsReact.Pagination page={page} total={total} urlPrefix={urlPrefix}
/>
           </div>
         </footer>
       );

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/860a808b/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 5a790a4..cebb194 100644
--- a/app/addons/databases/tests/componentsSpec.react.jsx
+++ b/app/addons/databases/tests/componentsSpec.react.jsx
@@ -186,5 +186,20 @@ define([
 
   });
 
+  describe('DatabasePagination', function () {
+    it ('uses custom URL prefix on the navigation if passed through props', function () {
+      var container = document.createElement('div');
+      var pagination = TestUtils.renderIntoDocument(<Views.DatabasePagination linkPath="_custom_path"
/>, container);
+
+      var links = $(pagination.getDOMNode()).find("a");
+      assert.equal(links.length, 3, "pagination contains links");
+
+      links.each(function () {
+        assert.include(this.href, '_custom_path', 'link contains custom path');
+      });
+    });
+
+  });
+
 });
 


Mime
View raw message