Skip to content

Commit

Permalink
Feat #699 One tab bar for the whole app and not per view (#707)
Browse files Browse the repository at this point in the history
Server Admin and Reference Data pages are also tabbed now
  • Loading branch information
joao4all authored Jul 22, 2024
1 parent ff3b206 commit 77023f0
Show file tree
Hide file tree
Showing 26 changed files with 457 additions and 134 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ReferenceDataPageTestFixture.cs" company="Starion Group S.A.">
// <copyright file="ReferenceDataBodyTestFixture.cs" company="Starion Group S.A.">
// Copyright (c) 2024 Starion Group S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
Expand All @@ -22,7 +22,7 @@
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMETwebapp.Tests.Pages.ReferenceData
namespace COMETwebapp.Tests.Components.ReferenceData
{
using Bunit;

Expand All @@ -32,11 +32,11 @@ namespace COMETwebapp.Tests.Pages.ReferenceData
using COMET.Web.Common.Services.ConfigurationService;
using COMET.Web.Common.Services.SessionManagement;
using COMET.Web.Common.Test.Helpers;
using COMET.Web.Common.ViewModels.Components.Applications;

using COMETwebapp.Components.ReferenceData;
using COMETwebapp.Components.ReferenceData.MeasurementScales;
using COMETwebapp.Components.ReferenceData.ParameterTypes;
using COMETwebapp.Pages.ReferenceData;
using COMETwebapp.ViewModels.Components.ReferenceData;
using COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales;
using COMETwebapp.ViewModels.Components.ReferenceData.ParameterTypes;
using COMETwebapp.ViewModels.Components.ReferenceData.Rows;
Expand All @@ -53,13 +53,13 @@ namespace COMETwebapp.Tests.Pages.ReferenceData
using TestContext = Bunit.TestContext;

[TestFixture]
public class ReferenceDataPageTestFixture
public class ReferenceDataBodyTestFixture
{
private TestContext context;
private Mock<IParameterTypeTableViewModel> parameterTypesTableViewModel;
private Mock<IMeasurementScalesTableViewModel> measurementScalesTableViewModel;
private Mock<ISessionService> sessionService;
private IRenderedComponent<ReferenceDataPage> renderer;
private IRenderedComponent<ReferenceDataBody> renderer;

[SetUp]
public void Setup()
Expand All @@ -83,9 +83,9 @@ public void Setup()
this.context.Services.AddSingleton(this.parameterTypesTableViewModel.Object);
this.context.Services.AddSingleton(this.measurementScalesTableViewModel.Object);
this.context.Services.AddSingleton(configuration.Object);
this.context.Services.AddSingleton<IApplicationTemplateViewModel, ApplicationTemplateViewModel>();
this.context.Services.AddSingleton(new Mock<IReferenceDataBodyViewModel>().Object);

this.renderer = this.context.RenderComponent<ReferenceDataPage>();
this.renderer = this.context.RenderComponent<ReferenceDataBody>();
}

[TearDown]
Expand All @@ -95,7 +95,7 @@ public void Teardown()
}

