Skip to content

Commit b5aea7c

Browse files
committed
[Storybook]: Add react-query-devtools to all stories.
1 parent 780b639 commit b5aea7c

6 files changed

Lines changed: 31 additions & 6 deletions

File tree

src/stories/Basic.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import type { Meta, StoryObj } from '@storybook/react';
33
import { within } from '@storybook/test';
44
import { HydraAdmin, type HydraAdminProps } from '../hydra';
55
import { OpenApiAdmin } from '../openapi';
6+
import DevtoolsLayout from './layout/DevtoolsLayout';
67

78
/**
89
* # Basic `<HydraAdmin>` component
910
* The `<HydraAdmin>` component without any parameter.
1011
*/
1112
const Basic = ({ entrypoint }: BasicProps) => (
12-
<HydraAdmin entrypoint={entrypoint} />
13+
<HydraAdmin entrypoint={entrypoint} layout={DevtoolsLayout} />
1314
);
1415

1516
interface BasicProps extends Pick<HydraAdminProps, 'entrypoint'> {}

src/stories/Basic.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import React from 'react';
22
import { HydraAdmin, type HydraAdminProps } from '../hydra';
3+
import DevtoolsLayout from './layout/DevtoolsLayout';
34

45
/**
56
* # Basic `<HydraAdmin>` component
67
* The `<HydraAdmin>` component without any parameter.
78
*/
89
const Basic = ({ entrypoint }: BasicProps) => (
9-
<HydraAdmin entrypoint={entrypoint} />
10+
<HydraAdmin entrypoint={entrypoint} layout={DevtoolsLayout} />
1011
);
1112

1213
export default Basic;

src/stories/auth/Admin.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { HydraAdmin, type HydraAdminProps } from '../../hydra';
33
import authProvider from './basicAuth';
4+
import DevtoolsLayout from '../layout/DevtoolsLayout';
45

56
/**
67
* # Protected `<HydraAdmin>`
@@ -9,7 +10,12 @@ import authProvider from './basicAuth';
910
* Login with: john/123
1011
*/
1112
const Admin = ({ entrypoint }: JwtAuthProps) => (
12-
<HydraAdmin entrypoint={entrypoint} authProvider={authProvider} requireAuth />
13+
<HydraAdmin
14+
entrypoint={entrypoint}
15+
authProvider={authProvider}
16+
requireAuth
17+
layout={DevtoolsLayout}
18+
/>
1319
);
1420

1521
export default Admin;

src/stories/custom/AdvancedCustomization.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
DateField,
1111
Edit,
1212
Labeled,
13-
Layout,
1413
List,
1514
NumberField,
1615
ReferenceArrayField,
@@ -34,6 +33,7 @@ import ResourceGuesser from '../../core/ResourceGuesser';
3433
import FieldGuesser from '../../field/FieldGuesser';
3534
import { HydraAdmin } from '../../hydra';
3635
import InputGuesser from '../../input/InputGuesser';
36+
import DevtoolsLayout from '../layout/DevtoolsLayout';
3737

3838
export default {
3939
title: 'Admin/Custom/AdvancedCustomization',
@@ -222,7 +222,7 @@ const ReviewList = () => (
222222
export const AdvancedCustomization = () => (
223223
<HydraAdmin
224224
entrypoint={process.env.ENTRYPOINT}
225-
layout={Layout}
225+
layout={DevtoolsLayout}
226226
theme={defaultLightTheme}
227227
darkTheme={defaultDarkTheme}>
228228
<ResourceGuesser

src/stories/custom/UsingGuessers.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import FieldGuesser from '../../field/FieldGuesser';
99
import EditGuesser from '../../edit/EditGuesser';
1010
import InputGuesser from '../../input/InputGuesser';
1111
import CreateGuesser from '../../create/CreateGuesser';
12+
import DevtoolsLayout from '../layout/DevtoolsLayout';
1213

1314
export default {
1415
title: 'Admin/Custom/UsingGuessers',
@@ -98,7 +99,7 @@ const ReviewList = () => (
9899
);
99100

100101
export const UsingGuessers = () => (
101-
<HydraAdmin entrypoint={process.env.ENTRYPOINT}>
102+
<HydraAdmin entrypoint={process.env.ENTRYPOINT} layout={DevtoolsLayout}>
102103
<ResourceGuesser
103104
name="books"
104105
list={BookList}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
3+
import { useQueryClient } from '@tanstack/react-query';
4+
import { Layout, type LayoutProps } from 'react-admin';
5+
6+
const DevtoolsLayout = ({ children, ...props }: LayoutProps) => {
7+
const client = useQueryClient();
8+
return (
9+
<Layout {...props}>
10+
{children}
11+
<ReactQueryDevtools initialIsOpen={false} client={client} />
12+
</Layout>
13+
);
14+
};
15+
16+
export default DevtoolsLayout;

0 commit comments

Comments
 (0)