diff --git a/docs/en/UI/Blazor/Basic-Theme.md b/docs/en/UI/Blazor/Basic-Theme.md index e4124d9a2cd..0c3fc83bd0f 100644 --- a/docs/en/UI/Blazor/Basic-Theme.md +++ b/docs/en/UI/Blazor/Basic-Theme.md @@ -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. ### 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 -using Volo.Abp.AspNetCore.Components.Web.BasicTheme.Navigation; +using Volo.Abp.UI.Navigation; //... diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs index 59814ff3be6..5a755f187ab 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs @@ -1,11 +1,13 @@ +using System; using JetBrains.Annotations; using System.Linq; -using Volo.Abp.UI.Navigation; namespace Volo.Abp.UI.Navigation; public static class ApplicationMenuExtensions { + public const string CustomDataComponentKey = "ApplicationMenu.CustomComponent"; + [NotNull] public static ApplicationMenuItem GetAdministration( [NotNull] this ApplicationMenu applicationMenu) @@ -112,4 +114,19 @@ public static IHasMenuGroups SetMenuGroupOrder( 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; + } } diff --git a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Navigation/BasicThemeNavigationExtensions.cs b/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Navigation/BasicThemeNavigationExtensions.cs deleted file mode 100644 index 020709f56c4..00000000000 --- a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Navigation/BasicThemeNavigationExtensions.cs +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor b/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor index 1f469a809a0..070d514cb65 100644 --- a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor +++ b/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor @@ -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 cssClass = string.IsNullOrEmpty(MenuItem.CssClass) ? string.Empty : MenuItem.CssClass; diff --git a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/SecondLevelNavMenuItem.razor b/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/SecondLevelNavMenuItem.razor index 6d9ffb1fea8..2a93e5459e1 100644 --- a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/SecondLevelNavMenuItem.razor +++ b/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.Web.BasicTheme/Themes/Basic/SecondLevelNavMenuItem.razor @@ -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 cssClass = string.IsNullOrEmpty(MenuItem.CssClass) ? string.Empty : MenuItem.CssClass;