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

[Doc] Improve description of rbac tab, panel, section, and step #9030

Merged
merged 12 commits into from
Jun 23, 2023
30 changes: 26 additions & 4 deletions docs/AuthRBAC.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,9 @@ const ProductShow = () => (

Replacement for the `<TabbedShowLayout.Tab>` that only renders a tab if the user has the right permissions.

Add a `name` prop to the Tab to define the resource on which the user needs to have the 'read' permissions for.
Add a `name` prop to the `<Tab>` to define the resource on which the user needs to have the 'read' permissions for.
adguernier marked this conversation as resolved.
Show resolved Hide resolved
Then, to display a particular `<Tab>` update permissions definition as follows: `{ action: 'read', resource: '${resource}.tab.${source}' }`.
adguernier marked this conversation as resolved.
Show resolved Hide resolved
> For instance, to allow user access `<Tab label="Description" name="description">` in product resource, add this line in permissions: `{ action: 'read', resource: 'products.tab.description' }`.
adguernier marked this conversation as resolved.
Show resolved Hide resolved

`<Tab>` also only renders the child fields for which the user has the 'read' permissions.

Expand All @@ -651,7 +653,9 @@ const authProvider = {
// 'products.description' is missing
{ action: 'read', resource: 'products.thumbnail' },
// 'products.image' is missing
// note that the tab with the name 'description' will be displayed
{ action: 'read', resource: 'products.tab.description' },
// note that the tab with the name 'images' will be displayed
{ action: 'read', resource: 'products.tab.images' },
// 'products.tab.stock' is missing
],
Expand Down Expand Up @@ -758,7 +762,9 @@ const authProvider = {
// 'products.description' is missing
{ action: 'write', resource: 'products.thumbnail' },
// 'products.image' is missing
// note that the tab with the name 'description' will be displayed
{ action: 'write', resource: 'products.tab.description' },
// note that the tab with the name 'images' will be displayed
{ action: 'write', resource: 'products.tab.images' },
// 'products.tab.stock' is missing
],
Expand Down Expand Up @@ -813,7 +819,9 @@ const authProvider = {
// 'products.description' is missing
{ action: 'write', resource: 'products.thumbnail' },
// 'products.image' is missing
// note that the tab with the name 'description' will be displayed
{ action: 'write', resource: 'products.tab.description' },
// note that the tab with the name 'images' will be displayed
{ action: 'write', resource: 'products.tab.images' },
// 'products.tab.stock' is missing
],
Expand Down Expand Up @@ -870,7 +878,9 @@ const authProvider = {
// 'products.description' is missing
{ action: 'write', resource: 'products.thumbnail' },
// 'products.image' is missing
// note that the panel with the name 'description' will be displayed
{ action: 'write', resource: 'products.panel.description' },
// note that the panel with the name 'images' will be displayed
{ action: 'write', resource: 'products.panel.images' },
// 'products.panel.stock' is missing
]),
Expand Down Expand Up @@ -922,7 +932,9 @@ const authProvider = {
// 'products.description' is missing
{ action: 'write', resource: 'products.thumbnail' },
// 'products.image' is missing
// note that the panel with the name 'description' will be displayed
{ action: 'write', resource: 'products.panel.description' },
// note that the panel with the name 'images' will be displayed
{ action: 'write', resource: 'products.panel.images' },
// 'products.panel.stock' is missing
]),
Expand Down Expand Up @@ -977,7 +989,9 @@ const authProvider = {
// 'products.description' is missing
{ action: 'write', resource: 'products.thumbnail' },
// 'products.image' is missing
// note that the section with the name 'description' will be displayed
{ action: 'write', resource: 'products.section.description' },
// note that the section with the name 'images' will be displayed
{ action: 'write', resource: 'products.section.images' },
// 'products.section.stock' is missing
]),
Expand Down Expand Up @@ -1036,8 +1050,10 @@ const authProvider = {
// 'products.description' is missing
{ action: 'write', resource: 'products.thumbnail' },
// 'products.image' is missing
{ action: 'write', resource: 'products.Section.description' },
{ action: 'write', resource: 'products.Section.images' },
// note that the section with the name 'description' will be displayed
{ action: 'write', resource: 'products.section.description' },
// note that the section with the name 'images' will be displayed
{ action: 'write', resource: 'products.section.images' },
// 'products.Section.stock' is missing
]),
};
Expand Down Expand Up @@ -1089,7 +1105,9 @@ const authProvider = {
// 'products.description' is missing
{ action: 'write', resource: 'products.thumbnail' },
// 'products.image' is missing
// note that the panel with the name 'description' will be displayed
{ action: 'write', resource: 'products.panel.description' },
// note that the panel with the name 'images' will be displayed
{ action: 'write', resource: 'products.panel.images' },
adguernier marked this conversation as resolved.
Show resolved Hide resolved
// 'products.panel.stock' is missing
]),
Expand Down Expand Up @@ -1147,7 +1165,9 @@ const authProvider = {
// 'products.description' is missing
{ action: 'write', resource: 'products.thumbnail' },
// 'products.image' is missing
// note that the step with the name 'description' will be displayed
{ action: 'write', resource: 'products.step.description' },
// note that the step with the name 'images' will be displayed
{ action: 'write', resource: 'products.step.images' },
// 'products.step.stock' is missing
]),
Expand Down Expand Up @@ -1193,7 +1213,7 @@ To learn more about the permissions format, please refer to the [`@react-admin/r
{% raw %}
```tsx
import { Edit, TextInput } from 'react-admin';
import { WizardForm, WizardFormStep } from '@react-admin/ra-enterprise';
import { WizardForm } from '@react-admin/ra-enterprise';

const authProvider = {
// ...
Expand All @@ -1205,7 +1225,9 @@ const authProvider = {
// 'products.description' is missing
{ action: 'write', resource: 'products.thumbnail' },
// 'products.image' is missing
// note that the step with the name 'description' will be displayed
{ action: 'write', resource: 'products.step.description' },
// note that the step with the name 'images' will be displayed
{ action: 'write', resource: 'products.step.images' },
// 'products.step.stock' is missing
]),
Expand Down