Browse Source

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 3 years ago
committed by GitHub
parent
commit
71d23498f5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs
  2. 3
      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

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

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

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

@ -19,8 +19,7 @@ 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)? var hooks = Options.Hooks.GetOrDefault(name)?
.Where(IsViewComponent) .Where(x => IsViewComponent(x) && (string.IsNullOrWhiteSpace(x.Layout) || x.Layout == layout))
.WhereIf(!string.IsNullOrWhiteSpace(layout), x => x.Layout == layout)
.ToArray() ?? Array.Empty<LayoutHookInfo>(); .ToArray() ?? Array.Empty<LayoutHookInfo>();
return View( return View(

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( public static Task<IHtmlContent> InvokeLayoutHookAsync(
this IViewComponentHelper componentHelper, this IViewComponentHelper componentHelper,
string name, string name,
string? layout = null) string layout)
{ {
return componentHelper.InvokeAsync( return componentHelper.InvokeAsync(
typeof(LayoutHookViewComponent), typeof(LayoutHookViewComponent),

Loading…
Cancel
Save