File tree Expand file tree Collapse file tree 5 files changed +122
-0
lines changed Expand file tree Collapse file tree 5 files changed +122
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React , { createElement } from 'react' ;
2
+ import { Route } from 'react-router' ;
3
+
4
+ /**
5
+ <CreateRouter basePath="/user" resource="user">
6
+ <Create />
7
+ </CreateRouter>;
8
+ */
9
+
10
+ export const CreateRouter = ( { basePath, resource, children } ) => {
11
+ if ( ! children ) {
12
+ return null ;
13
+ }
14
+
15
+ return (
16
+ < Route
17
+ path = { `${ basePath } /create` }
18
+ render = { props =>
19
+ createElement ( children , {
20
+ basePath,
21
+ ...resource ,
22
+ ...props ,
23
+ } )
24
+ }
25
+ />
26
+ ) ;
27
+ } ;
28
+
29
+ export default CreateRouter ;
Original file line number Diff line number Diff line change
1
+ import React , { createElement } from 'react' ;
2
+ import { Route } from 'react-router' ;
3
+
4
+ /**
5
+ <EditRouter basePath="/user" resource="user">
6
+ <Show />
7
+ </EditRouter>;
8
+ */
9
+
10
+ export const EditRouter = ( { basePath, resource, children } ) => {
11
+ if ( ! children ) {
12
+ return null ;
13
+ }
14
+
15
+ return (
16
+ < Route
17
+ path = { `${ basePath } /:id` }
18
+ render = { props =>
19
+ createElement ( children , {
20
+ basePath,
21
+ id : decodeURIComponent ( props . match . params . id ) ,
22
+ ...resource ,
23
+ ...props ,
24
+ } )
25
+ }
26
+ />
27
+ ) ;
28
+ } ;
29
+
30
+ export default EditRouter ;
Original file line number Diff line number Diff line change
1
+ import React , { createElement } from 'react' ;
2
+ import { Route } from 'react-router' ;
3
+
4
+ /**
5
+ <ListRouter basePath="/user" resource="user">
6
+ <Create />
7
+ </ListRouter>;
8
+ */
9
+
10
+ export const ListRouter = ( { basePath, resource, children } ) => {
11
+ if ( ! children ) {
12
+ return null ;
13
+ }
14
+
15
+ return (
16
+ < Route
17
+ path = { basePath }
18
+ render = { props =>
19
+ createElement ( children , {
20
+ basePath,
21
+ ...resource ,
22
+ ...props ,
23
+ } )
24
+ }
25
+ />
26
+ ) ;
27
+ } ;
28
+
29
+ export default ListRouter ;
Original file line number Diff line number Diff line change
1
+ import React , { createElement } from 'react' ;
2
+ import { Route } from 'react-router' ;
3
+
4
+ /**
5
+ <ShowRouter basePath="/user" resource="user">
6
+ <Show />
7
+ </ShowRouter>;
8
+ */
9
+
10
+ export const ShowRouter = ( { basePath, resource, children } ) => {
11
+ if ( ! children ) {
12
+ return null ;
13
+ }
14
+
15
+ return (
16
+ < Route
17
+ path = { `${ basePath } /:id/show` }
18
+ render = { props =>
19
+ createElement ( children , {
20
+ basePath,
21
+ id : decodeURIComponent ( props . match . params . id ) ,
22
+ ...resource ,
23
+ ...props ,
24
+ } )
25
+ }
26
+ />
27
+ ) ;
28
+ } ;
29
+
30
+ export default ShowRouter ;
Original file line number Diff line number Diff line change
1
+ export * from './CreateRouter' ;
2
+ export * from './EditRouter' ;
3
+ export * from './ListRouter' ;
4
+ export * from './ShowRouter' ;
You can’t perform that action at this time.
0 commit comments