Browse Source
Merge pull request #18726 from abpframework/usecomponent
Move UseComponent extension methods to Framework
pull/18730/head
Enis Necipoglu
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
22 additions and
33 deletions
docs/en/UI/Blazor/Basic-Theme.md
framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Navigation/BasicThemeNavigationExtensions.cs
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/SecondLevelNavMenuItem.razor
@ -86,10 +86,10 @@ You can simply override the styles in the Global Styles file of your application
See the [Customization / Overriding Components ](Customization-Overriding-Components.md ) to learn how you can replace components, customize and extend the user interface.
See the [Customization / Overriding Components ](Customization-Overriding-Components.md ) to learn how you can replace components, customize and extend the user interface.
### Overriding the Menu Item
### Overriding the Menu Item
Basic theme supports overriding a single menu item with a custom component. You can create a custom component and call `UseComponent` extension method of Basic Theme in the **MenuContributor** .
Basic theme supports overriding a single menu item with a custom component. You can create a custom component and call `UseComponent` extension method in the **MenuContributor** .
```csharp
```csharp
using Volo.Abp.AspNetCore.Components.Web.BasicTheme .Navigation;
using Volo.Abp.UI .Navigation;
//...
//...
@ -1,11 +1,13 @@
using System ;
using JetBrains.Annotations ;
using JetBrains.Annotations ;
using System.Linq ;
using System.Linq ;
using Volo.Abp.UI.Navigation ;
namespace Volo.Abp.UI.Navigation ;
namespace Volo.Abp.UI.Navigation ;
public static class ApplicationMenuExtensions
public static class ApplicationMenuExtensions
{
{
public const string CustomDataComponentKey = "ApplicationMenu.CustomComponent" ;
[NotNull]
[NotNull]
public static ApplicationMenuItem GetAdministration (
public static ApplicationMenuItem GetAdministration (
[NotNull] this ApplicationMenu applicationMenu )
[NotNull] this ApplicationMenu applicationMenu )
@ -112,4 +114,19 @@ public static class ApplicationMenuExtensions
return menuWithGroups ;
return menuWithGroups ;
}
}
public static ApplicationMenuItem UseComponent ( this ApplicationMenuItem applicationMenuItem , Type componentType )
{
return applicationMenuItem . WithCustomData ( CustomDataComponentKey , componentType ) ;
}
public static Type ? GetComponentTypeOrDefault ( this ApplicationMenuItem applicationMenuItem )
{
if ( applicationMenuItem . CustomData . TryGetValue ( CustomDataComponentKey , out var value ) )
{
return value as Type ;
}
return default ;
}
}
}
@ -1,26 +0,0 @@
using System ;
using JetBrains.Annotations ;
using Volo.Abp.UI.Navigation ;
namespace Volo.Abp.AspNetCore.Components.Web.BasicTheme.Navigation ;
public static class BasicThemeNavigationExtensions
{
public const string CustomDataComponentKey = "BasicTheme.CustomComponent" ;
public static ApplicationMenuItem UseComponent ( this ApplicationMenuItem applicationMenuItem , Type componentType )
{
return applicationMenuItem . WithCustomData ( CustomDataComponentKey , componentType ) ;
}
[CanBeNull]
public static Type GetComponentTypeOrDefault ( this ApplicationMenuItem applicationMenuItem )
{
if ( applicationMenuItem . CustomData . TryGetValue ( CustomDataComponentKey , out object componentType ) )
{
return componentType as Type ;
}
return default ;
}
}
@ -1,5 +1,4 @@
@using Volo.Abp.AspNetCore.Components.Web.BasicTheme.Navigation;
@using Volo.Abp.UI.Navigation
@using Volo.Abp.UI.Navigation
@{
@{
var elementId = MenuItem.ElementId ?? "MenuItem_" + MenuItem.Name.Replace(".", "_");
var elementId = MenuItem.ElementId ?? "MenuItem_" + MenuItem.Name.Replace(".", "_");
var cssClass = string.IsNullOrEmpty(MenuItem.CssClass) ? string.Empty : MenuItem.CssClass;
var cssClass = string.IsNullOrEmpty(MenuItem.CssClass) ? string.Empty : MenuItem.CssClass;
@ -1,5 +1,4 @@
@using Volo.Abp.AspNetCore.Components.Web.BasicTheme.Navigation;
@using Volo.Abp.UI.Navigation
@using Volo.Abp.UI.Navigation
@{
@{
var elementId = MenuItem.ElementId ?? "MenuItem_" + MenuItem.Name.Replace(".", "_");
var elementId = MenuItem.ElementId ?? "MenuItem_" + MenuItem.Name.Replace(".", "_");
var cssClass = string.IsNullOrEmpty(MenuItem.CssClass) ? string.Empty : MenuItem.CssClass;
var cssClass = string.IsNullOrEmpty(MenuItem.CssClass) ? string.Empty : MenuItem.CssClass;