mirror of https://github.com/abpframework/abp.git
committed by
GitHub
64 changed files with 230 additions and 47 deletions
@ -1,15 +1,24 @@ |
|||||
using Volo.Abp.AspNetCore.Components.Web.Theming; |
using Volo.Abp.AspNetCore.Components.Web.Theming; |
||||
|
using Volo.Abp.FeatureManagement.Blazor.Settings; |
||||
using Volo.Abp.Features; |
using Volo.Abp.Features; |
||||
using Volo.Abp.Modularity; |
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.SettingManagement.Blazor; |
||||
|
|
||||
namespace Volo.Abp.FeatureManagement.Blazor; |
namespace Volo.Abp.FeatureManagement.Blazor; |
||||
|
|
||||
[DependsOn( |
[DependsOn( |
||||
typeof(AbpAspNetCoreComponentsWebThemingModule), |
typeof(AbpAspNetCoreComponentsWebThemingModule), |
||||
typeof(AbpFeatureManagementApplicationContractsModule), |
typeof(AbpFeatureManagementApplicationContractsModule), |
||||
typeof(AbpFeaturesModule) |
typeof(AbpFeaturesModule), |
||||
|
typeof(AbpSettingManagementBlazorModule) |
||||
)] |
)] |
||||
public class AbpFeatureManagementBlazorModule : AbpModule |
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 Size="Size.Small" 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); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
@inject IHtmlLocalizer<AbpFeatureManagementResource> L |
||||
|
@using Microsoft.AspNetCore.Mvc.Localization |
||||
|
@using Volo.Abp.FeatureManagement.Localization |
||||
|
@model Volo.Abp.FeatureManagement.Pages.FeatureManagement.Components.FeatureSettingGroup.FeatureSettingGroupViewComponent.FeatureSettingViewModel |
||||
|
|
||||
|
<abp-script src="/Pages/FeatureManagement/Components/FeatureSettingGroup/Default.js" /> |
||||
|
|
||||
|
<form id="FeatureSettingsForm"> |
||||
|
@if (Model.HasManageHostFeaturesPermission) |
||||
|
{ |
||||
|
<abp-button size="Small" button-type="Primary" id="ManageHostFeatures" icon="cog" text="@L["ManageHostFeatures"].Value"/> |
||||
|
} |
||||
|
</form> |
||||
@ -0,0 +1,16 @@ |
|||||
|
(function($){ |
||||
|
|
||||
|
$(function(){ |
||||
|
var _featuresModal = new abp.ModalManager( |
||||
|
abp.appPath + 'FeatureManagement/FeatureManagementModal' |
||||
|
); |
||||
|
|
||||
|
$("#ManageHostFeatures").click(function (e) { |
||||
|
e.preventDefault(); |
||||
|
_featuresModal.open({ |
||||
|
providerName: 'T' |
||||
|
}); |
||||
|
}); |
||||
|
}) |
||||
|
|
||||
|
})(jQuery); |
||||
@ -0,0 +1,31 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Features; |
||||
|
|
||||
|
namespace Volo.Abp.FeatureManagement.Pages.FeatureManagement.Components.FeatureSettingGroup; |
||||
|
|
||||
|
public class FeatureSettingGroupViewComponent: AbpViewComponent |
||||
|
{ |
||||
|
protected IPermissionChecker PermissionChecker { get; } |
||||
|
|
||||
|
public FeatureSettingGroupViewComponent(IPermissionChecker permissionChecker) |
||||
|
{ |
||||
|
PermissionChecker = permissionChecker; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IViewComponentResult> InvokeAsync() |
||||
|
{ |
||||
|
var model = new FeatureSettingViewModel |
||||
|
{ |
||||
|
HasManageHostFeaturesPermission = await PermissionChecker.IsGrantedAsync(FeatureManagementPermissions.ManageHostFeatures) |
||||
|
}; |
||||
|
return View("~/Pages/FeatureManagement/Components/FeatureSettingGroup/Default.cshtml", model); |
||||
|
} |
||||
|
|
||||
|
public class FeatureSettingViewModel |
||||
|
{ |
||||
|
public bool HasManageHostFeaturesPermission { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Localization; |
||||
|
using Volo.Abp.FeatureManagement.Localization; |
||||
|
using Volo.Abp.FeatureManagement.Pages.FeatureManagement.Components.FeatureSettingGroup; |
||||
|
using Volo.Abp.SettingManagement.Web.Pages.SettingManagement; |
||||
|
|
||||
|
namespace Volo.Abp.FeatureManagement.Settings; |
||||
|
|
||||
|
public class FeatureSettingManagementPageContributor : SettingPageContributorBase |
||||
|
{ |
||||
|
public FeatureSettingManagementPageContributor() |
||||
|
{ |
||||
|
RequiredPermissions(FeatureManagementPermissions.ManageHostFeatures); |
||||
|
} |
||||
|
|
||||
|
public override Task ConfigureAsync(SettingPageCreationContext context) |
||||
|
{ |
||||
|
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpFeatureManagementResource>>(); |
||||
|
context.Groups.Add( |
||||
|
new SettingPageGroup( |
||||
|
"Volo.Abp.FeatureManagement", |
||||
|
l["Permission:FeatureManagement"], |
||||
|
typeof(FeatureSettingGroupViewComponent) |
||||
|
) |
||||
|
); |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue