diff --git a/src/OrchardCore.Modules/OrchardCore.Admin/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Admin/AdminMenu.cs index 22d4da0c5c7..f6ece6ee3c7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Admin/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Admin/AdminMenu.cs @@ -20,11 +20,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -39,6 +39,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.AdminMenu/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.AdminMenu/AdminMenu.cs index 266a89a2b3e..ddf50366eb7 100644 --- a/src/OrchardCore.Modules/OrchardCore.AdminMenu/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.AdminMenu/AdminMenu.cs @@ -6,22 +6,22 @@ namespace OrchardCore.AdminMenu; public sealed class AdminMenu : INavigationProvider { - private readonly AdminMenuNavigationProvidersCoordinator _adminMenuNavigationProvider; + private readonly AdminMenuNavigationProvidersCoordinator _adminMenuNavigationProviderCoordinator; internal readonly IStringLocalizer S; - public AdminMenu(AdminMenuNavigationProvidersCoordinator adminMenuNavigationProvider, + public AdminMenu(AdminMenuNavigationProvidersCoordinator adminMenuNavigationProviderCoordinator, IStringLocalizer localizer) { - _adminMenuNavigationProvider = adminMenuNavigationProvider; + _adminMenuNavigationProviderCoordinator = adminMenuNavigationProviderCoordinator; S = localizer; } - public async Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return; + return ValueTask.CompletedTask; } // Configuration and settings menus for the AdminMenu module @@ -35,6 +35,6 @@ public async Task BuildNavigationAsync(string name, NavigationBuilder builder) ); // This is the entry point for the adminMenu: dynamically generated custom admin menus - await _adminMenuNavigationProvider.BuildNavigationAsync(NavigationConstants.AdminMenuId, builder); + return _adminMenuNavigationProviderCoordinator.BuildNavigationAsync(NavigationConstants.AdminMenuId, builder); } } diff --git a/src/OrchardCore.Modules/OrchardCore.AdminMenu/Services/AdminMenuNavigationProvidersCoordinator.cs b/src/OrchardCore.Modules/OrchardCore.AdminMenu/Services/AdminMenuNavigationProvidersCoordinator.cs index dba9e021d3e..8653cbe4b2d 100644 --- a/src/OrchardCore.Modules/OrchardCore.AdminMenu/Services/AdminMenuNavigationProvidersCoordinator.cs +++ b/src/OrchardCore.Modules/OrchardCore.AdminMenu/Services/AdminMenuNavigationProvidersCoordinator.cs @@ -31,7 +31,7 @@ public AdminMenuNavigationProvidersCoordinator( _logger = logger; } - public async Task BuildNavigationAsync(string name, NavigationBuilder builder) + public async ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { // We only add them if the caller uses the string "adminMenu". if (name != NavigationConstants.AdminMenuId) diff --git a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/AdminMenu.cs index 7785b68d27b..2eb5ce08cfc 100644 --- a/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -28,6 +28,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Navigation/AuditTrailAdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Navigation/AuditTrailAdminMenu.cs index f1a154e8d7f..420287ba525 100644 --- a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Navigation/AuditTrailAdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Navigation/AuditTrailAdminMenu.cs @@ -20,11 +20,11 @@ public AuditTrailAdminMenu(IStringLocalizer stringLocalizer S = stringLocalizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -36,6 +36,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) .LocalNav() ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Navigation/AuditTrailSettingsAdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Navigation/AuditTrailSettingsAdminMenu.cs index 420c6376f6a..de27939f74d 100644 --- a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Navigation/AuditTrailSettingsAdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Navigation/AuditTrailSettingsAdminMenu.cs @@ -20,11 +20,11 @@ public AuditTrailSettingsAdminMenu(IStringLocalizer S = stringLocalizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -40,6 +40,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.BackgroundTasks/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.BackgroundTasks/AdminMenu.cs index d0b3c30881c..5dd1dc28b35 100644 --- a/src/OrchardCore.Modules/OrchardCore.BackgroundTasks/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.BackgroundTasks/AdminMenu.cs @@ -9,11 +9,11 @@ public sealed class AdminMenu : INavigationProvider public AdminMenu(IStringLocalizer localizer) => S = localizer; - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -27,6 +27,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentLocalization/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.ContentLocalization/AdminMenu.cs index ea0f1b77a91..732a2901c74 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentLocalization/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentLocalization/AdminMenu.cs @@ -26,11 +26,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -55,6 +55,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.ContentTypes/AdminMenu.cs index 7884038bc9b..9652f9f20c5 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/AdminMenu.cs @@ -16,11 +16,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -39,6 +39,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs index 70d0c584538..88a98cd5c12 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs @@ -56,7 +56,7 @@ public AdminMenu( S = localizer; } - public async Task BuildNavigationAsync(string name, NavigationBuilder builder) + public async ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetAdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetAdminMenu.cs index e2bc1d6911e..92c7a706b10 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetAdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetAdminMenu.cs @@ -19,11 +19,11 @@ public ExportContentToDeploymentTargetAdminMenu(IStringLocalizer loca S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -39,6 +39,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Cors/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Cors/AdminMenu.cs index 892f4aa07b8..c017468e4db 100644 --- a/src/OrchardCore.Modules/OrchardCore.Cors/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Cors/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -32,6 +32,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.CustomSettings/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.CustomSettings/AdminMenu.cs index 6ed4c424978..a6ccb4bf96b 100644 --- a/src/OrchardCore.Modules/OrchardCore.CustomSettings/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.CustomSettings/AdminMenu.cs @@ -23,7 +23,7 @@ public AdminMenu( _customSettingsService = customSettingsService; } - public async Task BuildNavigationAsync(string name, NavigationBuilder builder) + public async ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { diff --git a/src/OrchardCore.Modules/OrchardCore.Demo/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Demo/AdminMenu.cs index 6cb5f157beb..bdb37147b18 100644 --- a/src/OrchardCore.Modules/OrchardCore.Demo/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Demo/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -50,6 +50,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment.Remote/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Deployment.Remote/AdminMenu.cs index 55d5a584754..2a6d094a38a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment.Remote/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment.Remote/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -35,6 +35,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/AdminMenu.cs index c07bee68586..91712c8aa6f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -40,6 +40,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Email/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Email/AdminMenu.cs index 1a23e2a7829..785376bb588 100644 --- a/src/OrchardCore.Modules/OrchardCore.Email/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Email/AdminMenu.cs @@ -22,11 +22,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -49,6 +49,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/AdminMenu.cs index 6eae881a631..1ed131cd81e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/AdminMenu.cs @@ -19,11 +19,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -39,7 +39,7 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } @@ -59,11 +59,11 @@ public AdminMenuLogin( S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -79,46 +79,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; - } -} - -public sealed class AdminMenuPixel : INavigationProvider -{ - private static readonly RouteValueDictionary _routeValues = new() - { - { "area", "OrchardCore.Settings" }, - { "groupId", FacebookConstants.PixelSettingsGroupId }, - }; - - internal readonly IStringLocalizer S; - - public AdminMenuPixel( - IStringLocalizer stringLocalizer) - { - S = stringLocalizer; - } - - public Task BuildNavigationAsync(string name, NavigationBuilder builder) - { - if (!NavigationHelper.IsAdminMenu(name)) - { - return Task.CompletedTask; - } - - builder - .Add(S["Configuration"], configuration => configuration - .Add(S["Settings"], settings => settings - .Add(S["Meta Pixel"], S["Meta Pixel"].PrefixPosition(), pixel => pixel - .AddClass("facebookPixel") - .Id("facebookPixel") - .Action("Index", "Admin", _routeValues) - .Permission(FacebookConstants.ManageFacebookPixelPermission) - .LocalNav() - ) - ) - ); - - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/AdminMenuPixel.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/AdminMenuPixel.cs new file mode 100644 index 00000000000..130b0ea0600 --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/AdminMenuPixel.cs @@ -0,0 +1,45 @@ +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Localization; +using OrchardCore.Navigation; + +namespace OrchardCore.Facebook; + +public sealed class AdminMenuPixel : INavigationProvider +{ + private static readonly RouteValueDictionary _routeValues = new() + { + { "area", "OrchardCore.Settings" }, + { "groupId", FacebookConstants.PixelSettingsGroupId }, + }; + + internal readonly IStringLocalizer S; + + public AdminMenuPixel( + IStringLocalizer stringLocalizer) + { + S = stringLocalizer; + } + + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) + { + if (!NavigationHelper.IsAdminMenu(name)) + { + return ValueTask.CompletedTask; + } + + builder + .Add(S["Configuration"], configuration => configuration + .Add(S["Settings"], settings => settings + .Add(S["Meta Pixel"], S["Meta Pixel"].PrefixPosition(), pixel => pixel + .AddClass("facebookPixel") + .Id("facebookPixel") + .Action("Index", "Admin", _routeValues) + .Permission(FacebookConstants.ManageFacebookPixelPermission) + .LocalNav() + ) + ) + ); + + return ValueTask.CompletedTask; + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Features/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Features/AdminMenu.cs index b97f75d79b5..76f77253851 100644 --- a/src/OrchardCore.Modules/OrchardCore.Features/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Features/AdminMenu.cs @@ -20,11 +20,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -36,6 +36,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.GitHub/AdminMenuGitHubLogin.cs b/src/OrchardCore.Modules/OrchardCore.GitHub/AdminMenuGitHubLogin.cs index efbf84567bb..7e408ae2c46 100644 --- a/src/OrchardCore.Modules/OrchardCore.GitHub/AdminMenuGitHubLogin.cs +++ b/src/OrchardCore.Modules/OrchardCore.GitHub/AdminMenuGitHubLogin.cs @@ -19,11 +19,11 @@ public AdminMenuGitHubLogin(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -39,6 +39,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsAdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsAdminMenu.cs new file mode 100644 index 00000000000..ea2061cebca --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAnalyticsAdminMenu.cs @@ -0,0 +1,43 @@ +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Localization; +using OrchardCore.Navigation; + +namespace OrchardCore.Google; + +public sealed class GoogleAnalyticsAdminMenu : INavigationProvider +{ + private static readonly RouteValueDictionary _routeValues = new() + { + { "area", "OrchardCore.Settings" }, + { "groupId", GoogleConstants.Features.GoogleAnalytics }, + }; + + internal readonly IStringLocalizer S; + + public GoogleAnalyticsAdminMenu(IStringLocalizer localizer) + { + S = localizer; + } + + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) + { + if (!NavigationHelper.IsAdminMenu(name)) + { + return ValueTask.CompletedTask; + } + + builder + .Add(S["Configuration"], configuration => configuration + .Add(S["Settings"], settings => settings + .Add(S["Google Analytics"], S["Google Analytics"].PrefixPosition(), google => google + .AddClass("googleAnalytics").Id("googleAnalytics") + .Action("Index", "Admin", _routeValues) + .Permission(Permissions.ManageGoogleAnalytics) + .LocalNav() + ) + ) + ); + + return ValueTask.CompletedTask; + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationAdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationAdminMenu.cs index 96ed4718417..5ad2818c51b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationAdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationAdminMenu.cs @@ -19,11 +19,11 @@ public GoogleAuthenticationAdminMenu(IStringLocalizer localizer) - { - S = localizer; - } - - public Task BuildNavigationAsync(string name, NavigationBuilder builder) - { - if (!NavigationHelper.IsAdminMenu(name)) - { - return Task.CompletedTask; - } - - builder - .Add(S["Configuration"], configuration => configuration - .Add(S["Settings"], settings => settings - .Add(S["Google Analytics"], S["Google Analytics"].PrefixPosition(), google => google - .AddClass("googleAnalytics").Id("googleAnalytics") - .Action("Index", "Admin", _routeValues) - .Permission(Permissions.ManageGoogleAnalytics) - .LocalNav() - ) - ) - ); - - return Task.CompletedTask; - } -} - -public sealed class GoogleTagManagerAdminMenu : INavigationProvider -{ - private static readonly RouteValueDictionary _routeValues = new() - { - { "area", "OrchardCore.Settings" }, - { "groupId", GoogleConstants.Features.GoogleTagManager }, - }; - - internal readonly IStringLocalizer S; - - public GoogleTagManagerAdminMenu(IStringLocalizer localizer) - { - S = localizer; - } - - public Task BuildNavigationAsync(string name, NavigationBuilder builder) - { - if (!NavigationHelper.IsAdminMenu(name)) - { - return Task.CompletedTask; - } - - builder - .Add(S["Configuration"], configuration => configuration - .Add(S["Settings"], settings => settings - .Add(S["Google Tag Manager"], S["Google Tag Manager"].PrefixPosition(), google => google - .AddClass("googleTagManager") - .Id("googleTagManager") - .Action("Index", "Admin", _routeValues) - .Permission(Permissions.ManageGoogleTagManager) - .LocalNav() - ) - ) - ); - - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Google/GoogleTagManagerAdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Google/GoogleTagManagerAdminMenu.cs new file mode 100644 index 00000000000..f488e8027c9 --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Google/GoogleTagManagerAdminMenu.cs @@ -0,0 +1,44 @@ +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Localization; +using OrchardCore.Navigation; + +namespace OrchardCore.Google; + +public sealed class GoogleTagManagerAdminMenu : INavigationProvider +{ + private static readonly RouteValueDictionary _routeValues = new() + { + { "area", "OrchardCore.Settings" }, + { "groupId", GoogleConstants.Features.GoogleTagManager }, + }; + + internal readonly IStringLocalizer S; + + public GoogleTagManagerAdminMenu(IStringLocalizer localizer) + { + S = localizer; + } + + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) + { + if (!NavigationHelper.IsAdminMenu(name)) + { + return ValueTask.CompletedTask; + } + + builder + .Add(S["Configuration"], configuration => configuration + .Add(S["Settings"], settings => settings + .Add(S["Google Tag Manager"], S["Google Tag Manager"].PrefixPosition(), google => google + .AddClass("googleTagManager") + .Id("googleTagManager") + .Action("Index", "Admin", _routeValues) + .Permission(Permissions.ManageGoogleTagManager) + .LocalNav() + ) + ) + ); + + return ValueTask.CompletedTask; + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Https/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Https/AdminMenu.cs index 343c5fefad6..601b14b7ec7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Https/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Https/AdminMenu.cs @@ -20,11 +20,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -38,6 +38,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Layers/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Layers/AdminMenu.cs index 35a0ee94c1e..54567183d8a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Layers/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Layers/AdminMenu.cs @@ -20,11 +20,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -43,6 +43,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Localization/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Localization/AdminMenu.cs index e7caf0145b4..7bab7a7751f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Localization/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Localization/AdminMenu.cs @@ -28,11 +28,11 @@ public AdminMenu(IStringLocalizer localizer) } /// - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -52,6 +52,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Media.AmazonS3/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Media.AmazonS3/AdminMenu.cs index 20ac8645b70..00a388c18ee 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media.AmazonS3/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media.AmazonS3/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder.Add(S["Configuration"], configuration => configuration @@ -29,6 +29,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Media.Azure/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Media.Azure/AdminMenu.cs index 2d8ceb9eb3e..6f0741f505b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media.Azure/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media.Azure/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder.Add(S["Configuration"], configuration => configuration @@ -29,6 +29,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Media/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Media/AdminMenu.cs index aa65a4c4d73..731430c6ce7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -45,34 +45,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; - } -} - -public sealed class MediaCacheAdminMenu : INavigationProvider -{ - internal readonly IStringLocalizer S; - - public MediaCacheAdminMenu(IStringLocalizer localizer) - { - S = localizer; - } - - public Task BuildNavigationAsync(string name, NavigationBuilder builder) - { - if (!NavigationHelper.IsAdminMenu(name)) - { - return Task.CompletedTask; - } - - builder.Add(S["Configuration"], configuration => configuration - .Add(S["Media"], S["Media"].PrefixPosition(), media => media - .Add(S["Media Cache"], S["Media Cache"].PrefixPosition(), cache => cache - .Action("Index", "MediaCache", "OrchardCore.Media") - .Permission(MediaCachePermissions.ManageAssetCache) - .LocalNav()) - )); - - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Media/MediaCacheAdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Media/MediaCacheAdminMenu.cs new file mode 100644 index 00000000000..f44a5bbde92 --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Media/MediaCacheAdminMenu.cs @@ -0,0 +1,34 @@ +using Microsoft.Extensions.Localization; +using OrchardCore.Navigation; + +namespace OrchardCore.Media; + +public sealed class MediaCacheAdminMenu : INavigationProvider +{ + internal readonly IStringLocalizer S; + + public MediaCacheAdminMenu(IStringLocalizer localizer) + { + S = localizer; + } + + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) + { + if (!NavigationHelper.IsAdminMenu(name)) + { + return ValueTask.CompletedTask; + } + + builder.Add(S["Configuration"], configuration => configuration + .Add(S["Media"], S["Media"].PrefixPosition(), media => media + .Add(S["Media Cache"], S["Media Cache"].PrefixPosition(), cache => cache + .Action("Index", "MediaCache", "OrchardCore.Media") + .Permission(MediaCachePermissions.ManageAssetCache) + .LocalNav() + ) + ) + ); + + return ValueTask.CompletedTask; + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Menu/AdminMenu.cs index ede5985f17c..9bed18a2a08 100644 --- a/src/OrchardCore.Modules/OrchardCore.Menu/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Menu/AdminMenu.cs @@ -21,11 +21,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -37,6 +37,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/AdminMenuAAD.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/AdminMenuAAD.cs new file mode 100644 index 00000000000..8731c5ef14b --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/AdminMenuAAD.cs @@ -0,0 +1,38 @@ +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Localization; +using OrchardCore.Navigation; + +namespace OrchardCore.Microsoft.Authentication; + +public sealed class AdminMenuAAD : INavigationProvider +{ + private static readonly RouteValueDictionary _routeValues = new() + { + { "area", "OrchardCore.Settings" }, + { "groupId", MicrosoftAuthenticationConstants.Features.AAD }, + }; + + internal readonly IStringLocalizer S; + + public AdminMenuAAD(IStringLocalizer localizer) => S = localizer; + + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) + { + if (!NavigationHelper.IsAdminMenu(name)) + { + return ValueTask.CompletedTask; + } + + builder + .Add(S["Security"], security => security + .Add(S["Authentication"], authentication => authentication + .Add(S["Microsoft Entra ID"], S["Microsoft Entra ID"].PrefixPosition(), client => client + .AddClass("microsoft-entra-id").Id("microsoft-entra-id") + .Action("Index", "Admin", _routeValues) + .Permission(Permissions.ManageMicrosoftAuthentication) + .LocalNav()) + )); + + return ValueTask.CompletedTask; + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/AdminMenuMicrosoftAccount.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/AdminMenuMicrosoftAccount.cs index 80d244dd944..f317da4c8d1 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/AdminMenuMicrosoftAccount.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/AdminMenuMicrosoftAccount.cs @@ -19,11 +19,11 @@ public AdminMenuMicrosoftAccount(IStringLocalizer loc S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -39,39 +39,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; - } -} - -public sealed class AdminMenuAAD : INavigationProvider -{ - private static readonly RouteValueDictionary _routeValues = new() - { - { "area", "OrchardCore.Settings" }, - { "groupId", MicrosoftAuthenticationConstants.Features.AAD }, - }; - - internal readonly IStringLocalizer S; - - public AdminMenuAAD(IStringLocalizer localizer) => S = localizer; - - public Task BuildNavigationAsync(string name, NavigationBuilder builder) - { - if (!NavigationHelper.IsAdminMenu(name)) - { - return Task.CompletedTask; - } - - builder - .Add(S["Security"], security => security - .Add(S["Authentication"], authentication => authentication - .Add(S["Microsoft Entra ID"], S["Microsoft Entra ID"].PrefixPosition(), client => client - .AddClass("microsoft-entra-id").Id("microsoft-entra-id") - .Action("Index", "Admin", _routeValues) - .Permission(Permissions.ManageMicrosoftAuthentication) - .LocalNav()) - )); - - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/AdminMenu.cs index 3ed32671880..a39f986d647 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/AdminMenu.cs @@ -26,11 +26,11 @@ public AdminMenu( _shellDescriptor = shellDescriptor; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder.Add(S["Security"], security => security @@ -88,6 +88,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) } })); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Placements/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Placements/AdminMenu.cs index e1bf238c678..cf5b653050f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Placements/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Placements/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -28,6 +28,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Queries/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Queries/AdminMenu.cs index 529fe96dba4..2b68f863033 100644 --- a/src/OrchardCore.Modules/OrchardCore.Queries/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Queries/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -25,15 +25,15 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) .Id("search") .Add(S["Queries"], S["Queries"].PrefixPosition(), queries => queries .Add(S["All queries"], "1", allQueries => allQueries - .Action("Index", "Admin", "OrchardCore.Queries") - .AddClass("searchallqueries") - .Id("searchallqueries") - .Permission(Permissions.ManageQueries) - .LocalNav() + .Action("Index", "Admin", "OrchardCore.Queries") + .AddClass("searchallqueries") + .Id("searchallqueries") + .Permission(Permissions.ManageQueries) + .LocalNav() ) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Queries/Sql/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Queries/Sql/AdminMenu.cs index f87303e6b57..c4532e21cad 100644 --- a/src/OrchardCore.Modules/OrchardCore.Queries/Sql/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Queries/Sql/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -30,6 +30,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.ReCaptcha/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.ReCaptcha/AdminMenu.cs index 4efc9c37dfc..5750dc38b9e 100644 --- a/src/OrchardCore.Modules/OrchardCore.ReCaptcha/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.ReCaptcha/AdminMenu.cs @@ -20,11 +20,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -38,6 +38,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Recipes/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Recipes/AdminMenu.cs index c1c7e0de56f..ecee693eab4 100644 --- a/src/OrchardCore.Modules/OrchardCore.Recipes/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Recipes/AdminMenu.cs @@ -13,11 +13,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -31,6 +31,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.ReverseProxy/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.ReverseProxy/AdminMenu.cs index 6d6d00c3a90..4920b5f1037 100644 --- a/src/OrchardCore.Modules/OrchardCore.ReverseProxy/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.ReverseProxy/AdminMenu.cs @@ -20,11 +20,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -40,6 +40,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Roles/AdminMenu.cs index 7b53d3ac915..4170f21efa6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -29,6 +29,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/AdminMenu.cs index 74bcc90c853..b50b61278e6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/AdminMenu.cs @@ -13,11 +13,11 @@ public sealed class AdminMenu( internal readonly IStringLocalizer S = stringLocalizer; private readonly AzureAISearchDefaultOptions _azureAISearchSettings = azureAISearchSettings.Value; - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!string.Equals(name, "admin", StringComparison.OrdinalIgnoreCase)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -51,6 +51,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ); } - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/AdminMenu.cs index e989b82da0a..0fdbfb8a77b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/AdminMenu.cs @@ -7,11 +7,11 @@ public sealed class AdminMenu(IStringLocalizer localizer) : INavigati { internal readonly IStringLocalizer S = localizer; - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -38,6 +38,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/AdminMenu.cs index 0ae37f156a1..90538bf755d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/AdminMenu.cs @@ -7,11 +7,11 @@ public sealed class AdminMenu(IStringLocalizer localizer) : INavigati { internal readonly IStringLocalizer S = localizer; - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -38,6 +38,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Search/AdminMenu.cs index f5d6b053262..a9dfe5388ed 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search/AdminMenu.cs @@ -19,11 +19,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -39,6 +39,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Security/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Security/AdminMenu.cs index 0365ddd1a0f..10e52b21a6d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Security/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Security/AdminMenu.cs @@ -21,11 +21,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -41,6 +41,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Seo/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Seo/AdminMenu.cs index 952e6a93b4e..ab641c3bbe6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Seo/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Seo/AdminMenu.cs @@ -19,11 +19,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -39,6 +39,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Settings/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Settings/AdminMenu.cs index 99e7c9d2fba..1f646c33939 100644 --- a/src/OrchardCore.Modules/OrchardCore.Settings/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Settings/AdminMenu.cs @@ -20,11 +20,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -42,6 +42,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) priority: 1) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Shortcodes/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Shortcodes/AdminMenu.cs index ea3e9efd93e..3f9eccf8a62 100644 --- a/src/OrchardCore.Modules/OrchardCore.Shortcodes/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Shortcodes/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -28,6 +28,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Sitemaps/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Sitemaps/AdminMenu.cs index 8a358411a1d..38dc624db8e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sitemaps/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sitemaps/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -38,6 +38,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Sms/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Sms/AdminMenu.cs index 9c9751907ed..cd716d610b4 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sms/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sms/AdminMenu.cs @@ -21,11 +21,11 @@ public AdminMenu(IStringLocalizer stringLocalizer) S = stringLocalizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -48,6 +48,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Taxonomies/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Taxonomies/AdminMenu.cs index 3799d6b87ac..72779f3ae02 100644 --- a/src/OrchardCore.Modules/OrchardCore.Taxonomies/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Taxonomies/AdminMenu.cs @@ -20,11 +20,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -40,6 +40,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Templates/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Templates/AdminMenu.cs index 725efe55903..31fd6bb4029 100644 --- a/src/OrchardCore.Modules/OrchardCore.Templates/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Templates/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -28,6 +28,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Templates/AdminTemplatesAdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Templates/AdminTemplatesAdminMenu.cs index a1c2653ea6a..bc6d01e2b06 100644 --- a/src/OrchardCore.Modules/OrchardCore.Templates/AdminTemplatesAdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Templates/AdminTemplatesAdminMenu.cs @@ -12,11 +12,11 @@ public AdminTemplatesAdminMenu(IStringLocalizer localiz S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -28,6 +28,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Tenants/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Tenants/AdminMenu.cs index 8bac59d0bc7..d18f0bc28db 100644 --- a/src/OrchardCore.Modules/OrchardCore.Tenants/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Tenants/AdminMenu.cs @@ -16,17 +16,17 @@ public AdminMenu(IStringLocalizer localizer, ShellSettings shellSetti S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } // Don't add the menu item on non-default tenants if (!_shellSettings.IsDefaultShell()) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -40,6 +40,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ), priority: 1); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Tenants/FeatureProfilesAdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Tenants/FeatureProfilesAdminMenu.cs index db6bf5ac87e..114eb2049e1 100644 --- a/src/OrchardCore.Modules/OrchardCore.Tenants/FeatureProfilesAdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Tenants/FeatureProfilesAdminMenu.cs @@ -10,23 +10,25 @@ public sealed class FeatureProfilesAdminMenu : INavigationProvider internal readonly IStringLocalizer S; - public FeatureProfilesAdminMenu(IStringLocalizer localizer, ShellSettings shellSettings) + public FeatureProfilesAdminMenu( + IStringLocalizer localizer, + ShellSettings shellSettings) { _shellSettings = shellSettings; S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } - // Don't add the menu item on non-default tenants + // Don't add the menu item on non-default tenants. if (!_shellSettings.IsDefaultShell()) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -39,6 +41,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Themes/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Themes/AdminMenu.cs index 7eb63fe9feb..5d799b679ef 100644 --- a/src/OrchardCore.Modules/OrchardCore.Themes/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Themes/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -29,6 +29,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Twitter/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Twitter/AdminMenu.cs new file mode 100644 index 00000000000..7b5344f8c25 --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Twitter/AdminMenu.cs @@ -0,0 +1,43 @@ +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Localization; +using OrchardCore.Navigation; + +namespace OrchardCore.Twitter; + +public sealed class AdminMenu : INavigationProvider +{ + private static readonly RouteValueDictionary _routeValues = new() + { + { "area", "OrchardCore.Settings" }, + { "groupId", TwitterConstants.Features.Twitter }, + }; + + internal readonly IStringLocalizer S; + + public AdminMenu(IStringLocalizer localizer) + { + S = localizer; + } + + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) + { + if (!NavigationHelper.IsAdminMenu(name)) + { + return ValueTask.CompletedTask; + } + + builder + .Add(S["Configuration"], configuration => configuration + .Add(S["Settings"], settings => settings + .Add(S["X (Twitter)"], S["X (Twitter)"].PrefixPosition(), twitter => twitter + .AddClass("twitter").Id("twitter") + .Action("Index", "Admin", _routeValues) + .Permission(Permissions.ManageTwitter) + .LocalNav() + ) + ) + ); + + return ValueTask.CompletedTask; + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Twitter/AdminMenuSignin.cs b/src/OrchardCore.Modules/OrchardCore.Twitter/AdminMenuSignin.cs index 1add9f36949..4b64b669bad 100644 --- a/src/OrchardCore.Modules/OrchardCore.Twitter/AdminMenuSignin.cs +++ b/src/OrchardCore.Modules/OrchardCore.Twitter/AdminMenuSignin.cs @@ -19,11 +19,11 @@ public AdminMenuSignin(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -38,44 +38,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; - } -} - -public sealed class AdminMenu : INavigationProvider -{ - private static readonly RouteValueDictionary _routeValues = new() - { - { "area", "OrchardCore.Settings" }, - { "groupId", TwitterConstants.Features.Twitter }, - }; - - internal readonly IStringLocalizer S; - - public AdminMenu(IStringLocalizer localizer) - { - S = localizer; - } - - public Task BuildNavigationAsync(string name, NavigationBuilder builder) - { - if (!NavigationHelper.IsAdminMenu(name)) - { - return Task.CompletedTask; - } - - builder - .Add(S["Configuration"], configuration => configuration - .Add(S["Settings"], settings => settings - .Add(S["X (Twitter)"], S["X (Twitter)"].PrefixPosition(), twitter => twitter - .AddClass("twitter").Id("twitter") - .Action("Index", "Admin", _routeValues) - .Permission(Permissions.ManageTwitter) - .LocalNav() - ) - ) - ); - - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Users/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Users/AdminMenu.cs index cdcb2cddb57..9c2a4159813 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/AdminMenu.cs @@ -21,11 +21,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -49,117 +49,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; - } -} - -public sealed class ChangeEmailAdminMenu : INavigationProvider -{ - private static readonly RouteValueDictionary _routeValues = new() - { - { "area", "OrchardCore.Settings" }, - { "groupId", ChangeEmailSettingsDisplayDriver.GroupId }, - }; - - internal readonly IStringLocalizer S; - - public ChangeEmailAdminMenu(IStringLocalizer localizer) - { - S = localizer; - } - - public Task BuildNavigationAsync(string name, NavigationBuilder builder) - { - if (!NavigationHelper.IsAdminMenu(name)) - { - return Task.CompletedTask; - } - - builder - .Add(S["Security"], security => security - .Add(S["Settings"], settings => settings - .Add(S["User Change email"], S["User Change email"].PrefixPosition(), email => email - .Permission(CommonPermissions.ManageUsers) - .Action("Index", "Admin", _routeValues) - .LocalNav() - ) - ) - ); - - return Task.CompletedTask; - } -} - -public sealed class RegistrationAdminMenu : INavigationProvider -{ - private static readonly RouteValueDictionary _routeValues = new() - { - { "area", "OrchardCore.Settings" }, - { "groupId", RegistrationSettingsDisplayDriver.GroupId }, - }; - - internal readonly IStringLocalizer S; - - public RegistrationAdminMenu(IStringLocalizer localizer) - { - S = localizer; - } - - public Task BuildNavigationAsync(string name, NavigationBuilder builder) - { - if (!NavigationHelper.IsAdminMenu(name)) - { - return Task.CompletedTask; - } - - builder - .Add(S["Security"], security => security - .Add(S["Settings"], settings => settings - .Add(S["User Registration"], S["User Registration"].PrefixPosition(), registration => registration - .Permission(CommonPermissions.ManageUsers) - .Action("Index", "Admin", _routeValues) - .LocalNav() - ) - ) - ); - - return Task.CompletedTask; - } -} - -public sealed class ResetPasswordAdminMenu : INavigationProvider -{ - private static readonly RouteValueDictionary _routeValues = new() - { - { "area", "OrchardCore.Settings" }, - { "groupId", ResetPasswordSettingsDisplayDriver.GroupId }, - }; - - internal readonly IStringLocalizer S; - - public ResetPasswordAdminMenu(IStringLocalizer localizer) - { - S = localizer; - } - - public Task BuildNavigationAsync(string name, NavigationBuilder builder) - { - if (!NavigationHelper.IsAdminMenu(name)) - { - return Task.CompletedTask; - } - - builder - .Add(S["Security"], security => security - .Add(S["Settings"], settings => settings - .Add(S["User Reset password"], S["User Reset password"].PrefixPosition(), password => password - .Permission(CommonPermissions.ManageUsers) - .Action("Index", "Admin", _routeValues) - .LocalNav() - ) - ) - ); - - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Users/ChangeEmailAdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Users/ChangeEmailAdminMenu.cs new file mode 100644 index 00000000000..b6a9cc6c54b --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Users/ChangeEmailAdminMenu.cs @@ -0,0 +1,43 @@ +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Localization; +using OrchardCore.Navigation; +using OrchardCore.Users.Drivers; + +namespace OrchardCore.Users; + +public sealed class ChangeEmailAdminMenu : INavigationProvider +{ + private static readonly RouteValueDictionary _routeValues = new() + { + { "area", "OrchardCore.Settings" }, + { "groupId", ChangeEmailSettingsDisplayDriver.GroupId }, + }; + + internal readonly IStringLocalizer S; + + public ChangeEmailAdminMenu(IStringLocalizer localizer) + { + S = localizer; + } + + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) + { + if (!NavigationHelper.IsAdminMenu(name)) + { + return ValueTask.CompletedTask; + } + + builder + .Add(S["Security"], security => security + .Add(S["Settings"], settings => settings + .Add(S["User Change email"], S["User Change email"].PrefixPosition(), email => email + .Permission(CommonPermissions.ManageUsers) + .Action("Index", "Admin", _routeValues) + .LocalNav() + ) + ) + ); + + return ValueTask.CompletedTask; + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Users/RegistrationAdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Users/RegistrationAdminMenu.cs new file mode 100644 index 00000000000..cffef43f061 --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Users/RegistrationAdminMenu.cs @@ -0,0 +1,43 @@ +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Localization; +using OrchardCore.Navigation; +using OrchardCore.Users.Drivers; + +namespace OrchardCore.Users; + +public sealed class RegistrationAdminMenu : INavigationProvider +{ + private static readonly RouteValueDictionary _routeValues = new() + { + { "area", "OrchardCore.Settings" }, + { "groupId", RegistrationSettingsDisplayDriver.GroupId }, + }; + + internal readonly IStringLocalizer S; + + public RegistrationAdminMenu(IStringLocalizer localizer) + { + S = localizer; + } + + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) + { + if (!NavigationHelper.IsAdminMenu(name)) + { + return ValueTask.CompletedTask; + } + + builder + .Add(S["Security"], security => security + .Add(S["Settings"], settings => settings + .Add(S["User Registration"], S["User Registration"].PrefixPosition(), registration => registration + .Permission(CommonPermissions.ManageUsers) + .Action("Index", "Admin", _routeValues) + .LocalNav() + ) + ) + ); + + return ValueTask.CompletedTask; + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Users/ResetPasswordAdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Users/ResetPasswordAdminMenu.cs new file mode 100644 index 00000000000..7b609d1606f --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Users/ResetPasswordAdminMenu.cs @@ -0,0 +1,43 @@ +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Localization; +using OrchardCore.Navigation; +using OrchardCore.Users.Drivers; + +namespace OrchardCore.Users; + +public sealed class ResetPasswordAdminMenu : INavigationProvider +{ + private static readonly RouteValueDictionary _routeValues = new() + { + { "area", "OrchardCore.Settings" }, + { "groupId", ResetPasswordSettingsDisplayDriver.GroupId }, + }; + + internal readonly IStringLocalizer S; + + public ResetPasswordAdminMenu(IStringLocalizer localizer) + { + S = localizer; + } + + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) + { + if (!NavigationHelper.IsAdminMenu(name)) + { + return ValueTask.CompletedTask; + } + + builder + .Add(S["Security"], security => security + .Add(S["Settings"], settings => settings + .Add(S["User Reset password"], S["User Reset password"].PrefixPosition(), password => password + .Permission(CommonPermissions.ManageUsers) + .Action("Index", "Admin", _routeValues) + .LocalNav() + ) + ) + ); + + return ValueTask.CompletedTask; + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/AdminMenu.cs index 576bd49705b..b598e86535e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/AdminMenu.cs @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer localizer) S = localizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -28,6 +28,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) .LocalNav() ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Trimming/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Trimming/AdminMenu.cs index d50904907d2..48a90aeb162 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Trimming/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Trimming/AdminMenu.cs @@ -20,11 +20,11 @@ public AdminMenu(IStringLocalizer stringLocalizer) S = stringLocalizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder.Add(S["Configuration"], configuration => configuration @@ -37,6 +37,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder) ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/OrchardCore/OrchardCore.Navigation.Core/INavigationProvider.cs b/src/OrchardCore/OrchardCore.Navigation.Core/INavigationProvider.cs index 2e5d1a9485b..27352c60ad9 100644 --- a/src/OrchardCore/OrchardCore.Navigation.Core/INavigationProvider.cs +++ b/src/OrchardCore/OrchardCore.Navigation.Core/INavigationProvider.cs @@ -3,5 +3,5 @@ namespace OrchardCore.Navigation; public interface INavigationProvider { - Task BuildNavigationAsync(string name, NavigationBuilder builder); + ValueTask BuildNavigationAsync(string name, NavigationBuilder builder); } diff --git a/src/docs/guides/add-admin-menu/README.md b/src/docs/guides/add-admin-menu/README.md index 0134b00a80c..bbe6ca0da74 100644 --- a/src/docs/guides/add-admin-menu/README.md +++ b/src/docs/guides/add-admin-menu/README.md @@ -62,20 +62,19 @@ using System.Text; using System.Threading.Tasks; using OrchardCore.Admin; -namespace MyModule.Controllers +namespace MyModule.Controllers; + +[Admin] +public sealed class DemoNavController : Controller { - [Admin] - public sealed class DemoNavController : Controller + public ActionResult ChildOne() { - public ActionResult ChildOne() - { - return View(); - } + return View(); + } - public ActionResult ChildTwo() - { - return View(); - } + public ActionResult ChildTwo() + { + return View(); } } ``` @@ -113,36 +112,35 @@ using System.Threading.Tasks; using Microsoft.Extensions.Localization; using OrchardCore.Navigation; -namespace MyModule +namespace MyModule; + +public sealed class AdminMenu : INavigationProvider { - public sealed class AdminMenu : INavigationProvider + internal readonly IStringLocalizer S; + + public AdminMenu(IStringLocalizer localizer) { - internal readonly IStringLocalizer S; + S = localizer; + } - public AdminMenu(IStringLocalizer localizer) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) + { + // We want to add our menus to the "admin" menu only. + if (!String.Equals(name, "admin", StringComparison.OrdinalIgnoreCase)) { - S = localizer; + return ValueTask.CompletedTask; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) - { - // We want to add our menus to the "admin" menu only. - if (!String.Equals(name, "admin", StringComparison.OrdinalIgnoreCase)) - { - return Task.CompletedTask; - } - - // Adding our menu items to the builder. - // The builder represents the full admin menu tree. - builder - .Add(S["My Root View"], S["My Root View"].PrefixPosition(), rootView => rootView - .Add(S["Child One"], S["Child One"].PrefixPosition(), childOne => childOne - .Action("ChildOne", "DemoNav", new { area = "MyModule"})) - .Add(S["Child Two"], S["Child Two"].PrefixPosition(), childTwo => childTwo - .Action("ChildTwo", "DemoNav", new { area = "MyModule"}))); - - return Task.CompletedTask; - } + // Adding our menu items to the builder. + // The builder represents the full admin menu tree. + builder + .Add(S["My Root View"], S["My Root View"].PrefixPosition(), rootView => rootView + .Add(S["Child One"], S["Child One"].PrefixPosition(), childOne => childOne + .Action("ChildOne", "DemoNav", new { area = "MyModule"})) + .Add(S["Child Two"], S["Child Two"].PrefixPosition(), childTwo => childTwo + .Action("ChildTwo", "DemoNav", new { area = "MyModule"}))); + + return ValueTask.CompletedTask; } } ``` @@ -161,7 +159,7 @@ using OrchardCore.Navigation; Add this line to the `ConfigureServices()` method: ```csharp -services.AddScoped(); +services.AddNavigationProvider(); ``` ## Testing the resulting application diff --git a/src/docs/reference/modules/Navigation/README.md b/src/docs/reference/modules/Navigation/README.md index 9752455ea51..2c3bbcb45e2 100644 --- a/src/docs/reference/modules/Navigation/README.md +++ b/src/docs/reference/modules/Navigation/README.md @@ -155,19 +155,21 @@ public sealed class MainMenu : INavigationProvider S = localizer; } - public async Task BuildNavigation(string name, NavigationBuilder builder) + public ValueTask BuildNavigation(string name, NavigationBuilder builder) { //Only interact with the "main" navigation menu here. if (!String.Equals(name, "main", StringComparison.OrdinalIgnoreCase)) { - return; + return ValueTask.CompletedTask; } builder - .Add(S["Notifications"], S["Notifications"], layers => layers - .Action("Index", "Template", new { area = "CRT.Client.OrchardModules.CommunicationTemplates", groupId = 1 }) + .Add(S["Notifications"], S["Notifications"], notifications => notifications + .Action("Index", "Template", new { area = "CRT.Client.OrchardModules.CommunicationTemplates", groupId = "1" }) .LocalNav() ); + + return ValueTask.CompletedTask; } } ``` diff --git a/src/docs/releases/2.0.0.md b/src/docs/releases/2.0.0.md index 14eb83837c2..97c16209904 100644 --- a/src/docs/releases/2.0.0.md +++ b/src/docs/releases/2.0.0.md @@ -399,6 +399,10 @@ Previously, the `CreateContentTask`, `RetrieveContentTask`, and `UpdateContentTa Additionally, a new workflow-scoped script function `setCorrelationId(id:string): void` was added, that you can use to update the workflow's CorrelationId. +### Navigations Module + +The `BuildNavigationAsync` method in the `INavigationProvider` interface was optimized by changing its return type from `Task` to `ValueTask`. + ## Change Logs @@ -499,11 +503,11 @@ public sealed class AdminMenu : INavigationProvider S = stringLocalizer; } - public Task BuildNavigationAsync(string name, NavigationBuilder builder) + public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder) { if (!NavigationHelper.IsAdminMenu(name)) { - return Task.CompletedTask; + return ValueTask.CompletedTask; } builder @@ -519,12 +523,12 @@ public sealed class AdminMenu : INavigationProvider ) ); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } ``` -A new extension has been introduced to simplify the registration of navigation providers. Instead of using `services.AddScoped()`, you can now register it with the more streamlined `services.AddNavigationProvider();`. +A new extension has been introduced to simplify the registration of navigation providers. Instead of using `services.AddNavigationProvider()`, you can now register it with the more streamlined `services.AddNavigationProvider();`. ### Admin Routes