Merge pull request #17438 from abpframework/salihozkara/fixLayout

Fix layout hooks filtering and show layout hooks for the specified layouts
pull/17439/head
Engincan VESKE 2 years ago committed by GitHub
commit 71d23498f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,8 +25,7 @@ public partial class LayoutHook : ComponentBase
if (LayoutHookOptions.Value.Hooks.TryGetValue(Name, out var layoutHooks))
{
layoutHooks = layoutHooks
.Where(IsComponentBase)
.WhereIf(!string.IsNullOrWhiteSpace(Layout), x => x.Layout == Layout)
.Where(x => IsComponentBase(x) && (string.IsNullOrWhiteSpace(x.Layout) || x.Layout == Layout))
.ToList();
}

@ -19,8 +19,7 @@ public class LayoutHookViewComponent : AbpViewComponent
public virtual IViewComponentResult Invoke(string name, string? layout)
{
var hooks = Options.Hooks.GetOrDefault(name)?
.Where(IsViewComponent)
.WhereIf(!string.IsNullOrWhiteSpace(layout), x => x.Layout == layout)
.Where(x => IsViewComponent(x) && (string.IsNullOrWhiteSpace(x.Layout) || x.Layout == layout))
.ToArray() ?? Array.Empty<LayoutHookInfo>();
return View(

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

Loading…
Cancel
Save