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

BulkUpdateButtons do not support custom mutation meta field #9029

Closed
KonkretneKosteczki opened this issue Jun 20, 2023 · 3 comments
Closed

Comments

@KonkretneKosteczki
Copy link
Contributor

KonkretneKosteczki commented Jun 20, 2023

Is your feature request related to a problem? Please describe.
One can pass query options to the list, but not mutation options to the BulkUpdateButton

export const PostList = () => (
    <List queryOptions={{meta: {foo: "bar"}}}>
        <Datagrid bulkActionButtons={
          <>
            <BulkUpdateButton label="Make commentable" data={{commentable: true}} />
            <BulkDeleteButton />
          </>
        }>
            <TextField source="id" />
            <TextField source="title" />
            <DateField source="published_at" />
            <TextField source="category" />
            <BooleanField source="commentable" />
        </Datagrid>
    </List>
);

Describe the solution you'd like
It would be nice if the buttons accepted not only mutationMode, but also mutationOptions prop the same way that BulkDeleteButton and Edit components do.

            <BulkUpdateButton mutationOptions={{meta: {foo: "bar"}}} label="Make commentable" data={{commentable: true}} />
            <BulkDeleteButton mutationOptions={{meta: {foo: "bar"}}} />

Describe alternatives you've considered
Maybe it doesn't have to be buttons, but list prop could accept the parameter and button scould somehow get it from the context instead.

@slax57
Copy link
Contributor

slax57 commented Jun 21, 2023

Thanks for this suggestion.

I think we should definitely add mutationOptions to BulkUpdateButton, especially provided that other similar buttons (BulkDeleteButton, DeleteButton) already support it.

I think it's best to set the meta prop at the button level, as it allows for more flexibility in case you need to pass a specific value for this case, besides I don't see what context could hold this value.

Would you like to open a PR to add this feature?

@KonkretneKosteczki
Copy link
Contributor Author

KonkretneKosteczki commented Jun 21, 2023

I added support for the mutationOptions in this pull #9035 I tried to follow implementation of BulkDeleteButton so that they are the same. Please let me know if the code is not up to standard I will update it.

@slax57
Copy link
Contributor

slax57 commented Jun 21, 2023

Implemented in #9035

@slax57 slax57 closed this as completed Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants