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

Fix<DeleteButton mutationOptions> ignores meta parameter #8023

Merged
merged 7 commits into from Aug 4, 2022

Conversation

antoinefricker
Copy link
Contributor

@antoinefricker antoinefricker commented Jul 29, 2022

Fix #8016
Kudos to @carlos-duran

  • Fix delete contexts don't send mutation meta
  • Fix settings mutationOptions on <BulkDeleteWithConfirmButton>and <BulkDeleteWithUndoButton> generates an error
  • Add mutationOptions prop description on delete buttons documentation

useMutation documentation.

@antoinefricker antoinefricker added the WIP Work In Progress label Jul 29, 2022
[skip ci]
| --------------------| -------- | --------------- | ------------------ | ---------------------------------------------------|
| `label` | Optional | `string` | 'ra.action.delete' | label or translation message to use |
| `icon` | Optional | `ReactElement` | `<DeleteIcon>` | iconElement, e.g. `<CommentIcon />` |
| `mutationOptions` | Optional | `object` | null | options for react-query `useMutation` hook |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description isn't entirely accurate, as react-query's options cannot contain a meta key. In fact, you should probably add an example explaining how to set the meta parameter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a meta option in useMutation. It is of type Record<string, unknown> when ours is any though.

@@ -277,6 +277,7 @@ Delete the current record after a confirm dialog has been accepted. To be used i
| `confirmContent` | Optional | `ReactNode` | 'ra.message.delete_content' | Message or React component to be used as the body of the confirm dialog |
| `redirect` | Optional | `string | false | Function` | 'list' | Custom redirection after success side effect |
| `translateOptions` | Optional | `{ id?: string, name?: string }` | {} | Custom id and name to be used in the confirm dialog's title |
| `mutationOptions` | Optional | | null | options for react-query `useMutation` hook |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@fzaninotto
Copy link
Member

Could you add a test to prove that it works?

@antoinefricker antoinefricker added WIP Work In Progress and removed RFR Ready For Review labels Aug 2, 2022
@antoinefricker
Copy link
Contributor Author

Could you add a test to prove that it works?

Here you are, colleague of little faith.

@fzaninotto fzaninotto merged commit 4f2e996 into master Aug 4, 2022
@fzaninotto fzaninotto deleted the 8016-dataprovider-delete-meta branch August 4, 2022 18:33
@fzaninotto fzaninotto added this to the 4.2.6 milestone Aug 4, 2022
@fzaninotto fzaninotto changed the title Fix delete contexts don't send mutation meta Fix<DeleteButton mutationOptions> cannot include a meta parameter Aug 4, 2022
@fzaninotto fzaninotto changed the title Fix<DeleteButton mutationOptions> cannot include a meta parameter Fix<DeleteButton mutationOptions> ignores meta parameter Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work In Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

meta is undefined in params of delete method of dataProvider when using DeleteButton
3 participants