Browse Source

Update Toolbars.md

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

11
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`.
Use the `RequiredPermissionName` property of `ToolbarItem` or manually checking the permissions.
````csharp
context.Toolbar.Items.Insert(0, new ToolbarItem(typeof(NotificationViewComponent), requiredPermissionName: "MyPermissionName"));
if (await context.IsGrantedAsync("MyPermissionName"))
{
//...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.
@ -84,4 +85,4 @@ That's all, you will see the notification icon on the toolbar when you run the a
## IToolbarManager
`IToolbarManager` is used to render the toolbar. It returns the toolbar items by a toolbar name. This is generally used by the [themes](Theming.md) to render the toolbar on the layout.
`IToolbarManager` is used to render the toolbar. It returns the toolbar items by a toolbar name. This is generally used by the [themes](Theming.md) to render the toolbar on the layout.

Loading…
Cancel
Save