mirror of https://github.com/abpframework/abp.git
7 changed files with 106 additions and 8 deletions
@ -1,15 +1,24 @@ |
|||
using Volo.Abp.AspNetCore.Components.Web.Theming; |
|||
using Volo.Abp.FeatureManagement.Blazor.Settings; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.SettingManagement.Blazor; |
|||
|
|||
namespace Volo.Abp.FeatureManagement.Blazor; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAspNetCoreComponentsWebThemingModule), |
|||
typeof(AbpFeatureManagementApplicationContractsModule), |
|||
typeof(AbpFeaturesModule) |
|||
typeof(AbpFeaturesModule), |
|||
typeof(AbpSettingManagementBlazorModule) |
|||
)] |
|||
public class AbpFeatureManagementBlazorModule : AbpModule |
|||
{ |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<SettingManagementComponentOptions>(options => |
|||
{ |
|||
options.Contributors.Add(new FeatureSettingManagementComponentContributor()); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,12 @@ |
|||
@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase |
|||
|
|||
@if (Settings != null && Settings.HasManageHostFeaturesPermission) |
|||
{ |
|||
<Form> |
|||
<Button Color="Color.Primary" onclick="@OnManageHostFeaturesClicked"> |
|||
<Icon Name="@("fa-cog")"/> @L["ManageHostFeatures"] |
|||
</Button> |
|||
</Form> |
|||
|
|||
<FeatureManagementModal @ref="FeatureManagementModal"/> |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.Extensions.Localization; |
|||
using Volo.Abp.AspNetCore.Components; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.FeatureManagement.Localization; |
|||
using Volo.Abp.Features; |
|||
|
|||
namespace Volo.Abp.FeatureManagement.Blazor.Components.FeatureSettingGroup; |
|||
|
|||
public partial class FeatureSettingManagementComponent : AbpComponentBase |
|||
{ |
|||
[Inject] |
|||
protected IStringLocalizer<AbpFeatureManagementResource> L { get; set; } |
|||
|
|||
[Inject] |
|||
protected PermissionChecker PermissionChecker { get; set; } |
|||
|
|||
protected FeatureManagementModal FeatureManagementModal; |
|||
|
|||
protected FeatureSettingViewModel Settings; |
|||
|
|||
protected async override Task OnInitializedAsync() |
|||
{ |
|||
Settings = new FeatureSettingViewModel |
|||
{ |
|||
HasManageHostFeaturesPermission = await PermissionChecker.IsGrantedAsync(FeatureManagementPermissions.ManageHostFeatures) |
|||
}; |
|||
} |
|||
|
|||
protected virtual async Task OnManageHostFeaturesClicked() |
|||
{ |
|||
await FeatureManagementModal.OpenAsync(TenantFeatureValueProvider.ProviderName); |
|||
} |
|||
} |
|||
|
|||
public class FeatureSettingViewModel |
|||
{ |
|||
public bool HasManageHostFeaturesPermission { get; set; } |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Localization; |
|||
using Volo.Abp.FeatureManagement.Blazor.Components.FeatureSettingGroup; |
|||
using Volo.Abp.FeatureManagement.Localization; |
|||
using Volo.Abp.SettingManagement.Blazor; |
|||
|
|||
namespace Volo.Abp.FeatureManagement.Blazor.Settings; |
|||
|
|||
public class FeatureSettingManagementComponentContributor: ISettingComponentContributor |
|||
{ |
|||
public virtual async Task ConfigureAsync(SettingComponentCreationContext context) |
|||
{ |
|||
if (!await CheckPermissionsInternalAsync(context)) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpFeatureManagementResource>>(); |
|||
context.Groups.Add( |
|||
new SettingComponentGroup( |
|||
"Volo.Abp.Feature", |
|||
l["Permission:FeatureManagement"], |
|||
typeof(FeatureSettingManagementComponent) |
|||
) |
|||
); |
|||
} |
|||
|
|||
public virtual async Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context) |
|||
{ |
|||
return await CheckPermissionsInternalAsync(context); |
|||
} |
|||
|
|||
protected virtual async Task<bool> CheckPermissionsInternalAsync(SettingComponentCreationContext context) |
|||
{ |
|||
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>(); |
|||
|
|||
return await authorizationService.IsGrantedAsync(FeatureManagementPermissions.ManageHostFeatures); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue