You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by garrensmith <gi...@git.apache.org> on 2015/03/03 14:25:27 UTC
[GitHub] couchdb-fauxton pull request: React docs pagination
GitHub user garrensmith opened a pull request:
https://github.com/apache/couchdb-fauxton/pull/301
React docs pagination
This is the pagination converted to Flux and React
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/garrensmith/couchdb-fauxton react-docs-pagination
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/couchdb-fauxton/pull/301.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #301
----
commit f380d9b8ab9d73af4d3be04400742848296bf177
Author: Garren Smith <ga...@gmail.com>
Date: 2015-02-18T14:47:06Z
file layout
commit b0dd2d798985ab2b3428ffb98b513aade7b65eca
Author: Garren Smith <ga...@gmail.com>
Date: 2015-02-24T10:45:35Z
Progress
commit 68e0d74f277f3d131bd6c655170a3ca1c6111d33
Author: Garren Smith <ga...@gmail.com>
Date: 2015-02-25T16:00:50Z
Pagination working for _all_docs
commit b2466097d9d36b3536e281b5482da84acc978dff
Author: Garren Smith <ga...@gmail.com>
Date: 2015-03-02T14:51:01Z
Working in views
commit 5bb66019540db8c6914454081f122c7b56e43b89
Author: Garren Smith <ga...@gmail.com>
Date: 2015-03-03T10:16:44Z
upgrade to selenium 2.45
commit 82e27b20589c5f6d5abde1c488e75f1b071a51f8
Author: Garren Smith <ga...@gmail.com>
Date: 2015-03-03T13:19:46Z
night watch tests
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: React docs pagination
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/301#discussion_r25773892
--- Diff: app/addons/documents/shared-routes.js ---
@@ -162,15 +126,9 @@ define([
urlParams = params.urlParams,
docParams = params.docParams,
ddoc = event.ddoc,
- defaultPageSize,
- isLazyInit,
- pageSize,
+ pageSize = PaginationStores.indexPaginationStore.getPerPage(),
collection;
- isLazyInit = _.isUndefined(this.documentsView) || _.isUndefined(this.documentsView.allDocsNumber);
- defaultPageSize = isLazyInit ? FauxtonAPI.constants.MISC.DEFAULT_PAGE_SIZE : this.documentsView.perPage();
- docParams.limit = pageSize = this.getDocPerPageLimit(urlParams, defaultPageSize);
-
--- End diff --
:heart_eyes:
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: React docs pagination
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/301#issuecomment-77165160
+1 great!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: React docs pagination
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/301#discussion_r25773326
--- Diff: app/addons/documents/pagination/pagination.react.jsx ---
@@ -0,0 +1,198 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+ "api",
+ "react",
+ 'addons/documents/pagination/stores',
+ 'addons/documents/pagination/actions',
+ ], function (FauxtonAPI, React, Stores, Actions) {
+ var indexPaginationStore = Stores.indexPaginationStore;
+
+ var IndexPaginationController = React.createClass({
+
+ getStoreState: function () {
+ return {
+ canShowPrevious: indexPaginationStore.canShowPrevious(),
+ canShowNext: indexPaginationStore.canShowNext(),
+ };
+ },
+
+ getInitialState: function () {
+ return this.getStoreState();
+ },
+
+ componentDidMount: function() {
+ indexPaginationStore.on('change', this.onChange, this);
+ },
+
+ componentWillUnmount: function() {
+ indexPaginationStore.off('change', this.onChange);
+ },
+
+ onChange: function () {
+ this.setState(this.getStoreState());
+ },
+
+ nextClicked: function (event) {
+ event.preventDefault();
+ event.stopPropagation();
+ if (!this.state.canShowNext) { return; }
+ Actions.paginateNext();
+ },
+
+ previousClicked: function (event) {
+ event.preventDefault();
+ event.stopPropagation();
+ if (!this.state.canShowPrevious) { return; }
+ Actions.paginatePrevious();
+ },
+
+ render: function () {
+ var canShowPreviousClassName;
+ var canShowNextClassName;
--- End diff --
would default them to an empty string, see https://issues.apache.org/jira/browse/COUCHDB-2577
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: React docs pagination
Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith closed the pull request at:
https://github.com/apache/couchdb-fauxton/pull/301
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: React docs pagination
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/301#issuecomment-77159942
fixes: https://issues.apache.org/jira/browse/COUCHDB-2572 :)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: React docs pagination
Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/301#issuecomment-77327659
Merged.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: React docs pagination
Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/301#issuecomment-76960458
This fixes COUCHDB-2193
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: React docs pagination
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/301#discussion_r25773721
--- Diff: app/addons/documents/pagination/tests/paginationStoreSpec.js ---
@@ -0,0 +1,237 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+ 'api',
+ 'addons/documents/pagination/stores',
+ 'addons/documents/pagination/actiontypes',
+ 'testUtils'
+], function (FauxtonAPI, Stores, ActionTypes, testUtils) {
+ var assert = testUtils.assert;
+ var dispatchToken;
+ var store;
+
+ describe('Index Pagination Store', function () {
+
+ beforeEach(function () {
+ store = new Stores.IndexPaginationStore();
+ dispatchToken = FauxtonAPI.dispatcher.register(store.dispatch);
+ });
+
+ afterEach(function () {
+ FauxtonAPI.dispatcher.unregister(dispatchToken);
+ });
+
+ describe('#collectionChanged', function () {
+ var collection;
+ beforeEach(function () {
+ collection = new Backbone.Collection([{id:1}, {id: 2}]);
+ collection.updateSeq = function () { return 'updateSeq';};
+ store.reset();
+ });
+
+ it('sets total rows correctly', function () {
+ store.newPagination(collection);
+ assert.equal(store.getTotalRows(), 2);
+ });
+
+ it('sets updateSeq', function () {
+ store.newPagination(collection);
+ assert.equal(store.getUpdateSeq(), 'updateSeq');
+ });
+
+ });
+
+ describe('canShowPrevious', function () {
+ it('cannot show previous if disabled', function () {
+ store._enabled = false;
+ assert.notOk(store.canShowPrevious());
+ });
+
+ it('can show if collection can show', function () {
+ store._enabled = true;
+ store._collection = new Backbone.Collection();
+ store._collection.hasPrevious = function () { return true;};
+ assert.ok(store.canShowPrevious());
+ });
+
+ });
+
+ describe('canShowNext', function () {
+ it('cannot show next if disabled', function () {
+ store._enabled = false;
+ assert.notOk(store.canShowNext());
+ });
+
+ it('cannot show if pageStart and perPage greater than docLimit', function () {
+ store._enabled = true;
+ store._docLimit = 10;
+ store._perPage = 20;
+
+ assert.notOk(store.canShowNext());
+ });
+
+ it('can show if collection can show', function () {
+ store._enabled = true;
+ store._docLimit = 100000;
+ store.reset();
+ store._collection = new Backbone.Collection();
+ store._collection.hasNext = function () { return true;};
+ assert.ok(store.canShowNext());
+ });
+ });
+
+ describe('paginateNext', function () {
+ beforeEach(function () {
+ store.setPerPage(20);
+ });
+
+ it('should increment page number', function () {
+
+ store.reset();
+ store.paginateNext();
+
+ assert.equal(store.getCurrentPage(), 2);
+ });
+
+ it('should increment page start', function () {
+
+ store.reset();
+ store.paginateNext();
+
+ assert.equal(store.getPageStart(), 21);
+ });
+
+ it('should set correct page end', function () {
+ store._collection = new Backbone.Collection();
+ store._collection.length = 20;
+ store.reset();
+ store.paginateNext();
+
+ assert.equal(store.getPageEnd(), 40);
+ });
+ });
+
+ describe('paginatePrevious', function () {
+
+ it('should decrement page number', function () {
+ store.reset();
+ store.paginateNext();
+ store.paginatePrevious();
+
+ assert.equal(store.getCurrentPage(), 1);
+ });
+
+ it('should decrement page start', function () {
+ store.reset();
+ store.paginateNext();
+ store.paginatePrevious();
+
+ assert.equal(store.getPageStart(), 1);
+ });
+
+ it('should decrement page end', function () {
+ store.reset();
+ store._collection = new Backbone.Collection();
+ store._collection.length = 20;
+ store.paginateNext();
+ store.paginatePrevious();
+
+ assert.equal(store.getPageEnd(), 20);
+ });
+
+ });
+
+ describe('totalDocsViewed', function () {
+ beforeEach(function () {
+ store.setPerPage(20);
--- End diff --
you can add `store.reset();` here and remove it from the testcases
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: React docs pagination
Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/301#issuecomment-77015601
Nice.
The ">" icon sometimes doesn't get highlighted when it should. I've noticed this on Chrome + Safari. Reproducing it consistently has been tough, but I find these steps often work:
- starting on the databases page, select a DB with lots of records (>1 page)
- on the db page [sometimes I've found it's not enabled here, right off the bat] click on the edit icon for the first record
- on the full page editor page, click the "cancel" link
- back on the documents page I find that here often isn't enabled. Note: on Safari I find it works more often, but when you click ">" it takes you to a blank page.
Doing a refresh on the pages where it isn't enabled doesn't always fix it.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: React docs pagination
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/301#discussion_r25774317
--- Diff: app/addons/documents/views.js ---
@@ -512,22 +492,6 @@ function (app, FauxtonAPI, Components, Documents,
}, this);
},
- setCollection: function (collection) {
- this.collection = collection;
- this.pagination.setCollection(collection);
- this.allDocsNumber.setCollection(collection);
- },
-
- setParams: function (docParams, urlParams) {
- this.docParams = docParams;
- this.params = urlParams;
- this.perPageDefault = this.docParams.limit;
-
- if (this.params.limit) {
- this.pagination.docLimit = this.params.limit;
- }
- },
-
--- End diff --
:heart_eyes:
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: React docs pagination
Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/301#issuecomment-77155565
@benkeen thanks for reviewing. After a bit of digging around I found that actually isn't a bug. If you set the per page to 20 docs per page. Then edit a doc and then click cancel. It returns you to the _all_docs page but sets the limit = 20 docs. So that means that you cannot paginate any further.
The issue here, which I cannot fix on this branch, is that the cancel url shouldn't have the limit of 20. It should be the same as pressing '<'.
But I did manage to find another bug while testing this so thanks. I've pushed a small fix.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: React docs pagination
Posted by michellephung <gi...@git.apache.org>.
Github user michellephung commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/301#issuecomment-76994015
holy macaroni, 989 additions and 835 deletions!
+1
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---