Skip to content

Commit 80fb439

Browse files
committed
[Doc] Mention Soft Delete in Buttons documentation
1 parent 9fcec4c commit 80fb439

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

docs/Buttons.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,20 @@ Alternately, pass a `successMessage` prop:
112112
<BulkDeleteButton successMessage="Posts deleted successfully" />
113113
```
114114

115+
### Access Control
116+
117+
If your `authProvider` implements [Access Control](./Permissions.md#access-control), `<DeleteButton>` will only render if the user has the "delete" access to the related resource.
118+
119+
`<DeleteButton>` will call `authProvider.canAccess()` using the following parameters:
120+
121+
```txt
122+
{ action: "delete", resource: [current resource], record: [current record] }
123+
```
124+
125+
### Soft Delete
126+
127+
Should you need to only archive records, the soft delete feature from the [Enterprise Edition add-on](https://react-admin-ee.marmelab.com/documentation/ra-soft-delete) provides the [`<BulkSoftDeleteButton />`](./BulkSoftDeleteButton.md), a drop-in replacement for `<BulkDeleteButton>`.
128+
115129
## `<BulkExportButton>`
116130

117131
Same as `<ExportButton>`, except it only exports the selected rows instead of the entire list. To be used inside [the `<DataTable bulkActionButtons>` prop](./DataTable.md#bulkactionbuttons).
@@ -1022,6 +1036,10 @@ If your `authProvider` implements [Access Control](./Permissions.md#access-contr
10221036
{ action: "delete", resource: [current resource], record: [current record] }
10231037
```
10241038

1039+
### Soft Delete
1040+
1041+
Should you need to only archive records, the soft delete feature from the [Enterprise Edition add-on](https://react-admin-ee.marmelab.com/documentation/ra-soft-delete) provides the [`<SoftDeleteButton />`](./SoftDeleteButton.md), a drop-in replacement for `<DeleteButton>`.
1042+
10251043
## `<DeleteWithConfirmButton>`
10261044

10271045
Delete the current record after a confirm dialog has been accepted. To be used inside a `<Toolbar/>` component.
@@ -1063,15 +1081,15 @@ const MyEdit = () => (
10631081
<Edit>
10641082
<SimpleForm toolbar={<EditToolbar />}>
10651083
...
1066-
</SimpleForm>
1067-
</Edit>
1084+
</SimpleForm>
1085+
</Edit>
10681086
);
10691087
```
10701088
{% endraw %}
10711089

10721090
## `<EditButton>`
10731091

1074-
Opens the Edit view of the current record.
1092+
Opens the Edit view of the current record.
10751093

10761094
![Edit button](./img/edit-button.png)
10771095

@@ -1397,7 +1415,7 @@ By default, react-admin's `<DataTable>` displays a `<SelectAllButton>` in its `b
13971415
import { List, DataTable, BulkActionsToolbar, SelectAllButton, BulkDeleteButton } from 'react-admin';
13981416

13991417
const PostSelectAllButton = () => (
1400-
<SelectAllButton
1418+
<SelectAllButton
14011419
label="Select all records"
14021420
queryOptions={{ meta: { foo: 'bar' } }}
14031421
/>
@@ -1636,11 +1654,11 @@ const PostEditActions = () => (
16361654

16371655
The mutation mode determines when the side effects (redirection, notifications, etc.) are executed:
16381656

1639-
- `pessimistic`: The mutation is passed to the dataProvider first. When the dataProvider returns successfully, the mutation is applied locally, and the side effects are executed.
1640-
- `optimistic`: The mutation is applied locally and the side effects are executed immediately. Then the mutation is passed to the dataProvider. If the dataProvider returns successfully, nothing happens (as the mutation was already applied locally). If the dataProvider returns in error, the page is refreshed and an error notification is shown.
1657+
- `pessimistic`: The mutation is passed to the dataProvider first. When the dataProvider returns successfully, the mutation is applied locally, and the side effects are executed.
1658+
- `optimistic`: The mutation is applied locally and the side effects are executed immediately. Then the mutation is passed to the dataProvider. If the dataProvider returns successfully, nothing happens (as the mutation was already applied locally). If the dataProvider returns in error, the page is refreshed and an error notification is shown.
16411659
- `undoable` (default): The mutation is applied locally and the side effects are executed immediately. Then a notification is shown with an undo button. If the user clicks on undo, the mutation is never sent to the dataProvider, and the page is refreshed. Otherwise, after a 5 seconds delay, the mutation is passed to the dataProvider. If the dataProvider returns successfully, nothing happens (as the mutation was already applied locally). If the dataProvider returns in error, the page is refreshed and an error notification is shown.
16421660

1643-
By default, the `<UpdateButton>` uses the `undoable` mutation mode. This is part of the "optimistic rendering" strategy of react-admin ; it makes user interactions more reactive.
1661+
By default, the `<UpdateButton>` uses the `undoable` mutation mode. This is part of the "optimistic rendering" strategy of react-admin ; it makes user interactions more reactive.
16441662

16451663
You can change this default by setting the `mutationMode` prop. For instance, to remove the ability to undo the changes, use the `optimistic` mode:
16461664

@@ -1671,7 +1689,7 @@ const PostEditActions = () => (
16711689
{% endraw %}
16721690

16731691

1674-
**Tip**: When using any other mode than `undoable`, the `<UpdateButton>` displays a confirmation dialog before calling the dataProvider.
1692+
**Tip**: When using any other mode than `undoable`, the `<UpdateButton>` displays a confirmation dialog before calling the dataProvider.
16751693

16761694
### `confirmTitle`
16771695

@@ -1777,7 +1795,7 @@ The default `onSuccess` function is:
17771795
}
17781796
```
17791797

1780-
**Tip**: When you use `mutationMode="pessimistic"`, the `onSuccess` function receives the response from the `dataProvider.update()` call, which is the edited record (see [the dataProvider documentation for details](./DataProviderWriting.md#update)). You can use that response in the success side effects:
1798+
**Tip**: When you use `mutationMode="pessimistic"`, the `onSuccess` function receives the response from the `dataProvider.update()` call, which is the edited record (see [the dataProvider documentation for details](./DataProviderWriting.md#update)). You can use that response in the success side effects:
17811799

17821800
{% raw %}
17831801
```jsx

0 commit comments

Comments
 (0)