Browse Source

Update Toolbars.md

pull/7882/head
maliming 6 years ago
committed by GitHub
parent
commit
73dd6eb30d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      docs/en/UI/AspNetCore/Toolbars.md

9
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.

Loading…
Cancel
Save