@@ -12,6 +12,7 @@ import { AdminUI } from '../AdminUI';
12
12
import { NumberField , TextField } from '../field' ;
13
13
import { Show , SimpleShowLayout } from '../detail' ;
14
14
import { TopToolbar } from '../layout' ;
15
+ import { Datagrid , List } from '../list' ;
15
16
16
17
export default { title : 'ra-ui-materialui/button/UpdateButton' } ;
17
18
@@ -44,7 +45,7 @@ const getDataProvider = () =>
44
45
id : 1 ,
45
46
title : 'Lorem Ipsum' ,
46
47
body : 'Lorem ipsum dolor sit amet' ,
47
- views : 1000 ,
48
+ views : 500 ,
48
49
} ,
49
50
] ,
50
51
authors : [ ] ,
@@ -60,24 +61,42 @@ const getDataProvider = () =>
60
61
]
61
62
) ;
62
63
63
- const PostShow = ( ) => {
64
- return (
65
- < Show
66
- actions = {
67
- < TopToolbar >
68
- < UpdateButton label = "Reset views" data = { { views : 0 } } />
69
- </ TopToolbar >
70
- }
71
- >
72
- < SimpleShowLayout >
73
- < TextField source = "id" />
74
- < TextField source = "title" />
75
- < TextField source = "body" />
76
- < NumberField source = "views" />
77
- </ SimpleShowLayout >
78
- </ Show >
79
- ) ;
80
- } ;
64
+ const PostShow = ( ) => (
65
+ < Show
66
+ actions = {
67
+ < TopToolbar >
68
+ < UpdateButton label = "Reset views" data = { { views : 0 } } />
69
+ </ TopToolbar >
70
+ }
71
+ >
72
+ < SimpleShowLayout >
73
+ < TextField source = "id" />
74
+ < TextField source = "title" />
75
+ < TextField source = "body" />
76
+ < NumberField source = "views" />
77
+ </ SimpleShowLayout >
78
+ </ Show >
79
+ ) ;
80
+
81
+ const PostList = ( ) => (
82
+ < List >
83
+ < Datagrid rowClick = "show" >
84
+ < TextField source = "id" />
85
+ < TextField source = "title" />
86
+ < TextField source = "body" />
87
+ < NumberField source = "views" />
88
+ < UpdateButton label = "Reset views" data = { { views : 0 } } />
89
+ </ Datagrid >
90
+ </ List >
91
+ ) ;
92
+
93
+ export const InsideAList = ( ) => (
94
+ < AdminContext dataProvider = { getDataProvider ( ) } i18nProvider = { i18nProvider } >
95
+ < AdminUI >
96
+ < Resource name = "posts" list = { < PostList /> } show = { < PostShow /> } />
97
+ </ AdminUI >
98
+ </ AdminContext >
99
+ ) ;
81
100
82
101
export const Undoable = ( ) => (
83
102
< AdminContext
@@ -91,28 +110,26 @@ export const Undoable = () => (
91
110
</ AdminContext >
92
111
) ;
93
112
94
- const PostShowPessimistic = ( ) => {
95
- return (
96
- < Show
97
- actions = {
98
- < TopToolbar >
99
- < UpdateButton
100
- mutationMode = "pessimistic"
101
- label = "Reset views"
102
- data = { { views : 0 } }
103
- />
104
- </ TopToolbar >
105
- }
106
- >
107
- < SimpleShowLayout >
108
- < TextField source = "id" />
109
- < TextField source = "title" />
110
- < TextField source = "body" />
111
- < NumberField source = "views" />
112
- </ SimpleShowLayout >
113
- </ Show >
114
- ) ;
115
- } ;
113
+ const PostShowPessimistic = ( ) => (
114
+ < Show
115
+ actions = {
116
+ < TopToolbar >
117
+ < UpdateButton
118
+ mutationMode = "pessimistic"
119
+ label = "Reset views"
120
+ data = { { views : 0 } }
121
+ />
122
+ </ TopToolbar >
123
+ }
124
+ >
125
+ < SimpleShowLayout >
126
+ < TextField source = "id" />
127
+ < TextField source = "title" />
128
+ < TextField source = "body" />
129
+ < NumberField source = "views" />
130
+ </ SimpleShowLayout >
131
+ </ Show >
132
+ ) ;
116
133
117
134
export const Pessimistic = ( ) => (
118
135
< AdminContext
@@ -126,28 +143,26 @@ export const Pessimistic = () => (
126
143
</ AdminContext >
127
144
) ;
128
145
129
- const PostShowOptimistic = ( ) => {
130
- return (
131
- < Show
132
- actions = {
133
- < TopToolbar >
134
- < UpdateButton
135
- mutationMode = "optimistic"
136
- label = "Reset views"
137
- data = { { views : 0 } }
138
- />
139
- </ TopToolbar >
140
- }
141
- >
142
- < SimpleShowLayout >
143
- < TextField source = "id" />
144
- < TextField source = "title" />
145
- < TextField source = "body" />
146
- < NumberField source = "views" />
147
- </ SimpleShowLayout >
148
- </ Show >
149
- ) ;
150
- } ;
146
+ const PostShowOptimistic = ( ) => (
147
+ < Show
148
+ actions = {
149
+ < TopToolbar >
150
+ < UpdateButton
151
+ mutationMode = "optimistic"
152
+ label = "Reset views"
153
+ data = { { views : 0 } }
154
+ />
155
+ </ TopToolbar >
156
+ }
157
+ >
158
+ < SimpleShowLayout >
159
+ < TextField source = "id" />
160
+ < TextField source = "title" />
161
+ < TextField source = "body" />
162
+ < NumberField source = "views" />
163
+ </ SimpleShowLayout >
164
+ </ Show >
165
+ ) ;
151
166
152
167
export const Optimistic = ( ) => (
153
168
< AdminContext
@@ -202,28 +217,26 @@ export const MutationOptions = () => (
202
217
</ AdminContext >
203
218
) ;
204
219
205
- const PostShowSx = ( ) => {
206
- return (
207
- < Show
208
- actions = {
209
- < TopToolbar >
210
- < UpdateButton
211
- sx = { { border : '1px solid red' } }
212
- label = "Reset views"
213
- data = { { views : 0 } }
214
- />
215
- </ TopToolbar >
216
- }
217
- >
218
- < SimpleShowLayout >
219
- < TextField source = "id" />
220
- < TextField source = "title" />
221
- < TextField source = "body" />
222
- < NumberField source = "views" />
223
- </ SimpleShowLayout >
224
- </ Show >
225
- ) ;
226
- } ;
220
+ const PostShowSx = ( ) => (
221
+ < Show
222
+ actions = {
223
+ < TopToolbar >
224
+ < UpdateButton
225
+ sx = { { border : '1px solid red' } }
226
+ label = "Reset views"
227
+ data = { { views : 0 } }
228
+ />
229
+ </ TopToolbar >
230
+ }
231
+ >
232
+ < SimpleShowLayout >
233
+ < TextField source = "id" />
234
+ < TextField source = "title" />
235
+ < TextField source = "body" />
236
+ < NumberField source = "views" />
237
+ </ SimpleShowLayout >
238
+ </ Show >
239
+ ) ;
227
240
228
241
export const Sx = ( ) => (
229
242
< AdminContext
0 commit comments