Skip to content

Commit

Permalink
Add the ability to override the TopMenu component on the MainLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbware committed Oct 9, 2023
1 parent 29f2a48 commit 46c3043
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
5 changes: 5 additions & 0 deletions COMET.Web.Common/Model/GlobalOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public class GlobalOptions
/// Defines the <see cref="Type" /> that should be used as MainLayout
/// </summary>
public Type MainLayoutType { get; set; } = typeof(MainLayout);

/// <summary>
/// Defines the <see cref="Type" /> that should be used as TopMenu
/// </summary>
public Type TopMenuType { get; set; } = typeof(TopMenu);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@ public interface IRegistrationService
/// Gets the <see cref="Type" /> to use as MainLayout for the application
/// </summary>
Type MainLayoutType { get; }

Type TopMenuType { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,19 @@ public RegistrationService(IOptions<GlobalOptions> options)
this.registeredAuthorizedTopMenuEntries.AddRange(options.Value.AdditionalMenuEntries);
this.CustomHeader = options.Value.CustomHeaderTitle;
this.MainLayoutType = options.Value.MainLayoutType;
this.TopMenuType = options.Value.TopMenuType;
}

/// <summary>
/// Gets the <see cref="Type" /> to use as MainLayout for the application
/// </summary>
public Type MainLayoutType { get; }

/// <summary>
/// Gets the <see cref="Type" /> to use as TopMenu for the application
/// </summary>

public Type TopMenuType { get; }

/// <summary>
/// Gets the <see cref="IReadOnlyList{T}" /> of registered <see cref="Assembly" />
Expand Down
13 changes: 10 additions & 3 deletions COMET.Web.Common/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@
</Rows>
<Items>
<DxGridLayoutItem Area="header">
<Template>
<TopMenu />
</Template>
<Template>
@if (this.RegistrationService.TopMenuType != null)
{
<DynamicComponent Type="this.RegistrationService.TopMenuType"/>
}
else
{
<TopMenu />
}
</Template>
</DxGridLayoutItem>
<DxGridLayoutItem Area="content" CssClass="content px-4">
<Template>
Expand Down
42 changes: 42 additions & 0 deletions COMET.Web.Common/Shared/MainLayout.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MainLayout.razor.cs" company="RHEA System S.A.">
// Copyright (c) 2023 RHEA System S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine
//
// This file is part of COMET WEB Community Edition
// The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
//
// The COMET WEB Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The COMET WEB Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMET.Web.Common.Shared
{
using Microsoft.AspNetCore.Components;

using COMET.Web.Common.Services.RegistrationService;

/// <summary>
/// Component used for the main layout
/// </summary>
public partial class MainLayout
{
/// <summary>
/// The <see cref="Services.RegistrationService.IRegistrationService"/>
/// </summary>
[Inject]
internal IRegistrationService RegistrationService { get; set; }
}
}

0 comments on commit 46c3043

Please sign in to comment.