Browse Source

Check if the type is a component before rendering

pull/18783/head
liangshiwei 3 years ago
parent
commit
75598e76ff
  1. 4
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor
  2. 4
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/SecondLevelNavMenuItem.razor
  3. 4
      modules/basic-theme/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/Default.cshtml
  4. 8
      modules/basic-theme/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/_MenuItem.cshtml

4
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor

@ -8,7 +8,7 @@
}
@if (MenuItem.IsLeaf)
{
if (customComponentType != null)
if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{
<DynamicComponent Type="@customComponentType" />
}
@ -32,7 +32,7 @@ else
{
<li class="nav-item">
<div class="dropdown">
@if (customComponentType != null)
@if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{
<DynamicComponent Type="@customComponentType" />
}

4
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/SecondLevelNavMenuItem.razor

@ -8,7 +8,7 @@
}
@if (MenuItem.IsLeaf)
{
if (customComponentType != null)
if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{
<DynamicComponent Type="@customComponentType" />
}
@ -28,7 +28,7 @@
else
{
<div class="dropdown-submenu">
@if (customComponentType != null)
@if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{
<DynamicComponent Type="@customComponentType" />
}

4
modules/basic-theme/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/Default.cshtml

@ -10,7 +10,7 @@
if (menuItem.IsLeaf)
{
if (customComponentType != null)
if (customComponentType != null && typeof(ViewComponent).IsAssignableFrom(customComponentType))
{
@(await Component.InvokeAsync(customComponentType))
}
@ -34,7 +34,7 @@
{
<li class="nav-item">
<div class="dropdown">
@if (customComponentType != null)
@if (customComponentType != null && typeof(ViewComponent).IsAssignableFrom(customComponentType))
{
@(await Component.InvokeAsync(customComponentType))
}

8
modules/basic-theme/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/_MenuItem.cshtml

@ -10,7 +10,7 @@
}
@if (Model.IsLeaf)
{
if (customComponentType != null)
if (customComponentType != null && typeof(ViewComponent).IsAssignableFrom(customComponentType))
{
@(await Component.InvokeAsync(customComponentType))
}
@ -31,10 +31,10 @@
else
{
<div class="dropdown-submenu">
@if (customComponentType != null)
{
@if (customComponentType != null && typeof(ViewComponent).IsAssignableFrom(customComponentType))
{
@(await Component.InvokeAsync(customComponentType))
}
}
else
{
<a role="button" class="btn dropdown-toggle" data-bs-toggle="dropdown"

Loading…
Cancel
Save