Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move UseComponent extension methods to Framework #18726

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/en/UI/Blazor/Basic-Theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;

//...

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading