Skip to content

Commit 4d29039

Browse files
committed
remove import from react-admin
1 parent 3e9628a commit 4d29039

File tree

1 file changed

+146
-126
lines changed

1 file changed

+146
-126
lines changed

packages/ra-ui-materialui/src/input/SelectArrayInput.stories.tsx

Lines changed: 146 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import englishMessages from 'ra-language-english';
1616
import * as React from 'react';
1717

1818
import { CreateBase, Resource, TestMemoryRouter } from 'ra-core';
19-
import { Admin } from 'react-admin';
2019
import { AdminContext } from '../AdminContext';
20+
import { AdminUI } from '../AdminUI.tsx';
2121
import { Create, Edit } from '../detail';
2222
import { SimpleForm } from '../form';
2323
import { ArrayInput, SimpleFormIterator } from './ArrayInput';
@@ -552,45 +552,51 @@ const dataProviderWithAuthors = {
552552

553553
export const InsideReferenceArrayInput = () => (
554554
<TestMemoryRouter initialEntries={['/books/1']}>
555-
<Admin dataProvider={dataProviderWithAuthors}>
556-
<Resource
557-
name="authors"
558-
recordRepresentation={record =>
559-
`${record.first_name} ${record.last_name}`
560-
}
561-
/>
562-
<Resource
563-
name="books"
564-
edit={() => (
565-
<Edit
566-
mutationMode="pessimistic"
567-
mutationOptions={{
568-
onSuccess: data => {
569-
console.log(data);
570-
},
571-
}}
572-
>
573-
<SimpleForm>
574-
<ReferenceArrayInput
575-
reference="authors"
576-
source="authors"
577-
>
578-
<SelectArrayInput />
579-
</ReferenceArrayInput>
580-
<FormInspector name="authors" />
581-
</SimpleForm>
582-
</Edit>
583-
)}
584-
/>
585-
</Admin>
555+
<AdminContext
556+
dataProvider={dataProviderWithAuthors}
557+
i18nProvider={polyglotI18nProvider(() => englishMessages, 'en')}
558+
defaultTheme="light"
559+
>
560+
<AdminUI>
561+
<Resource
562+
name="authors"
563+
recordRepresentation={record =>
564+
`${record.first_name} ${record.last_name}`
565+
}
566+
/>
567+
<Resource
568+
name="books"
569+
edit={() => (
570+
<Edit
571+
mutationMode="pessimistic"
572+
mutationOptions={{
573+
onSuccess: data => {
574+
console.log(data);
575+
},
576+
}}
577+
>
578+
<SimpleForm>
579+
<ReferenceArrayInput
580+
reference="authors"
581+
source="authors"
582+
>
583+
<SelectArrayInput />
584+
</ReferenceArrayInput>
585+
<FormInspector name="authors" />
586+
</SimpleForm>
587+
</Edit>
588+
)}
589+
/>
590+
</AdminUI>
591+
</AdminContext>
586592
</TestMemoryRouter>
587593
);
588594

589595
export const InsideReferenceArrayInputDefaultValue = ({
590596
onSuccess = console.log,
591597
}) => (
592598
<TestMemoryRouter initialEntries={['/books/1']}>
593-
<Admin
599+
<AdminContext
594600
dataProvider={{
595601
...dataProviderWithAuthors,
596602
getOne: () =>
@@ -606,78 +612,86 @@ export const InsideReferenceArrayInputDefaultValue = ({
606612
},
607613
}),
608614
}}
615+
i18nProvider={polyglotI18nProvider(() => englishMessages, 'en')}
616+
defaultTheme="light"
609617
>
610-
<Resource
611-
name="authors"
612-
recordRepresentation={record =>
613-
`${record.first_name} ${record.last_name}`
614-
}
615-
/>
616-
<Resource
617-
name="books"
618-
edit={() => (
619-
<Edit
620-
mutationMode="pessimistic"
621-
mutationOptions={{ onSuccess }}
622-
>
623-
<SimpleForm>
624-
<TextInput source="title" />
625-
<ReferenceArrayInput
626-
reference="authors"
627-
source="authors"
628-
>
629-
<SelectArrayInput />
630-
</ReferenceArrayInput>
631-
<FormInspector name="authors" />
632-
</SimpleForm>
633-
</Edit>
634-
)}
635-
/>
636-
</Admin>
618+
<AdminUI>
619+
<Resource
620+
name="authors"
621+
recordRepresentation={record =>
622+
`${record.first_name} ${record.last_name}`
623+
}
624+
/>
625+
<Resource
626+
name="books"
627+
edit={() => (
628+
<Edit
629+
mutationMode="pessimistic"
630+
mutationOptions={{ onSuccess }}
631+
>
632+
<SimpleForm>
633+
<TextInput source="title" />
634+
<ReferenceArrayInput
635+
reference="authors"
636+
source="authors"
637+
>
638+
<SelectArrayInput />
639+
</ReferenceArrayInput>
640+
<FormInspector name="authors" />
641+
</SimpleForm>
642+
</Edit>
643+
)}
644+
/>
645+
</AdminUI>
646+
</AdminContext>
637647
</TestMemoryRouter>
638648
);
639649

