Skip to content

Commit f9768b4

Browse files
committed
Tweak story for manual tests
1 parent ed084b6 commit f9768b4

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

packages/ra-ui-materialui/src/list/datagrid/Datagrid.stories.tsx

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,11 @@ export const RowClickFalse = () => (
471471

472472
const dataProvider = fakeRestDataProvider({ books: data });
473473

474-
export const FullApp = () => (
474+
export const FullApp = ({
475+
rowClick,
476+
}: {
477+
rowClick?: DatagridRowProps['rowClick'];
478+
}) => (
475479
<AdminContext
476480
dataProvider={dataProvider}
477481
i18nProvider={polyglotI18nProvider(() => defaultMessages, 'en')}
@@ -481,7 +485,10 @@ export const FullApp = () => (
481485
name="books"
482486
list={() => (
483487
<List>
484-
<Datagrid>
488+
<Datagrid
489+
expand={<ExpandDetails />}
490+
rowClick={rowClick}
491+
>
485492
<TextField source="id" />
486493
<TextField source="title" />
487494
<TextField source="author" />
@@ -490,11 +497,59 @@ export const FullApp = () => (
490497
</List>
491498
)}
492499
edit={EditGuesser}
500+
show={ShowGuesser}
493501
/>
494502
</AdminUI>
495503
</AdminContext>
496504
);
497505

506+
FullApp.argTypes = {
507+
rowClick: {
508+
options: [
509+
'inferred',
510+
'show',
511+
'edit',
512+
'no-link',
513+
'expand',
514+
'toggleSelection',
515+
'function to expand',
516+
'function to toggleSelection',
517+
],
518+
mapping: {
519+
inferred: undefined,
520+
show: 'show',
521+
edit: 'edit',
522+
'no-link': false,
523+
expand: 'expand',
524+
toggleSelection: 'toggleSelection',
525+
'function to expand': (id, resource, record) => {
526+
if (process.env.NODE_ENV === 'development') {
527+
console.log('function to expand', id, resource, record);
528+
}
529+
return 'expand';
530+
},
531+
'function to toggleSelection': (id, resource, record) => {
532+
if (process.env.NODE_ENV === 'development') {
533+
console.log(
534+
'function to toggleSelection',
535+
id,
536+
resource,
537+
record
538+
);
539+
}
540+
return 'toggleSelection';
541+
},
542+
},
543+
control: { type: 'select' },
544+
},
545+
};
546+
547+
const ExpandDetails = () => {
548+
const record = useRecordContext();
549+
550+
return <div>Expand: {record?.title}</div>;
551+
};
552+
498553
const MyDatagridRow = ({
499554
onToggleItem,
500555
children,

0 commit comments

Comments
 (0)