Browse Source

Merge pull request #17431 from abpframework/EngincanV/fix-layout-hooks

Fix layout hooks filtering and show layout hooks for the specified layouts
pull/17435/head
maliming 3 years ago
committed by GitHub
parent
commit
253f3855b5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs
  2. 8
      framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/LayoutHookViewComponent.cs
  3. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/ViewComponentHelperLayoutHookExtensions.cs

2
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs

@ -26,7 +26,7 @@ public partial class LayoutHook : ComponentBase
{
layoutHooks = layoutHooks
.Where(IsComponentBase)
.WhereIf(string.IsNullOrWhiteSpace(Layout), x => x.Layout == Layout)
.WhereIf(!string.IsNullOrWhiteSpace(Layout), x => x.Layout == Layout)
.ToList();
}

8
framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/LayoutHookViewComponent.cs

@ -16,10 +16,12 @@ public class LayoutHookViewComponent : AbpViewComponent
Options = options.Value;
}
public virtual IViewComponentResult Invoke(string name, string layout)
public virtual IViewComponentResult Invoke(string name, string? layout)
{
var hooks = Options.Hooks.GetOrDefault(name)?.Where(x => x.Layout == layout && IsViewComponent(x)).ToArray()
?? Array.Empty<LayoutHookInfo>();
var hooks = Options.Hooks.GetOrDefault(name)?
.Where(IsViewComponent)
.WhereIf(!string.IsNullOrWhiteSpace(layout), x => x.Layout == layout)
.ToArray() ?? Array.Empty<LayoutHookInfo>();
return View(
"~/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/Default.cshtml",

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/ViewComponentHelperLayoutHookExtensions.cs

@ -9,7 +9,7 @@ public static class ViewComponentHelperLayoutHookExtensions
public static Task<IHtmlContent> InvokeLayoutHookAsync(
this IViewComponentHelper componentHelper,
string name,
string layout)
string? layout = null)
{
return componentHelper.InvokeAsync(
typeof(LayoutHookViewComponent),

Loading…
Cancel
Save