Skip to content

Commit

Permalink
docs: Improve docs on custom permission usage
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Nov 20, 2023
1 parent cdb801b commit 63846f8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ For example, let's imagine we are creating a plugin which adds a new entity call
```ts title="src/plugins/product-review/constants.ts"
import { CrudPermissionDefinition } from '@vendure/core';

export const productReview = new CrudPermissionDefinition(ProductReview);
export const productReview = new CrudPermissionDefinition('ProductReview');
```

These permissions can then be used in our resolver:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,18 @@ export interface NavMenuSection {
displayMode?: 'regular' | 'settings';
/**
* @description
* Control the display of this item based on the user permissions.
* Control the display of this item based on the user permissions. Note: if you attempt to pass a
* {@link PermissionDefinition} object, you will get a compilation error. Instead, pass the plain
* string version. For example, if the permission is defined as:
* ```ts
* export const MyPermission = new PermissionDefinition('ProductReview');
* ```
* then the generated permission strings will be:
*
* - `CreateProductReview`
* - `ReadProductReview`
* - `UpdateProductReview`
* - `DeleteProductReview`
*/
requiresPermission?: string | ((userPermissions: string[]) => boolean);
collapsible?: boolean;
Expand Down Expand Up @@ -116,6 +127,21 @@ export interface ActionBarItem {
buttonColor?: 'primary' | 'success' | 'warning';
buttonStyle?: 'solid' | 'outline' | 'link';
icon?: string;
/**
* @description
* Control the display of this item based on the user permissions. Note: if you attempt to pass a
* {@link PermissionDefinition} object, you will get a compilation error. Instead, pass the plain
* string version. For example, if the permission is defined as:
* ```ts
* export const MyPermission = new PermissionDefinition('ProductReview');
* ```
* then the generated permission strings will be:
*
* - `CreateProductReview`
* - `ReadProductReview`
* - `UpdateProductReview`
* - `DeleteProductReview`
*/
requiresPermission?: string | string[];
}

Expand Down

0 comments on commit 63846f8

Please sign in to comment.