File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed
packages/ra-core/src/dataProvider Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -451,3 +451,67 @@ InvalidateList.argTypes = {
451451 options : [ 'pessimistic' , 'optimistic' , 'undoable' ] ,
452452 } ,
453453} ;
454+
455+ export const CreateIdZero = ( {
456+ mutationMode,
457+ } : {
458+ mutationMode : MutationModeType ;
459+ } ) => {
460+ const dataProvider = fakeRestDataProvider (
461+ {
462+ posts : [ ] ,
463+ } ,
464+ process . env . NODE_ENV !== 'test' ,
465+ process . env . NODE_ENV === 'test' ? 10 : 1000
466+ ) ;
467+
468+ return (
469+ < TestMemoryRouter initialEntries = { [ '/posts/create' ] } >
470+ < CoreAdmin dataProvider = { dataProvider } >
471+ < Resource
472+ name = "posts"
473+ create = {
474+ < CreateBase mutationMode = { mutationMode } >
475+ < Form >
476+ { mutationMode !== 'pessimistic' && (
477+ < TextInput source = "id" defaultValue = { 0 } />
478+ ) }
479+ < TextInput source = "title" />
480+ < button type = "submit" > Save</ button >
481+ </ Form >
482+ </ CreateBase >
483+ }
484+ list = {
485+ < ListBase loading = { < p > Loading...</ p > } >
486+ < RecordsIterator
487+ render = { ( record : any ) => (
488+ < div
489+ style = { {
490+ display : 'flex' ,
491+ gap : '8px' ,
492+ alignItems : 'center' ,
493+ } }
494+ >
495+ { record . id } : { record . title }
496+ </ div >
497+ ) }
498+ />
499+ < Notification />
500+ </ ListBase >
501+ }
502+ />
503+ </ CoreAdmin >
504+ </ TestMemoryRouter >
505+ ) ;
506+ } ;
507+ CreateIdZero . args = {
508+ mutationMode : 'undoable' ,
509+ } ;
510+ CreateIdZero . argTypes = {
511+ mutationMode : {
512+ control : {
513+ type : 'select' ,
514+ } ,
515+ options : [ 'pessimistic' , 'optimistic' , 'undoable' ] ,
516+ } ,
517+ } ;
You can’t perform that action at this time.
0 commit comments