Browse Source
Merge pull request #24634 from abpframework/auto-merge/rel-10-1/4278
Merge branch dev with rel-10.1
pull/24637/head
Ma Liming
4 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
13 additions and
7 deletions
-
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/SimplePageToolbarContributor.cs
|
|
|
@ -16,6 +16,8 @@ public class SimplePageToolbarContributor : IPageToolbarContributor |
|
|
|
|
|
|
|
public string? RequiredPolicyName { get; } |
|
|
|
|
|
|
|
private bool? _shouldAddComponent; |
|
|
|
|
|
|
|
public SimplePageToolbarContributor( |
|
|
|
Type componentType, |
|
|
|
Dictionary<string, object?>? arguments = null, |
|
|
|
@ -38,15 +40,19 @@ public class SimplePageToolbarContributor : IPageToolbarContributor |
|
|
|
|
|
|
|
protected virtual async Task<bool> ShouldAddComponentAsync(PageToolbarContributionContext context) |
|
|
|
{ |
|
|
|
if (RequiredPolicyName != null) |
|
|
|
if (_shouldAddComponent.HasValue) |
|
|
|
{ |
|
|
|
return _shouldAddComponent.Value; |
|
|
|
} |
|
|
|
|
|
|
|
if (RequiredPolicyName == null) |
|
|
|
{ |
|
|
|
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>(); |
|
|
|
if (!await authorizationService.IsGrantedAsync(RequiredPolicyName)) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
_shouldAddComponent = true; |
|
|
|
return _shouldAddComponent.Value; |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>(); |
|
|
|
_shouldAddComponent = await authorizationService.IsGrantedAsync(RequiredPolicyName); |
|
|
|
return _shouldAddComponent.Value; |
|
|
|
} |
|
|
|
} |
|
|
|
|