@@ -2,7 +2,7 @@ import * as React from 'react';
22import polyglotI18nProvider from 'ra-i18n-polyglot' ;
33import englishMessages from 'ra-language-english' ;
44import frenchMessages from 'ra-language-french' ;
5- import { Resource , TestMemoryRouter } from 'ra-core' ;
5+ import { MutationMode , Resource , TestMemoryRouter } from 'ra-core' ;
66import fakeRestDataProvider from 'ra-data-fakerest' ;
77import { Alert } from '@mui/material' ;
88import { UpdateWithConfirmButton } from './UpdateWithConfirmButton' ;
@@ -82,89 +82,93 @@ const i18nProviderDefault = polyglotI18nProvider(
8282 ]
8383) ;
8484
85- const dataProvider = fakeRestDataProvider ( {
86- books : [
87- {
88- id : 1 ,
89- title : 'War and Peace' ,
90- author : 'Leo Tolstoy' ,
91- year : 1869 ,
92- } ,
93- {
94- id : 2 ,
95- title : 'Pride and Predjudice' ,
96- author : 'Jane Austen' ,
97- year : 1813 ,
98- } ,
99- {
100- id : 3 ,
101- title : 'The Picture of Dorian Gray' ,
102- author : 'Oscar Wilde' ,
103- year : 1890 ,
104- } ,
105- {
106- id : 4 ,
107- title : 'Le Petit Prince' ,
108- author : 'Antoine de Saint-Exupéry' ,
109- year : 1943 ,
110- } ,
111- {
112- id : 5 ,
113- title : "Alice's Adventures in Wonderland" ,
114- author : 'Lewis Carroll' ,
115- year : 1865 ,
116- } ,
117- {
118- id : 6 ,
119- title : 'Madame Bovary' ,
120- author : 'Gustave Flaubert' ,
121- year : 1856 ,
122- } ,
123- {
124- id : 7 ,
125- title : 'The Lord of the Rings' ,
126- author : 'J. R. R. Tolkien' ,
127- year : 1954 ,
128- } ,
129- {
130- id : 8 ,
131- title : "Harry Potter and the Philosopher's Stone" ,
132- author : 'J. K. Rowling' ,
133- year : 1997 ,
134- } ,
135- {
136- id : 9 ,
137- title : 'The Alchemist' ,
138- author : 'Paulo Coelho' ,
139- year : 1988 ,
140- } ,
141- {
142- id : 10 ,
143- title : 'A Catcher in the Rye' ,
144- author : 'J. D. Salinger' ,
145- year : 1951 ,
146- } ,
147- {
148- id : 11 ,
149- title : 'Ulysses' ,
150- author : 'James Joyce' ,
151- year : 1922 ,
152- } ,
153- ] ,
154- authors : [
155- { id : 1 , fullName : 'Leo Tolstoy' } ,
156- { id : 2 , fullName : 'Jane Austen' } ,
157- { id : 3 , fullName : 'Oscar Wilde' } ,
158- { id : 4 , fullName : 'Antoine de Saint-Exupéry' } ,
159- { id : 5 , fullName : 'Lewis Carroll' } ,
160- { id : 6 , fullName : 'Gustave Flaubert' } ,
161- { id : 7 , fullName : 'J. R. R. Tolkien' } ,
162- { id : 8 , fullName : 'J. K. Rowling' } ,
163- { id : 9 , fullName : 'Paulo Coelho' } ,
164- { id : 10 , fullName : 'J. D. Salinger' } ,
165- { id : 11 , fullName : 'James Joyce' } ,
166- ] ,
167- } ) ;
85+ const dataProvider = fakeRestDataProvider (
86+ {
87+ books : [
88+ {
89+ id : 1 ,
90+ title : 'War and Peace' ,
91+ author : 'Leo Tolstoy' ,
92+ year : 1869 ,
93+ } ,
94+ {
95+ id : 2 ,
96+ title : 'Pride and Predjudice' ,
97+ author : 'Jane Austen' ,
98+ year : 1813 ,
99+ } ,
100+ {
101+ id : 3 ,
102+ title : 'The Picture of Dorian Gray' ,
103+ author : 'Oscar Wilde' ,
104+ year : 1890 ,
105+ } ,
106+ {
107+ id : 4 ,
108+ title : 'Le Petit Prince' ,
109+ author : 'Antoine de Saint-Exupéry' ,
110+ year : 1943 ,
111+ } ,
112+ {
113+ id : 5 ,
114+ title : "Alice's Adventures in Wonderland" ,
115+ author : 'Lewis Carroll' ,
116+ year : 1865 ,
117+ } ,
118+ {
119+ id : 6 ,
120+ title : 'Madame Bovary' ,
121+ author : 'Gustave Flaubert' ,
122+ year : 1856 ,
123+ } ,
124+ {
125+ id : 7 ,
126+ title : 'The Lord of the Rings' ,
127+ author : 'J. R. R. Tolkien' ,
128+ year : 1954 ,
129+ } ,
130+ {
131+ id : 8 ,
132+ title : "Harry Potter and the Philosopher's Stone" ,
133+ author : 'J. K. Rowling' ,
134+ year : 1997 ,
135+ } ,
136+ {
137+ id : 9 ,
138+ title : 'The Alchemist' ,
139+ author : 'Paulo Coelho' ,
140+ year : 1988 ,
141+ } ,
142+ {
143+ id : 10 ,
144+ title : 'A Catcher in the Rye' ,
145+ author : 'J. D. Salinger' ,
146+ year : 1951 ,
147+ } ,
148+ {
149+ id : 11 ,
150+ title : 'Ulysses' ,
151+ author : 'James Joyce' ,
152+ year : 1922 ,
153+ } ,
154+ ] ,
155+ authors : [
156+ { id : 1 , fullName : 'Leo Tolstoy' } ,
157+ { id : 2 , fullName : 'Jane Austen' } ,
158+ { id : 3 , fullName : 'Oscar Wilde' } ,
159+ { id : 4 , fullName : 'Antoine de Saint-Exupéry' } ,
160+ { id : 5 , fullName : 'Lewis Carroll' } ,
161+ { id : 6 , fullName : 'Gustave Flaubert' } ,
162+ { id : 7 , fullName : 'J. R. R. Tolkien' } ,
163+ { id : 8 , fullName : 'J. K. Rowling' } ,
164+ { id : 9 , fullName : 'Paulo Coelho' } ,
165+ { id : 10 , fullName : 'J. D. Salinger' } ,
166+ { id : 11 , fullName : 'James Joyce' } ,
167+ ] ,
168+ } ,
169+ process . env . NODE_ENV !== 'test' ,
170+ process . env . NODE_ENV !== 'test' ? 300 : 0
171+ ) ;
168172
169173const BookList = ( { children } ) => {
170174 return (
@@ -192,7 +196,7 @@ const AuthorList = ({ children }) => {
192196 ) ;
193197} ;
194198
195- export const Basic = ( ) => (
199+ export const Basic = ( { mutationMode } : { mutationMode ?: MutationMode } ) => (
196200 < TestMemoryRouter initialEntries = { [ '/books' ] } >
197201 < AdminContext dataProvider = { dataProvider } i18nProvider = { i18nProvider } >
198202 < AdminUI >
@@ -202,6 +206,7 @@ export const Basic = () => (
202206 < BookList >
203207 < UpdateWithConfirmButton
204208 data = { { title : 'modified' } }
209+ mutationMode = { mutationMode }
205210 />
206211 </ BookList >
207212 }
@@ -211,6 +216,19 @@ export const Basic = () => (
211216 </ TestMemoryRouter >
212217) ;
213218
219+ Basic . args = {
220+ mutationMode : 'pessimistic' ,
221+ } ;
222+
223+ Basic . argTypes = {
224+ mutationMode : {
225+ options : [ 'pessimistic' , 'optimistic' , 'undoable' ] ,
226+ control : {
227+ type : 'select' ,
228+ } ,
229+ } ,
230+ } ;
231+
214232export const WithCustomTitleAndContent = ( ) => (
215233 < TestMemoryRouter initialEntries = { [ '/books' ] } >
216234 < AdminContext
0 commit comments