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

<Edit mutationMode="pessimistic"> produces "undoable" delete action in toolbar #5854

Closed
despatates opened this issue Feb 3, 2021 · 10 comments · Fixed by #5855
Closed

<Edit mutationMode="pessimistic"> produces "undoable" delete action in toolbar #5854

despatates opened this issue Feb 3, 2021 · 10 comments · Fixed by #5855

Comments

@despatates
Copy link
Contributor

What you were expecting:
With <Edit mutationMode="pessimistic" />, clicking on the delete button should open a confirmation dialog like it does with undoable={false}.

What happened instead:
With <Edit mutationMode="pessimistic" />, clicking on the delete button deletes the resource like it does with mutationMode="undoable".
A notification is shown with an "undo" action.

Steps to reproduce:
Create an edit form on a resource, and set pessimistic mutation mode.
In the toolbar at the bottom, click on the delete button.

record-2021-02-03_13.32.31.mp4

Related code:

import * as React from 'react';
import { DeleteButton, Edit, SaveButton, SimpleForm, TextInput, Toolbar } from 'react-admin';

const UserEdit = props => (
  <Edit {...props} mutationMode="pessimistic">
    <SimpleForm redirect="show">
      <TextInput source="name" />
      <TextInput source="email" />
    </SimpleForm>
  </Edit>
);

The result is the same with a custom toolbar, following the documentation example:

import * as React from 'react';
import { DeleteButton, Edit, SaveButton, SimpleForm, TextInput, Toolbar } from 'react-admin';

const CustomToolbar = props => (
  <Toolbar {...props}>
    <SaveButton />
    <DeleteButton mutationMode="pessimistic" />
  </Toolbar>
);

const UserEdit = props => (
  <Edit {...props} mutationMode="pessimistic">
    <SimpleForm redirect="show" toolbar={<CustomToolbar />}>
      <TextInput source="name" />
      <TextInput source="email" />
    </SimpleForm>
  </Edit>
);

Environment

  • React-admin version: 3.12.0
  • React version: 16.14.0
  • Browser: Chrome 88.0.4324.96
@djhi
Copy link
Collaborator

djhi commented Feb 3, 2021

Thanks for the report. Indeed, the DeleteButton has its undoable prop set to true by default

@djhi djhi added the bug label Feb 3, 2021
@djhi
Copy link
Collaborator

djhi commented Feb 3, 2021

Sorry I misread. So we actually don't propagate mutationMode accross all actions in a view. This would be a feature request. Howver there is also an issue with the DeleteButton which has undoable prop set to true by default. This prevent users to set another mutationMode. This is an issue. I'll fix this issue asap and add a feature request tag here

@nckenn
Copy link

nckenn commented Feb 4, 2021

@despatates not related to the issue, just want to ask are you using RA Enterprise Edition?

@despatates
Copy link
Contributor Author

@nckenn No, I'm not. Why?

@djhi
Copy link
Collaborator

djhi commented Feb 4, 2021

Closed automatically by Github but should be kept open for the feature request

@djhi djhi reopened this Feb 4, 2021
@djhi djhi added enhancement and removed bug labels Feb 4, 2021
@fzaninotto
Copy link
Member

The description mentions a bug that you've fixed. What's the feature request?

@djhi
Copy link
Collaborator

djhi commented Feb 4, 2021

The propagation of the mutationMode accross all actions in a view as their default mutation mode

@fzaninotto
Copy link
Member

As seen on the phone with @djhi, we agree that the bug is now fixed, so I'm closing this issue.

@nckenn
Copy link

nckenn commented Feb 4, 2021

@despatates can you share your AppBar?

@despatates
Copy link
Contributor Author

@nckenn My AppBar is very simple, it's a merge between react-admin and Material-UI components.

https://gist.github.com/despatates/3e92ea856ee2db4ddb870e3a0bfa9c3b
If you have any questions please comment on the gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants