Skip to content

Commit

Permalink
hide configuration menu for AWS Support (#2235)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssgueye2 authored and kbeaugrand committed Jun 22, 2023
1 parent ecc92e9 commit 44aa2f8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
19 changes: 12 additions & 7 deletions src/IoTHub.Portal.Client/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@using Microsoft.AspNetCore.Components.Authorization
@using IoTHub.Portal.Models.v10
@using Blazored.LocalStorage
@using IoTHub.Portal.Shared.Constants
@inject NavigationManager navigationManager
@inject PortalSettings Portal
@inject ILayoutService LayoutService
Expand Down Expand Up @@ -32,13 +33,17 @@
</MudTooltip>
</MudPaper>

<MudPaper Class="d-flex align-center flex-grow-1 gap-4" Elevation="0">
<MudPaper Class="py-4 d-flex flex-1 mud-theme-primary"/><MudNavLink Href="/device-configurations/">Configurations</MudNavLink>
<MudPaper Class="py-4 d-flex flex-1 mud-theme-secondary"/>
<MudTooltip Text="Add device model">
<MudIconButton id="addDeviceConfigurationButton" OnClick="AddDeviceConfig" Color="Color.Secondary" Icon="@Icons.Material.Filled.AddCircle" Size="Size.Small"/>
</MudTooltip>
</MudPaper>
@if (Portal.CloudProvider.Equals(CloudProviders.Azure))
{
<MudPaper Class="d-flex align-center flex-grow-1 gap-4" Elevation="0">
<MudPaper Class="py-4 d-flex flex-1 mud-theme-primary" /><MudNavLink Href="/device-configurations/">Configurations</MudNavLink>
<MudPaper Class="py-4 d-flex flex-1 mud-theme-secondary" />
<MudTooltip Text="Add device configuration">
<MudIconButton id="addDeviceConfigurationButton" OnClick="AddDeviceConfig" Color="Color.Secondary" Icon="@Icons.Material.Filled.AddCircle" Size="Size.Small" />
</MudTooltip>
</MudPaper>
}

</MudNavGroup>

<MudNavGroup Title="IoT Edge" Icon="@Icons.Material.Outlined.DeveloperBoard"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
namespace IoTHub.Portal.Tests.Unit.Client.Pages.Shared
{
using System;
using IoTHub.Portal.Client.Services;
using IoTHub.Portal.Client.Shared;
using Models.v10;
using UnitTests.Bases;
using Bunit;
using Bunit.TestDoubles;
using FluentAssertions;
using Microsoft.AspNetCore.Components.Web.Extensions.Head;
using IoTHub.Portal.Client.Services;
using IoTHub.Portal.Client.Shared;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.Extensions.DependencyInjection;
using Models.v10;
using MudBlazor;
using NUnit.Framework;
using Portal.Client.Constants;
using Microsoft.AspNetCore.Components.Web;
using UnitTests.Bases;

[TestFixture]
public class MainLayoutTests : BlazorUnitTest
Expand All @@ -34,7 +33,8 @@ public override void Setup()
_ = Services.AddSingleton(new PortalSettings
{
PortalName = "TEST",
IsLoRaSupported = false
IsLoRaSupported = false,
CloudProvider = "Azure"
});
}

Expand Down
17 changes: 9 additions & 8 deletions src/IoTHub.Portal.Tests.Unit/Client/Pages/Shared/NavMenuTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public override void Setup()
_ = Services.AddScoped<ILayoutService, LayoutService>();

_ = TestContext?.AddTestAuthorization().SetAuthorized(Guid.NewGuid().ToString());

}

[TestCase("Devices", "Devices")]
Expand All @@ -42,7 +43,7 @@ public override void Setup()
public async Task CollapseButtonNavGroupShouldSaveNewState(string title, string property)
{
// Arrange
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true });
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true, CloudProvider = "Azure" });
var cut = RenderComponent<NavMenu>();
var navGroups = cut.FindComponents<MudNavGroup>();

Expand All @@ -63,7 +64,7 @@ public async Task CollapseButtonNavGroupShouldSaveNewState(string title, string
public async Task ExpandButtonNavGroupShouldSaveState(string title, string property)
{
// Arrange
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true });
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true, CloudProvider = "Azure" });

var dic = new Dictionary<string, bool>
{
Expand Down Expand Up @@ -94,7 +95,7 @@ public async Task ExpandButtonNavGroupShouldSaveState(string title, string prope
public async Task CollapseButtonNavGroupShouldSaveState(string title, string property)
{
// Arrange
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true });
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true, CloudProvider = "Azure" });
var dic = new Dictionary<string, bool>
{
{ property, true }
Expand Down Expand Up @@ -124,7 +125,7 @@ public async Task CollapseButtonNavGroupShouldSaveState(string title, string pro
public async Task WhenFalseCollapseNavGroupShouldBeCollapsed(string title, string property)
{
// Arrange
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true });
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true, CloudProvider = "Azure" });
var dic = new Dictionary<string, bool>
{
{ property, false }
Expand All @@ -150,7 +151,7 @@ public async Task WhenFalseCollapseNavGroupShouldBeCollapsed(string title, strin
public async Task WhenTrueCollapseNavGroupShouldBeExpanded(string title, string property)
{
// Arrange
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true });
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true, CloudProvider = "Azure" });
var dic = new Dictionary<string, bool>
{
{ property, true }
Expand All @@ -170,7 +171,7 @@ public async Task WhenTrueCollapseNavGroupShouldBeExpanded(string title, string
public async Task NavGroupsExpendedValuesShouldBeTrueWhenFirstTime()
{
// Arrange
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true });
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true, CloudProvider = "Azure" });

// Act
var cut = RenderComponent<NavMenu>();
Expand All @@ -191,7 +192,7 @@ public async Task NavGroupsExpendedValuesShouldBeTrueWhenFirstTime()
public void LoRaNavGroupShouldBeDisplayedOnlyIfSupported(bool supported)
{
// Arrange
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = supported });
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = supported, CloudProvider = "Azure" });

// Act
var cut = RenderComponent<NavMenu>();
Expand All @@ -215,7 +216,7 @@ public void LoRaNavGroupShouldBeDisplayedOnlyIfSupported(bool supported)
public void WhenClickToNewButtonShouldNavigate(string buttonName, string path)
{
// Arrange
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = false });
_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = false, CloudProvider = "Azure" });
var cut = RenderComponent<NavMenu>();
var button = cut.WaitForElement($"#{buttonName}");

Expand Down

0 comments on commit 44aa2f8

Please sign in to comment.