mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.6 KiB
70 lines
2.6 KiB
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Options;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Features;
|
|
using Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
|
|
using Volo.Abp.UI.Navigation;
|
|
using Volo.Abp.SettingManagement.Localization;
|
|
|
|
namespace Volo.Abp.SettingManagement.Web.Navigation
|
|
{
|
|
public class SettingManagementMainMenuContributor : IMenuContributor
|
|
{
|
|
public virtual async Task ConfigureMenuAsync(MenuConfigurationContext context)
|
|
{
|
|
if (context.Menu.Name != StandardMenus.Main)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (context.Menu.FindMenuItem(SettingManagementMenuNames.GroupName) != null)
|
|
{
|
|
/* This may happen if blazor server UI is being used in the same application.
|
|
* In this case, we don't add the MVC setting management UI. */
|
|
return;
|
|
}
|
|
|
|
var featureChecker = context.ServiceProvider.GetRequiredService<IFeatureChecker>();
|
|
if (!await featureChecker.IsEnabledAsync(SettingManagementFeatures.Enable))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var settingManagementPageOptions = context.ServiceProvider.GetRequiredService<IOptions<SettingManagementPageOptions>>().Value;
|
|
var settingPageCreationContext = new SettingPageCreationContext(context.ServiceProvider);
|
|
if (!settingManagementPageOptions.Contributors.Any() ||
|
|
!(await CheckAnyOfPagePermissionsGranted(settingManagementPageOptions, settingPageCreationContext)))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var l = context.GetLocalizer<AbpSettingManagementResource>();
|
|
|
|
context.Menu
|
|
.GetAdministration()
|
|
.AddItem(
|
|
new ApplicationMenuItem(
|
|
SettingManagementMenuNames.GroupName,
|
|
l["Settings"],
|
|
"~/SettingManagement",
|
|
icon: "fa fa-cog"
|
|
)
|
|
);
|
|
}
|
|
|
|
protected virtual async Task<bool> CheckAnyOfPagePermissionsGranted(
|
|
SettingManagementPageOptions settingManagementPageOptions,
|
|
SettingPageCreationContext settingPageCreationContext)
|
|
{
|
|
foreach (var contributor in settingManagementPageOptions.Contributors)
|
|
{
|
|
if (await contributor.CheckPermissionsAsync(settingPageCreationContext))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|