Use withPagination on ResourceView
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Wed, 07 Jun 2017 14:15:10 +0200
changeset 226 1e18e08035d3
parent 225 79e8794592ec
child 227 d191f86135c0
Use withPagination on ResourceView So pagination links are now displayed.
src/components/Resource.js
test/index.js
--- a/src/components/Resource.js	Wed Jun 07 14:07:02 2017 +0200
+++ b/src/components/Resource.js	Wed Jun 07 14:15:10 2017 +0200
@@ -8,7 +8,7 @@
 import {EntityAttributes, EntityForm, EntityMeta, RelatedResources} from './Entity';
 import {PropTypesResourceModel} from '../model';
 import {PropTypeJsonaryWrapper, mapToSchema} from '../jsonaryutils';
-import {ActionsDropDown, CollectionView} from './BaseViews';
+import {ActionsDropDown, CollectionView, withPagination} from './BaseViews';
 
 export class ResourceContainer extends React.Component {
     constructor(props) {
@@ -298,6 +298,8 @@
     router: PropTypes.object.isRequired,
 };
 
+export const PaginatedResourceView = withPagination(ResourceView);
+
 export function Resource(props) {
     function selectView() {
         switch (props.match.params.action) {
@@ -309,7 +311,7 @@
                 return ResourceEditionForm;
             case 'view':
             default:
-                return ResourceView;
+                return PaginatedResourceView;
         }
     }
     return <ResourceContainer url={props.match.params.apiUrl} component={selectView()} />;
--- a/test/index.js	Wed Jun 07 14:07:02 2017 +0200
+++ b/test/index.js	Wed Jun 07 14:15:10 2017 +0200
@@ -22,6 +22,7 @@
     ResourceCreationForm,
     ResourceEditionForm,
     ResourceView,
+    PaginatedResourceView,
     ResourceCollectionView,
     ResourceEntityView,
     ResourceDeletionView,
@@ -784,7 +785,7 @@
         expect(component).to.be.equal(ResourceDeletionView);
     });
 
-    it('should select "ResourceView" when action is "view"', () => {
+    it('should select "PaginatedResourceView" when action is "view"', () => {
         const params = {
             apiUrl: '/book/123',
             action: 'view',
@@ -792,10 +793,10 @@
         const wrapper = shallow(<Resource match={{params: params}}/>);
         const component = wrapper.props().component;
 
-        expect(component).to.be.equal(ResourceView);
+        expect(component).to.be.equal(PaginatedResourceView);
     });
 
-    it('should select "ResourceView" when action is not present', () => {
+    it('should select "PaginatedResourceView" when action is not present', () => {
         const params = {
             apiUrl: '/book/123',
             action: undefined,
@@ -803,7 +804,7 @@
         const wrapper = shallow(<Resource match={{params: params}}/>);
         const component = wrapper.props().component;
 
-        expect(component).to.be.equal(ResourceView);
+        expect(component).to.be.equal(PaginatedResourceView);
     });
 
 });