You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/AuthRBAC.md
+53-62Lines changed: 53 additions & 62 deletions
Original file line number
Diff line number
Diff line change
@@ -109,8 +109,8 @@ React-admin already does page-level access control with actions like "list", "sh
109
109
|`create`| Allow to access the Create page |[`<Create>`](./Create.md), [`<CreateButton>`](./Buttons.md#createbutton), [`<List>`](./List.md#access-control)|
110
110
|`edit`| Allow to access the Edit page |[`<Edit>`](./Edit.md), [`<EditButton>`](./Buttons.md#editbutton), [`<Datagrid>`](./Datagrid.md#access-control), [`<Show>`](./Show.md)|
111
111
|`delete`| Allow to delete data |[`<DeleteButton>`](./Buttons.md#deletebutton), [`<BulkDeleteButton>`](./Buttons.md#bulkdeletebutton), [`<Datagrid>`](./Datagrid.md#access-control), [`<SimpleForm>`](./SimpleForm.md#access-control), [`<TabbedForm>`](#tabform)|
112
-
|`export`| Allow to export data |[`<ExportButton>`](#exportbutton), [`<List>`](./List.md#access-control)|
113
-
|`clone`| Allow to clone a record |[`<CloneButton>`](#clonebutton), [`<Edit>`](./Edit.md)|
112
+
|`export`| Allow to export data |[`<ExportButton>`](./Buttons.md#exportbutton), [`<List>`](./List.md#access-control)|
113
+
|`clone`| Allow to clone a record |[`<CloneButton>`](./Buttons.md#clonebutton), [`<Edit>`](./Edit.md)|
114
114
|`read`| Allow to view a field (or a tab) |[`<Datagrid>`](./Datagrid.md#access-control), [`<SimpleShowLayout>`](./SimpleShowLayout.md#access-control), [`<TabbedShowLayout>`](./TabbedShowLayout.md#access-control)|
115
115
|`write`| Allow to edit a field (or a tab) |[`<SimpleForm>`](./SimpleForm.md#access-control), [`<TabbedForm>`](./TabbedForm.md#access-control), [`<WizardForm>`](./WizardForm.md#enableaccesscontrol), [`<LongForm>`](./LongForm.md#enableaccesscontrol), [`<AccordionForm>`](./AccordionForm.md#enableaccesscontrol)|
116
116
@@ -365,80 +365,71 @@ Ra-rbac provides alternative components to react-admin base components. These al
Replacement for react-admin's [`<ExportButton>`](./Buttons.md#exportbutton) that checks users have the `'export'` permission before rendering. Use it if you want to provide your own `actions` to the `<List>`:
Replacement for react-admin's [`<CloneButton>`](./Buttons.md#clonebutton) that checks users have the `'clone'` permission before rendering. Use it if you want to provide your own `actions` to the `<Edit>`:
|`accessDenied`| Optional | ReactNode | null | The content to display when users don't have the `'clone'` permission |
439
-
|`action`| Optional | String |`"clone"`| The action to call `authProvider.canAccess` with |
440
-
|`authorizationError`| Optional | ReactNode | null | The content to display when an error occurs while checking permission |
441
-
442
433
## Performance
443
434
444
435
`authProvider.canAccess()` can return a promise, which in theory allows to rely on the authentication server for permissions. The downside is that this slows down the app a great deal, as each page may contain dozens of calls to these methods.
Copy file name to clipboardExpand all lines: docs/Buttons.md
+57-12Lines changed: 57 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -600,26 +600,48 @@ It also supports [all the other `<Button>` props](#button).
600
600
601
601
### Access Control
602
602
603
-
If you want to control whether this button should be displayed based on users permissions, you can leverage the `<CloneButton>` exported by the `@react-admin/ra-rbac` Enterprise package.
603
+
If you want to control whether this button should be displayed based on users permissions, use the `<CloneButton>` exported by the `@react-admin/ra-rbac` Enterprise package.
604
604
605
-
This `<CloneButton>` will call `authProvider.canAccess()` using the following parameters:
605
+
```diff
606
+
-import { CloneButton } from 'react-admin';
607
+
+import { CloneButton } from '@react-admin/ra-rbac';
608
+
```
606
609
607
-
```txt
610
+
This component adds the following [RBAC](./AuthRBAC.md) controls:
611
+
612
+
- It will only render if the user has the `'clone'` permission on the current resource.
613
+
614
+
```js
608
615
{ action:"clone", resource: [current resource] }
609
616
```
610
617
611
-
```jsx
612
-
import { TopToolbar, List } from'react-admin';
618
+
Here is an example of how to use the `<CloneButton>` with RBAC:
If you want to control whether this button should be displayed based on users permissions, you can leverage the `<ExportButton>` exported by the `@react-admin/ra-rbac` Enterprise package.
1021
+
If you want to control whether this button should be displayed based on users permissions, use the `<ExportButton>` exported by the `@react-admin/ra-rbac` Enterprise package.
1000
1022
1001
-
This `<ExportButton>` will call `authProvider.canAccess()` using the following parameters:
1023
+
```diff
1024
+
-import { ExportButton } from 'react-admin';
1025
+
+import { ExportButton } from '@react-admin/ra-rbac';
1026
+
```
1002
1027
1003
-
```txt
1028
+
This component adds the following [RBAC](./AuthRBAC.md) controls:
1029
+
1030
+
- It will only render if the user has the `'export'` permission on the current resource.
1031
+
1032
+
```js
1004
1033
{ action:"export", resource: [current resource] }
1005
1034
```
1006
1035
1036
+
- It will only export the fields the user has the `'read'` permission on.
0 commit comments