640650
export const InsideReferenceArrayInputWithError = () => (
641651
<TestMemoryRouter initialEntries={['/books/1']}>
642-
<Admin
652+
<AdminContext
643653
dataProvider={{
644654
...dataProviderWithAuthors,
645655
getList: () =>
646656
Promise.reject(
647657
new Error('Error while fetching the authors')
648658
),
649659
}}
660+
i18nProvider={polyglotI18nProvider(() => englishMessages, 'en')}
661+
defaultTheme="light"
650662
>
651-
<Resource
652-
name="authors"
653-
recordRepresentation={record =>
654-
`${record.first_name} ${record.last_name}`
655-
}
656-
/>
657-
<Resource
658-
name="books"
659-
edit={() => (
660-
<Edit
661-
mutationMode="pessimistic"
662-
mutationOptions={{
663-
onSuccess: data => {
664-
console.log(data);
665-
},
666-
}}
667-
>
668-
<SimpleForm>
669-
<ReferenceArrayInput
670-
reference="authors"
671-
source="authors"
672-
>
673-
<SelectArrayInput />
674-
</ReferenceArrayInput>
675-
<FormInspector name="authors" />
676-
</SimpleForm>
677-
</Edit>
678-
)}
679-
/>
680-
</Admin>
663+
<AdminUI>
664+
<Resource
665+
name="authors"
666+
recordRepresentation={record =>
667+
`${record.first_name} ${record.last_name}`
668+
}
669+
/>
670+
<Resource
671+
name="books"
672+
edit={() => (
673+
<Edit
674+
mutationMode="pessimistic"
675+
mutationOptions={{
676+
onSuccess: data => {
677+
console.log(data);
678+
},
679+
}}
680+
>
681+
<SimpleForm>
682+
<ReferenceArrayInput
683+
reference="authors"
684+
source="authors"
685+
>
686+
<SelectArrayInput />
687+
</ReferenceArrayInput>
688+
<FormInspector name="authors" />
689+
</SimpleForm>
690+
</Edit>
691+
)}
692+
/>
693+
</AdminUI>
694+
</AdminContext>
681695
</TestMemoryRouter>
682696
);
683697

@@ -735,41 +749,47 @@ export const InsideReferenceArrayInputAndCreationSupport = () => {
735749
};
736750
return (
737751
<TestMemoryRouter initialEntries={['/books/1']}>
738-
<Admin dataProvider={dataProviderWithAuthors}>
739-
<Resource
740-
name="authors"
741-
recordRepresentation={record =>
742-
`${record.first_name} ${record.last_name}`
743-
}
744-
/>
745-
<Resource
746-
name="books"
747-
edit={() => (
748-
<Edit
749-
mutationMode="pessimistic"
750-
mutationOptions={{
751-
onSuccess: data => {
752-
console.log(data);
753-
},
754-
}}
755-
>
756-
<SimpleForm>
757-
<ReferenceArrayInput
758-
reference="authors"
759-
source="authors"
760-
>
761-
<SelectArrayInput
762-
create={<CreateAuthor />}
763-
createLabel="Create a new Author"
764-
optionText={optionRenderer}
765-
/>
766-
</ReferenceArrayInput>
767-
<FormInspector name="authors" />
768-
</SimpleForm>
769-
</Edit>
770-
)}
771-
/>
772-
</Admin>
752+
<AdminContext
753+
dataProvider={dataProviderWithAuthors}
754+
i18nProvider={polyglotI18nProvider(() => englishMessages, 'en')}
755+
defaultTheme="light"
756+
>
757+
<AdminUI>
758+
<Resource
759+
name="authors"
760+
recordRepresentation={record =>
761+
`${record.first_name} ${record.last_name}`
762+
}
763+
/>
764+
<Resource
765+
name="books"
766+
edit={() => (
767+
<Edit
768+
mutationMode="pessimistic"
769+
mutationOptions={{
770+
onSuccess: data => {
771+
console.log(data);
772+
},
773+
}}
774+
>
775+
<SimpleForm>
776+
<ReferenceArrayInput
777+
reference="authors"
778+
source="authors"
779+
>
780+
<SelectArrayInput
781+
create={<CreateAuthor />}
782+
createLabel="Create a new Author"
783+
optionText={optionRenderer}
784+
/>
785+
</ReferenceArrayInput>
786+
<FormInspector name="authors" />
787+
</SimpleForm>
788+
</Edit>
789+
)}
790+
/>
791+
</AdminUI>
792+
</AdminContext>
773793
</TestMemoryRouter>
774794
);
775795
};

0 commit comments

Comments
 (0)