EntityPermAccessControl

EntityPermAccessControl is used to conditionally render other components (which we call access-controlled components) based on a single entity operation permission. A common use case is conditionally hiding Create / Edit / Delete buttons in an entity list.

Use this component either by wrapping access-controlled components in it:

<EntityPermAccessControl entityName='scr$Car' operation='create'>
  <button>Do Something</button>
</EntityPermAccessControl>

or by providing a render prop:

<EntityPermAccessControl entityName='scr$Car'
                         operation='create'
                         render={disabled => <button disabled={disabled}>Do Something</button>}
/>

If both are provided, render prop takes precedence.

In either example the button will only be shown if the user has a permission to create scr$Car entity instances.

Instead of hiding the access-controlled components you can specify to render them as disabled by setting mode prop to disable. If mode is disable:

  • If render prop is used, it will receive true as its disabled parameter.

  • Otherwise a prop with name disabled (can be configured via disabledPropName prop) and value true (can be configured via disabledPropValue prop) will be passed to each child.


See also: