selectPermissions
Home > @gooddata/sdk-ui-dashboard > selectPermissions
selectPermissions variable
This selector returns user's permissions in the workspace where the dashboard is stored.
Signature:
selectPermissions: DashboardSelector<IWorkspacePermissions>
Remarks
It is expected that the selector is called only after the permission state is correctly initialized. Invocations before initialization lead to invariant errors.
See for all available permissions.
If the permission is not supported by GoodData Cloud and GoodData.CN backends, the selector always returns false
value.
In case you need multiple permissions available in your application, use common selector.
Example 1
- on how to select all permissions.
const permissions = useDashboardSelector(selectPermissions);
if (permissions.canCreateAnalyticalDashboard) {
// allow user to do a action for which the `canCreateAnalyticalDashboard` permission is needed
}
If there is only limited number of permissions, use specific selector instead (available selectors are all below).
Example 2
- on how to select specific permission.
const canCreateAnalyticalDashboard = useDashboardSelector(selectCanCreateAnalyticalDashboard);
if (canCreateAnalyticalDashboard) {
// allow user to do a action for which the `canCreateAnalyticalDashboard` permission is needed
}