[Test]
public async Task VerifyReferenceDataPage()
public async Task VerifyReferenceDataBody()
{
Assert.Multiple(() =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SiteDirectoryPageTestFixture.cs" company="Starion Group S.A.">
// <copyright file="SiteDirectoryBodyTestFixture.cs" company="Starion Group S.A.">
// Copyright (c) 2024 Starion Group S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
Expand All @@ -22,7 +22,7 @@
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMETwebapp.Tests.Pages.SiteDirectory
namespace COMETwebapp.Tests.Components.SiteDirectory
{
using Bunit;

Expand All @@ -32,11 +32,10 @@ namespace COMETwebapp.Tests.Pages.SiteDirectory
using COMET.Web.Common.Services.ConfigurationService;
using COMET.Web.Common.Services.SessionManagement;
using COMET.Web.Common.Test.Helpers;
using COMET.Web.Common.ViewModels.Components.Applications;

using COMETwebapp.Components.SiteDirectory;
using COMETwebapp.Components.SiteDirectory.EngineeringModel;
using COMETwebapp.Pages.SiteDirectory;
using COMETwebapp.ViewModels.Components.SiteDirectory;
using COMETwebapp.ViewModels.Components.SiteDirectory.DomainsOfExpertise;
using COMETwebapp.ViewModels.Components.SiteDirectory.EngineeringModels;
using COMETwebapp.ViewModels.Components.SiteDirectory.Rows;
Expand All @@ -53,13 +52,13 @@ namespace COMETwebapp.Tests.Pages.SiteDirectory
using TestContext = Bunit.TestContext;

[TestFixture]
public class SiteDirectoryPageTestFixture
public class SiteDirectoryBodyTestFixture
{
private TestContext context;
private Mock<IEngineeringModelsTableViewModel> engineeringModelsTableViewModel;
private Mock<IDomainsOfExpertiseTableViewModel> domainsOfExpertiseTableViewModel;
private Mock<ISessionService> sessionService;
private IRenderedComponent<DirectoryPage> renderer;
private IRenderedComponent<SiteDirectoryBody> renderer;

[SetUp]
public void Setup()
Expand All @@ -83,9 +82,9 @@ public void Setup()
this.context.Services.AddSingleton(this.engineeringModelsTableViewModel.Object);
this.context.Services.AddSingleton(this.domainsOfExpertiseTableViewModel.Object);
this.context.Services.AddSingleton(configuration.Object);
this.context.Services.AddSingleton<IApplicationTemplateViewModel, ApplicationTemplateViewModel>();
this.context.Services.AddSingleton(new Mock<ISiteDirectoryBodyViewModel>().Object);

this.renderer = this.context.RenderComponent<DirectoryPage>();
this.renderer = this.context.RenderComponent<SiteDirectoryBody>();
}

[TearDown]
Expand All @@ -95,7 +94,7 @@ public void Teardown()
}

[Test]
public async Task VerifySiteDirectoryPage()
public async Task VerifySiteDirectoryBody()
{
Assert.Multiple(() =>
{
Expand Down
5 changes: 2 additions & 3 deletions COMETwebapp.Tests/Pages/TabsTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@ public async Task VerifyTabCustomButton()
tabToOpen = new TabbedApplicationInformation(this.engineeringModelBodyViewModel.Object, typeof(EngineeringModelBody), null);
openTabs.ReplaceAt(0, tabToOpen);
this.renderer.Render();
tabCustomButton = this.renderer.FindComponents<DxButton>().First(x => x.Instance.Id == "tab-custom-option-button");
await this.renderer.InvokeAsync(tabCustomButton.Instance.Click.InvokeAsync);
Assert.That(this.renderer.Instance.IsOpenTabVisible, Is.False);
var hasCustomOption = this.renderer.FindComponents<DxButton>().Any(x => x.Instance.Id == "tab-custom-option-button");
Assert.That(hasCustomOption, Is.False);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public async Task VerifyOpenIterationAndModel()

Assert.Multiple(() =>
{
this.tabsViewModel.Verify(x => x.CreateNewTab(It.IsAny<TabbedApplication>(), It.IsAny<Guid>(), It.IsAny<TabPanelInformation>()), Times.Once);
this.tabsViewModel.Verify(x => x.CreateNewTab(It.IsAny<TabbedApplication>(), It.IsAny<Guid>(), It.IsAny<TabPanelInformation>()), Times.Exactly(2));
this.sessionService.Verify(x => x.ReadIteration(It.IsAny<IterationSetup>(), It.IsAny<DomainOfExpertise>()), Times.Once);
});

Expand Down
42 changes: 42 additions & 0 deletions COMETwebapp/Components/ReferenceData/ReferenceDataBody.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!------------------------------------------------------------------------------
// Copyright (c) 2023-2024 Starion Group S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua
//
// This file is part of CDP4-COMET WEB Community Edition
// The CDP4-COMET WEB Community Edition is the Starion Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
//
// The CDP4-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 CDP4-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/.
------------------------------------------------------------------------------->
@inherits ApplicationBase<COMETwebapp.ViewModels.Components.ReferenceData.IReferenceDataBodyViewModel>

<LoadingComponent IsVisible="@(this.ViewModel.IsLoading)">
<DxToolbar ItemClick="@(this.OnItemClick)">
<Items>
@foreach (var mappedValue in this.mapOfComponentsAndNames)
{
<DxToolbarItem @key="@(mappedValue.Value)"
Name="@(mappedValue.Value)"
Text="@(mappedValue.Value)"
Tooltip="@(mappedValue.Value)"
RenderStyle="@(mappedValue.Key == this.SelectedComponent ? ButtonRenderStyle.Primary : ButtonRenderStyle.Secondary)"/>
}
</Items>
</DxToolbar>

@if (this.SelectedComponent != null)
{
<DynamicComponent Type="@(this.SelectedComponent)"/>
}
</LoadingComponent>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ReferenceDataPage.razor.cs" company="Starion Group S.A.">
// <copyright file="ReferenceDataBody.razor.cs" company="Starion Group S.A.">
// Copyright (c) 2024 Starion Group S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
Expand All @@ -22,7 +22,7 @@
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMETwebapp.Pages.ReferenceData
namespace COMETwebapp.Components.ReferenceData
{
using COMETwebapp.Components.ReferenceData.Categories;
using COMETwebapp.Components.ReferenceData.MeasurementScales;
Expand All @@ -32,9 +32,9 @@ namespace COMETwebapp.Pages.ReferenceData
using DevExpress.Blazor;

/// <summary>
/// Support class for the <see cref="ReferenceDataPage" />
/// Core component for the Reference Data body application
/// </summary>
public partial class ReferenceDataPage
public partial class ReferenceDataBody
{
/// <summary>
/// A map with all the available components and their names
Expand Down Expand Up @@ -70,5 +70,13 @@ private void OnItemClick(ToolbarItemClickEventArgs e)
{
this.SelectedComponent = this.mapOfComponentsAndNames.First(x => x.Value == e.ItemName).Key;
}

/// <summary>
/// Initializes values of the component and of the ViewModel based on parameters provided from the url
/// </summary>
/// <param name="parameters">A <see cref="Dictionary{TKey,TValue}" /> for parameters</param>
protected override void InitializeValues(Dictionary<string, string> parameters)
{
}
}
}
42 changes: 42 additions & 0 deletions COMETwebapp/Components/SiteDirectory/SiteDirectoryBody.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!------------------------------------------------------------------------------
// Copyright (c) 2023-2024 Starion Group S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua
//
// This file is part of CDP4-COMET WEB Community Edition
// The CDP4-COMET WEB Community Edition is the Starion Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
//
// The CDP4-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 CDP4-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/.
------------------------------------------------------------------------------->
@inherits ApplicationBase<COMETwebapp.ViewModels.Components.SiteDirectory.ISiteDirectoryBodyViewModel>

<LoadingComponent IsVisible="@(this.ViewModel.IsLoading)">
<DxToolbar ItemClick="@(this.OnItemClick)">
<Items>
@foreach (var mappedValue in this.mapOfComponentsAndNames)
{
<DxToolbarItem @key="@(mappedValue.Value)"
Name="@(mappedValue.Value)"
Text="@(mappedValue.Value)"
Tooltip="@(mappedValue.Value)"
RenderStyle="@(mappedValue.Key == this.SelectedComponent ? ButtonRenderStyle.Primary : ButtonRenderStyle.Secondary)"/>
}
</Items>
</DxToolbar>

@if (this.SelectedComponent != null)
{
<DynamicComponent Type="@(this.SelectedComponent)"/>
}
</LoadingComponent>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DirectoryPage.razor.cs" company="Starion Group S.A.">
// <copyright file="SiteDirectoryBody.razor.cs" company="Starion Group S.A.">
// Copyright (c) 2024 Starion Group S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
Expand All @@ -22,21 +22,18 @@
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMETwebapp.Pages.SiteDirectory
namespace COMETwebapp.Components.SiteDirectory
{
using COMETwebapp.Components.SiteDirectory;
using COMETwebapp.Components.SiteDirectory.EngineeringModel;
using COMETwebapp.Components.SiteDirectory.Roles;
using COMETwebapp.Components.SiteDirectory.UserManagement;

using DevExpress.Blazor;

using DomainsOfExpertiseTable = COMETwebapp.Components.SiteDirectory.DomainsOfExpertiseTable;

/// <summary>
/// Support class for the <see cref="DirectoryPage" />
/// Core component for the Server Admin (old Site Directory) body application
/// </summary>
public partial class DirectoryPage
public partial class SiteDirectoryBody
{
/// <summary>
/// A map with all the available components and their names
Expand Down Expand Up @@ -66,6 +63,14 @@ protected override void OnInitialized()
this.SelectedComponent = this.mapOfComponentsAndNames.First().Key;
}

/// <summary>
/// Initializes values of the component and of the ViewModel based on parameters provided from the url
/// </summary>
/// <param name="parameters">A <see cref="Dictionary{TKey,TValue}" /> for parameters</param>
protected override void InitializeValues(Dictionary<string, string> parameters)
{
}

/// <summary>
/// Method invoked to set the selected component from toolbar
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion COMETwebapp/Components/Tabs/TabComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<span>@(this.Text)</span>

@if (this.CustomOptionIcon is not null)
@if (this.CustomOptionIcon is not null && this.CustomOptionIconVisible)
{
<DxButton RenderStyle="ButtonRenderStyle.None"
Click="@(() => this.OnCustomOptionIconClick?.Invoke())"
Expand Down
6 changes: 6 additions & 0 deletions COMETwebapp/Components/Tabs/TabComponent.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public partial class TabComponent : DisposableComponent
[Parameter]
public Type CustomOptionIcon { get; set; }

/// <summary>
/// Gets or sets the condition to check if the <see cref="CustomOptionIcon"/> should be visible
/// </summary>
[Parameter]
public bool CustomOptionIconVisible { get; set; } = true;

/// <summary>
/// Gets or sets the icon to be displayed in the left, distinguishing different applications
/// </summary>
Expand Down
Loading

0 comments on commit 77023f0

Please sign in to comment.