maliming
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
5 deletions
-
docs/en/UI/AspNetCore/Toolbars.md
|
|
@ -54,16 +54,17 @@ public class MyToolbarContributor : IToolbarContributor |
|
|
|
|
|
|
|
|
You can use the [authorization](../../Authorization.md) to decide whether to add a `ToolbarItem`. |
|
|
You can use the [authorization](../../Authorization.md) to decide whether to add a `ToolbarItem`. |
|
|
|
|
|
|
|
|
Use the `RequiredPermissionName` property of `ToolbarItem` or manually checking the permissions. |
|
|
|
|
|
|
|
|
|
|
|
````csharp |
|
|
````csharp |
|
|
context.Toolbar.Items.Insert(0, new ToolbarItem(typeof(NotificationViewComponent), requiredPermissionName: "MyPermissionName")); |
|
|
|
|
|
|
|
|
|
|
|
if (await context.IsGrantedAsync("MyPermissionName")) |
|
|
if (await context.IsGrantedAsync("MyPermissionName")) |
|
|
{ |
|
|
{ |
|
|
//...add Toolbar items |
|
|
//...add Toolbar items |
|
|
} |
|
|
} |
|
|
```` |
|
|
```` |
|
|
|
|
|
You can use `RequiredPermissionName` as a shortcut. It is also more performant, ABP optimizes the permission check for all the items. |
|
|
|
|
|
|
|
|
|
|
|
````csharp |
|
|
|
|
|
context.Toolbar.Items.Insert(0, new ToolbarItem(typeof(NotificationViewComponent), requiredPermissionName: "MyPermissionName")); |
|
|
|
|
|
```` |
|
|
|
|
|
|
|
|
This class adds the `NotificationViewComponent` as the first item in the `Main` toolbar. |
|
|
This class adds the `NotificationViewComponent` as the first item in the `Main` toolbar. |
|
|
|
|
|
|
|
|
|