Browse Source

Merge pull request #18783 from abpframework/liangshiwei/customMenu

Check if the type is a component before rendering
pull/18805/head
Enis Necipoglu 3 years ago
committed by GitHub
parent
commit
468715c0c1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  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 (MenuItem.IsLeaf)
{ {
if (customComponentType != null) if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{ {
<DynamicComponent Type="@customComponentType" /> <DynamicComponent Type="@customComponentType" />
} }
@ -32,7 +32,7 @@ else
{ {
<li class="nav-item"> <li class="nav-item">
<div class="dropdown"> <div class="dropdown">
@if (customComponentType != null) @if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{ {
<DynamicComponent Type="@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 (MenuItem.IsLeaf)
{ {
if (customComponentType != null) if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{ {
<DynamicComponent Type="@customComponentType" /> <DynamicComponent Type="@customComponentType" />
} }
@ -28,7 +28,7 @@
else else
{ {
<div class="dropdown-submenu"> <div class="dropdown-submenu">
@if (customComponentType != null) @if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{ {
<DynamicComponent Type="@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 (menuItem.IsLeaf)
{ {
if (customComponentType != null) if (customComponentType != null && typeof(ViewComponent).IsAssignableFrom(customComponentType))
{ {
@(await Component.InvokeAsync(customComponentType)) @(await Component.InvokeAsync(customComponentType))
} }
@ -34,7 +34,7 @@
{ {
<li class="nav-item"> <li class="nav-item">
<div class="dropdown"> <div class="dropdown">
@if (customComponentType != null) @if (customComponentType != null && typeof(ViewComponent).IsAssignableFrom(customComponentType))
{ {
@(await Component.InvokeAsync(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 (Model.IsLeaf)
{ {
if (customComponentType != null) if (customComponentType != null && typeof(ViewComponent).IsAssignableFrom(customComponentType))
{ {
@(await Component.InvokeAsync(customComponentType)) @(await Component.InvokeAsync(customComponentType))
} }
@ -31,10 +31,10 @@
else else
{ {
<div class="dropdown-submenu"> <div class="dropdown-submenu">
@if (customComponentType != null) @if (customComponentType != null && typeof(ViewComponent).IsAssignableFrom(customComponentType))
{ {
@(await Component.InvokeAsync(customComponentType)) @(await Component.InvokeAsync(customComponentType))
} }
else else
{ {
<a role="button" class="btn dropdown-toggle" data-bs-toggle="dropdown" <a role="button" class="btn dropdown-toggle" data-bs-toggle="dropdown"

Loading…
Cancel
Save