@@ -112,6 +112,78 @@ export const FullApp = () => {
112112 ) ;
113113} ;
114114
115+ const data = {
116+ books : [
117+ {
118+ id : 1 ,
119+ title : 'War and Peace' ,
120+ author : 'Leo Tolstoy' ,
121+ year : 1869 ,
122+ } ,
123+ {
124+ id : 2 ,
125+ title : 'Pride and Predjudice' ,
126+ author : 'Jane Austen' ,
127+ year : 1813 ,
128+ } ,
129+ {
130+ id : 3 ,
131+ title : 'The Picture of Dorian Gray' ,
132+ author : 'Oscar Wilde' ,
133+ year : 1890 ,
134+ } ,
135+ {
136+ id : 4 ,
137+ title : 'Le Petit Prince' ,
138+ author : 'Antoine de Saint-Exupéry' ,
139+ year : 1943 ,
140+ } ,
141+ {
142+ id : 5 ,
143+ title : "Alice's Adventures in Wonderland" ,
144+ author : 'Lewis Carroll' ,
145+ year : 1865 ,
146+ } ,
147+ {
148+ id : 6 ,
149+ title : 'Madame Bovary' ,
150+ author : 'Gustave Flaubert' ,
151+ year : 1856 ,
152+ } ,
153+ {
154+ id : 7 ,
155+ title : 'The Lord of the Rings' ,
156+ author : 'J. R. R. Tolkien' ,
157+ year : 1954 ,
158+ } ,
159+ {
160+ id : 8 ,
161+ title : "Harry Potter and the Philosopher's Stone" ,
162+ author : 'J. K. Rowling' ,
163+ year : 1997 ,
164+ } ,
165+ {
166+ id : 9 ,
167+ title : 'The Alchemist' ,
168+ author : 'Paulo Coelho' ,
169+ year : 1988 ,
170+ } ,
171+ {
172+ id : 10 ,
173+ title : 'A Catcher in the Rye' ,
174+ author : 'J. D. Salinger' ,
175+ year : 1951 ,
176+ } ,
177+ {
178+ id : 11 ,
179+ title : 'Ulysses' ,
180+ author : 'James Joyce' ,
181+ year : 1922 ,
182+ } ,
183+ ] ,
184+ authors : [ ] ,
185+ } ;
186+
115187const FullAppAdmin = ( { queryClient } : { queryClient : QueryClient } ) => {
116188 const [ resourcesAccesses , setResourcesAccesses ] = React . useState ( {
117189 'books.list' : true ,
@@ -138,6 +210,10 @@ const FullAppAdmin = ({ queryClient }: { queryClient: QueryClient }) => {
138210 ) ,
139211 getPermissions : ( ) => Promise . resolve ( undefined ) ,
140212 } ;
213+ const dataProvider = fakeRestDataProvider (
214+ data ,
215+ process . env . NODE_ENV === 'development'
216+ ) ;
141217
142218 return (
143219 < AdminContext
@@ -165,18 +241,6 @@ const FullAppAdmin = ({ queryClient }: { queryClient: QueryClient }) => {
165241 ) ;
166242} ;
167243
168- export const NotificationDefault = ( ) => {
169- const dataProvider = {
170- delete : ( ) => Promise . resolve ( { data : { id : 1 } } ) ,
171- } as any ;
172- return (
173- < AdminContext dataProvider = { dataProvider } i18nProvider = { i18nProvider } >
174- < DeleteButton record = { { id : 1 } } resource = "books" />
175- < Notification />
176- </ AdminContext >
177- ) ;
178- } ;
179-
180244const AccessControlLayout = ( {
181245 children,
182246 resourcesAccesses,
@@ -231,94 +295,57 @@ const AccessControlLayout = ({
231295 ) ;
232296} ;
233297
234- const BookList = ( ) => {
298+ const BookList = ( { mutationMode = 'undoable' as const } ) => (
299+ < List >
300+ < Datagrid >
301+ < TextField source = "id" />
302+ < TextField source = "title" />
303+ < TextField source = "author" />
304+ < TextField source = "year" />
305+ < DeleteButton mutationMode = { mutationMode } />
306+ </ Datagrid >
307+ </ List >
308+ ) ;
309+
310+ export const InList = ( { mutationMode } ) => {
311+ const dataProvider = fakeRestDataProvider (
312+ data ,
313+ process . env . NODE_ENV === 'development' ,
314+ process . env . NODE_ENV === 'development' ? 500 : 0
315+ ) ;
235316 return (
236- < List >
237- < Datagrid >
238- < TextField source = "id" />
239- < TextField source = "title" />
240- < TextField source = "author" />
241- < TextField source = "year" />
242- < DeleteButton />
243- </ Datagrid >
244- </ List >
317+ < AdminContext dataProvider = { dataProvider } i18nProvider = { i18nProvider } >
318+ < AdminUI >
319+ < Resource
320+ name = "books"
321+ list = { ( ) => < BookList mutationMode = { mutationMode } /> }
322+ />
323+ </ AdminUI >
324+ </ AdminContext >
245325 ) ;
246326} ;
247327
248- const dataProvider = fakeRestDataProvider (
249- {
250- books : [
251- {
252- id : 1 ,
253- title : 'War and Peace' ,
254- author : 'Leo Tolstoy' ,
255- year : 1869 ,
256- } ,
257- {
258- id : 2 ,
259- title : 'Pride and Predjudice' ,
260- author : 'Jane Austen' ,
261- year : 1813 ,
262- } ,
263- {
264- id : 3 ,
265- title : 'The Picture of Dorian Gray' ,
266- author : 'Oscar Wilde' ,
267- year : 1890 ,
268- } ,
269- {
270- id : 4 ,
271- title : 'Le Petit Prince' ,
272- author : 'Antoine de Saint-Exupéry' ,
273- year : 1943 ,
274- } ,
275- {
276- id : 5 ,
277- title : "Alice's Adventures in Wonderland" ,
278- author : 'Lewis Carroll' ,
279- year : 1865 ,
280- } ,
281- {
282- id : 6 ,
283- title : 'Madame Bovary' ,
284- author : 'Gustave Flaubert' ,
285- year : 1856 ,
286- } ,
287- {
288- id : 7 ,
289- title : 'The Lord of the Rings' ,
290- author : 'J. R. R. Tolkien' ,
291- year : 1954 ,
292- } ,
293- {
294- id : 8 ,
295- title : "Harry Potter and the Philosopher's Stone" ,
296- author : 'J. K. Rowling' ,
297- year : 1997 ,
298- } ,
299- {
300- id : 9 ,
301- title : 'The Alchemist' ,
302- author : 'Paulo Coelho' ,
303- year : 1988 ,
304- } ,
305- {
306- id : 10 ,
307- title : 'A Catcher in the Rye' ,
308- author : 'J. D. Salinger' ,
309- year : 1951 ,
310- } ,
311- {
312- id : 11 ,
313- title : 'Ulysses' ,
314- author : 'James Joyce' ,
315- year : 1922 ,
316- } ,
317- ] ,
318- authors : [ ] ,
328+ InList . argTypes = {
329+ mutationMode : {
330+ options : [ 'undoable' , 'optimistic' , 'pessimistic' ] ,
331+ control : { type : 'select' } ,
319332 } ,
320- process . env . NODE_ENV === 'development'
321- ) ;
333+ } ;
334+ InList . args = {
335+ mutationMode : 'undoable' ,
336+ } ;
337+
338+ export const NotificationDefault = ( ) => {
339+ const dataProvider = {
340+ delete : ( ) => Promise . resolve ( { data : { id : 1 } } ) ,
341+ } as any ;
342+ return (
343+ < AdminContext dataProvider = { dataProvider } i18nProvider = { i18nProvider } >
344+ < DeleteButton record = { { id : 1 } } resource = "books" />
345+ < Notification />
346+ </ AdminContext >
347+ ) ;
348+ } ;
322349
323350export const NotificationTranslated = ( ) => {
324351 const dataProvider = {
0 commit comments