Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move extraInformation to meta #498

Merged
merged 3 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/CreateGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export const IntrospectedCreateGuesser = ({
const response = await create(
resource,
{
data: { ...data, extraInformation: { hasFileField } },
data,
meta: { hasFileField },
},
{ returnPromise: true },
);
Expand Down
7 changes: 2 additions & 5 deletions src/EditGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ export const IntrospectedEditGuesser = ({
resource,
{
id,
data: { ...data, extraInformation: { hasFileField } },
data,
meta: { hasFileField },
},
{ returnPromise: true },
);
Expand Down Expand Up @@ -199,10 +200,6 @@ export const IntrospectedEditGuesser = ({
mutationMode={mutationMode}
redirect={redirectTo}
component={viewComponent}
transform={(data: Partial<RaRecord>) => ({
...data,
extraInformation: { hasFileField },
})}
{...props}>
<FormType
onSubmit={mutationMode !== 'pessimistic' ? undefined : save}
Expand Down
12 changes: 6 additions & 6 deletions src/hydra/dataProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ describe('Transform a React Admin request to an Hydra request', () => {
data: {
bar: 'baz',
foo: 'foo',
extraInformation: {
hasFileField: true,
},
},
meta: {
hasFileField: true,
},
});
const url = mockFetchHydra.mock.calls?.[0]?.[0] ?? new URL('https://foo');
Expand Down Expand Up @@ -360,9 +360,9 @@ describe('Transform a React Admin request to an Hydra request', () => {
foo: 'foo',
bar: 'baz',
qux: null,
extraInformation: {
hasFileField: true,
},
},
meta: {
hasFileField: true,
},
previousData: {
id: '/entrypoint/resource/1',
Expand Down
5 changes: 2 additions & 3 deletions src/hydra/dataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,8 @@ function dataProvider(
}
});
let extraInformation: { hasFileField?: boolean } = {};
if ('data' in params && params.data.extraInformation) {
extraInformation = params.data.extraInformation;
delete params.data.extraInformation;
if ('meta' in params) {
extraInformation = params.meta;
}
const updateHttpMethod = extraInformation.hasFileField ? 'POST' : 'PUT';

Expand Down