Replace "new" view identifier by "create"
authorFrank Bessou <frank.bessou@logilab.fr>
Thu, 11 May 2017 18:05:05 +0200
changeset 198 5b1b7472669e
parent 197 926f820c4216
child 199 ed0d8132c38b
Replace "new" view identifier by "create" To align with resource's allowedActions.
src/components/BaseViews.js
src/components/Resource.js
src/index.js
test/index.js
--- a/src/components/BaseViews.js	Thu May 11 13:48:33 2017 +0200
+++ b/src/components/BaseViews.js	Thu May 11 18:05:05 2017 +0200
@@ -65,7 +65,7 @@
             url += '@@edit';
             break;
         case 'create':
-            url += '@@new';
+            url += '@@create';
             break;
         default:
             return null;
--- a/src/components/Resource.js	Thu May 11 13:48:33 2017 +0200
+++ b/src/components/Resource.js	Thu May 11 18:05:05 2017 +0200
@@ -271,7 +271,7 @@
 export function Resource(props) {
     function selectView() {
         switch (props.match.params.action) {
-            case 'new':
+            case 'create':
                 return ResourceCreationForm;
             case 'delete':
                 return ResourceDeletionView;
--- a/src/index.js	Thu May 11 13:48:33 2017 +0200
+++ b/src/index.js	Thu May 11 18:05:05 2017 +0200
@@ -18,7 +18,7 @@
                 <Route exact path='/' component={Root} />
                 <Route path="/:etype/:eid/relationships/:rtype" component={AddRelated} />
 
-                <Route exact path=":apiUrl(.*)@@:action(view|new|delete|edit)" component={Resource} />
+                <Route exact path=":apiUrl(.*)@@:action(view|create|delete|edit)" component={Resource} />
                 <Route exact path=":apiUrl(.*)" component={Resource} />
 
                 <Route path="*" component={NotFound} />
--- a/test/index.js	Thu May 11 13:48:33 2017 +0200
+++ b/test/index.js	Thu May 11 18:05:05 2017 +0200
@@ -219,7 +219,7 @@
         const wrapper = shallow(<ActionLink targetUrl={targetUrl} action='create'/>);
 
         expect(wrapper.is('Link')).to.be.equal(true);
-        expect(wrapper.prop('to')).to.be.equal('/any/123@@new');
+        expect(wrapper.prop('to')).to.be.equal('/any/123@@create');
         expect(wrapper.prop('title')).to.be.equal('create');
     });
 
@@ -770,10 +770,10 @@
 });
 
 describe('Resource', () => {
-    it('should select "ResourceCreationForm" when action is "new"', () => {
+    it('should select "ResourceCreationForm" when action is "create"', () => {
         const params = {
             apiUrl: '/book/',
-            action: 'new',
+            action: 'create',
         };
         const wrapper = shallow(<Resource match={{params: params}}/>);
         const component = wrapper.props().component;