Browse Source

Fix layout hooks filtering and show layout hooks for the specified layouts

pull/17431/head
Engincan VESKE 3 years ago
parent
commit
fdc6c4e0e8
  1. 2
      framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs
  2. 6
      framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/LayoutHookViewComponent.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 layoutHooks = layoutHooks
.Where(IsComponentBase) .Where(IsComponentBase)
.WhereIf(string.IsNullOrWhiteSpace(Layout), x => x.Layout == Layout) .WhereIf(!string.IsNullOrWhiteSpace(Layout), x => x.Layout == Layout)
.ToList(); .ToList();
} }

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

@ -18,8 +18,10 @@ public class LayoutHookViewComponent : AbpViewComponent
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() var hooks = Options.Hooks.GetOrDefault(name)?
?? Array.Empty<LayoutHookInfo>(); .Where(IsViewComponent)
.WhereIf(!string.IsNullOrWhiteSpace(layout), x => x.Layout == layout)
.ToArray() ?? Array.Empty<LayoutHookInfo>();
return View( return View(
"~/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/Default.cshtml", "~/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/Default.cshtml",

Loading…
Cancel
Save