Skip to content

Commit e967509

Browse files
committed
Fix ArrayField Story
1 parent 70f877a commit e967509

File tree

1 file changed

+47
-37
lines changed

1 file changed

+47
-37
lines changed

packages/ra-ui-materialui/src/field/ArrayField.stories.tsx

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import {
55
useListContext,
66
useRecordContext,
77
TestMemoryRouter,
8+
ResourceContextProvider,
89
} from 'ra-core';
910
import polyglotI18nProvider from 'ra-i18n-polyglot';
1011
import englishMessages from 'ra-language-english';
1112
import { Card, ThemeProvider, createTheme } from '@mui/material';
1213

14+
import { AdminContext } from '../AdminContext';
1315
import { ArrayField } from './ArrayField';
1416
import { Datagrid, SingleFieldList } from '../list';
1517
import { ChipField } from './ChipField';
@@ -133,42 +135,50 @@ export const ListContext = () => (
133135

134136
export const InShowLayout = () => (
135137
<TestMemoryRouter>
136-
<RecordContextProvider
137-
value={{
138-
id: 123,
139-
title: 'Lorem Ipsum Sit Amet',
140-
tags: [{ name: 'dolor' }, { name: 'sit' }, { name: 'amet' }],
141-
backlinks: [
142-
{
143-
uuid: '34fdf393-f449-4b04-a423-38ad02ae159e',
144-
date: '2012-08-10T00:00:00.000Z',
145-
url: 'http://example.com/foo/bar.html',
146-
},
147-
{
148-
uuid: 'd907743a-253d-4ec1-8329-404d4c5e6cf1',
149-
date: '2012-08-14T00:00:00.000Z',
150-
url: 'https://blog.johndoe.com/2012/08/12/foobar.html',
151-
},
152-
],
153-
}}
154-
>
155-
<Card sx={{ m: 1, p: 1 }}>
156-
<SimpleShowLayout>
157-
<TextField source="title" />
158-
<ArrayField source="tags">
159-
<SingleFieldList linkType={false}>
160-
<ChipField source="name" size="small" />
161-
</SingleFieldList>
162-
</ArrayField>
163-
<ArrayField source="backlinks">
164-
<Datagrid bulkActionButtons={false}>
165-
<TextField source="uuid" />
166-
<TextField source="date" />
167-
<TextField source="url" />
168-
</Datagrid>
169-
</ArrayField>
170-
</SimpleShowLayout>
171-
</Card>
172-
</RecordContextProvider>
138+
<AdminContext>
139+
<ResourceContextProvider value="posts">
140+
<RecordContextProvider
141+
value={{
142+
id: 123,
143+
title: 'Lorem Ipsum Sit Amet',
144+
tags: [
145+
{ name: 'dolor' },
146+
{ name: 'sit' },
147+
{ name: 'amet' },
148+
],
149+
backlinks: [
150+
{
151+
uuid: '34fdf393-f449-4b04-a423-38ad02ae159e',
152+
date: '2012-08-10T00:00:00.000Z',
153+
url: 'http://example.com/foo/bar.html',
154+
},
155+
{
156+
uuid: 'd907743a-253d-4ec1-8329-404d4c5e6cf1',
157+
date: '2012-08-14T00:00:00.000Z',
158+
url: 'https://blog.johndoe.com/2012/08/12/foobar.html',
159+
},
160+
],
161+
}}
162+
>
163+
<Card sx={{ m: 1, p: 1 }}>
164+
<SimpleShowLayout>
165+
<TextField source="title" />
166+
<ArrayField source="tags">
167+
<SingleFieldList linkType={false}>
168+
<ChipField source="name" size="small" />
169+
</SingleFieldList>
170+
</ArrayField>
171+
<ArrayField source="backlinks">
172+
<Datagrid bulkActionButtons={false}>
173+
<TextField source="uuid" />
174+
<TextField source="date" />
175+
<TextField source="url" />
176+
</Datagrid>
177+
</ArrayField>
178+
</SimpleShowLayout>
179+
</Card>
180+
</RecordContextProvider>
181+
</ResourceContextProvider>
182+
</AdminContext>
173183
</TestMemoryRouter>
174184
);

0 commit comments

Comments
 (0)