Repository: couchdb-fauxton Updated Branches: refs/heads/master 985b67deb -> fbd7df2ba
DatabasePagination allows custom URLs This was reverted earlier but didn't cause errors. Recommitting. Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/fbd7df2b Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/fbd7df2b Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/fbd7df2b Branch: refs/heads/master Commit: fbd7df2ba158d75544af51e9cd595ecbaa6216ed Parents: 985b67d Author: Ben Keen <[email protected]> Authored: Wed May 13 08:34:31 2015 -0700 Committer: Ben Keen <[email protected]> Committed: Wed May 13 09:21:28 2015 -0700 ---------------------------------------------------------------------- app/addons/databases/components.react.jsx | 10 +++++++++- app/addons/databases/tests/componentsSpec.react.jsx | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/fbd7df2b/app/addons/databases/components.react.jsx ---------------------------------------------------------------------- diff --git a/app/addons/databases/components.react.jsx b/app/addons/databases/components.react.jsx index 0bf290c..27203f9 100644 --- a/app/addons/databases/components.react.jsx +++ b/app/addons/databases/components.react.jsx @@ -270,6 +270,12 @@ define([ var DatabasePagination = React.createClass({ + getDefaultProps: function () { + return { + linkPath: '_all_dbs' + }; + }, + getStoreState: function () { return { databaseNames: databasesStore.getDatabaseNames(), @@ -296,10 +302,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/fbd7df2b/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..2925180 100644 --- a/app/addons/databases/tests/componentsSpec.react.jsx +++ b/app/addons/databases/tests/componentsSpec.react.jsx @@ -186,5 +186,18 @@ 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'); + }); + }); + }); + });
