Skip to content

Commit 964679d

Browse files
committed
chore(deps): bump react-admin to 5.15.5
Keep API Platform Admin compatible with recent react-admin releases. The bump pulls MUI 9 and a newer TanStack Query, which required: - passing the mutation context to onSuccess/onError in useOnSubmit - replacing removed MUI system props with sx in stories - using ESM module mocking since react-hotkeys-hook is now ESM-only - updating nwsapi so jsdom can parse MUI 9 selectors
1 parent ab9239c commit 964679d

5 files changed

Lines changed: 154 additions & 128 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@api-platform/api-doc-parser": "^0.16.8",
2222
"jsonld": "^8.3.2",
2323
"lodash.isplainobject": "^4.0.6",
24-
"react-admin": "^5.8.3"
24+
"react-admin": "^5.15.5"
2525
},
2626
"devDependencies": {
2727
"@babel/preset-env": "^7.23.3",

‎src/stories/custom/AdvancedCustomization.stories.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const BookCreate = () => (
5353
helperText={false}
5454
validate={required()}
5555
/>
56-
<Stack direction="row" gap={2} width="100%">
56+
<Stack direction="row" sx={{ gap: 2, width: '100%' }}>
5757
<InputGuesser source="isbn" label="ISBN" helperText={false} />
5858
<InputGuesser source="publicationDate" helperText={false} />
5959
</Stack>
@@ -72,7 +72,7 @@ const BookEdit = () => (
7272
helperText={false}
7373
validate={required()}
7474
/>
75-
<Stack direction="row" gap={2} width="100%">
75+
<Stack direction="row" sx={{ gap: 2, width: '100%' }}>
7676
<InputGuesser source="isbn" label="ISBN" helperText={false} />
7777
<InputGuesser source="publicationDate" helperText={false} />
7878
</Stack>
@@ -87,7 +87,7 @@ const BookShow = () => (
8787
<TextField source="title" variant="h5" />
8888
<TextField source="author" variant="body1" />
8989
<TextField source="description" variant="body1" />
90-
<SimpleShowLayout direction="row" gap={2} sx={{ p: 0 }}>
90+
<SimpleShowLayout direction="row" sx={{ gap: 2, p: 0 }}>
9191
<TextField source="isbn" label="ISBN" variant="body1" />
9292
<DateField source="publicationDate" variant="body1" />
9393
</SimpleShowLayout>

‎src/useOnSubmit.test.tsx‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import { jest } from '@jest/globals';
33
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
44
import { render, waitFor } from '@testing-library/react';
5+
import * as reactAdminActual from 'react-admin';
56
import {
67
type CreateResult,
78
DataProviderContext,
@@ -29,12 +30,7 @@ const onSubmitProps = {
2930

3031
jest.mock('./getIdentifierValue.js');
3132
const notify = jest.fn();
32-
const reactAdminActual = jest.requireActual('react-admin') as Record<
33-
string,
34-
unknown
35-
>;
36-
jest.mock('react-admin', () => ({
37-
__esModule: true,
33+
jest.unstable_mockModule('react-admin', () => ({
3834
...reactAdminActual,
3935
useNotify: () => notify,
4036
}));

‎src/useOnSubmit.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useCallback } from 'react';
22
import { useCreate, useNotify, useRedirect, useUpdate } from 'react-admin';
33
import type { HttpError, RaRecord } from 'react-admin';
44
import { useParams } from 'react-router-dom';
5+
import { useQueryClient } from '@tanstack/react-query';
56
import lodashIsPlainObject from 'lodash.isplainobject';
67

78
import getIdentifierValue from './getIdentifierValue.js';
@@ -33,6 +34,7 @@ const useOnSubmit = ({
3334
const [update] = useUpdate();
3435
const notify = useNotify();
3536
const redirect = useRedirect();
37+
const queryClient = useQueryClient();
3638

3739
return useCallback(
3840
async (values: Partial<RaRecord>) => {
@@ -83,6 +85,7 @@ const useOnSubmit = ({
8385
...(isCreate ? {} : { id, previousData: values }),
8486
},
8587
{},
88+
{ client: queryClient, meta: mutationOptions?.meta },
8689
);
8790

8891
return undefined;
@@ -119,6 +122,7 @@ const useOnSubmit = ({
119122
...(isCreate ? {} : { id, previousData: values }),
120123
},
121124
{},
125+
{ client: queryClient, meta: mutationOptions?.meta },
122126
);
123127
return submissionErrors ?? {};
124128
}
@@ -136,6 +140,7 @@ const useOnSubmit = ({
136140
transform,
137141
create,
138142
update,
143+
queryClient,
139144
],
140145
);
141146
};

0 commit comments

Comments
 (0)