Skip to content
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
3 changes: 3 additions & 0 deletions docker-compose.dcproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@
<ItemGroup>
<None Remove="src\**" />
</ItemGroup>
<ItemGroup>
<None Include="src\Blazor.Server.UI\Pages\Identity\Users\Profile.razor.cs" />
</ItemGroup>
</Project>
2 changes: 0 additions & 2 deletions src/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
<PackageReference Include="FluentValidation" Version="11.5.1" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.5.1" />
<PackageReference Include="Fluxor.Blazor.Web" Version="5.7.0" />
<PackageReference Include="Fluxor.Blazor.Web.ReduxDevTools" Version="5.7.0" />
<PackageReference Include="LazyCache" Version="2.4.0" />
<PackageReference Include="LazyCache.AspNetCore" Version="2.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.4" />
Expand Down
3 changes: 0 additions & 3 deletions src/Application/Common/Behaviours/ValidationBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Fluxor;
using System;

namespace CleanArchitecture.Blazor.Application.Common.Behaviours;

public class ValidationBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
Expand Down
4 changes: 0 additions & 4 deletions src/Application/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection


});
services.AddFluxor(options => {
options.ScanAssemblies(Assembly.GetExecutingAssembly());
options.UseReduxDevTools();
});
services.AddLazyCache();
services.AddScoped<PicklistService>();
services.AddScoped<IPicklistService>(sp => {
Expand Down
12 changes: 0 additions & 12 deletions src/Application/Features/Fluxor/Reducers.cs

This file was deleted.

40 changes: 0 additions & 40 deletions src/Application/Features/Fluxor/UserProfileState.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/Application/Features/Fluxor/UserProfileUpdateAction.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CleanArchitecture.Blazor.Application.Features.Identity.Notification;
public class UpdateUserProfileCommand:INotification
{
public UserProfile UserProfile { get; set; } = null!;
}
public class UpdateUserProfileEventArgs : EventArgs
{
public UserProfile UserProfile { get; set; } = null!;
}
1 change: 0 additions & 1 deletion src/Application/_Imports.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
global using MediatR;
global using Fluxor;
global using MediatR.Pipeline;
global using LazyCache;
global using Microsoft.Extensions.Localization;
Expand Down
1 change: 0 additions & 1 deletion src/Blazor.Server.UI/App.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

@inject IStringLocalizer<SharedResource> L

<Fluxor.Blazor.Web.StoreInitializer />
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
Expand Down
13 changes: 6 additions & 7 deletions src/Blazor.Server.UI/Components/Shared/SideMenu.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@using Blazor.Server.UI.Models.SideMenu

@inject IStringLocalizer<SideMenu> L
@inherits FluxorComponent
<MudDrawer Breakpoint="Breakpoint.Md"
Class="side-menu"
Elevation="0"
Expand All @@ -25,19 +24,19 @@
FullWidth="true">
<ChildContent>
<MudStack Row="true">
@if (string.IsNullOrEmpty(UserProfile.ProfilePictureDataUrl))
@if (string.IsNullOrEmpty(UserProfile?.ProfilePictureDataUrl))
{
<MudAvatar Color="Color.Primary">
@UserProfile.UserName.ToUpper().FirstOrDefault()
@UserProfile?.UserName.ToUpper().FirstOrDefault()
</MudAvatar>
}
else
{
<MudAvatar Image="@UserProfile.ProfilePictureDataUrl" />
<MudAvatar Image="@UserProfile?.ProfilePictureDataUrl" />
}
<MudStack Justify="Justify.SpaceBetween" Spacing="0">
<MudText Typo="Typo.body1">@UserProfile.DisplayName</MudText>
<MudText Typo="Typo.body2">@UserProfile.DefaultRole</MudText>
<MudText Typo="Typo.body1">@UserProfile?.DisplayName</MudText>
<MudText Typo="Typo.body2">@UserProfile?.DefaultRole</MudText>
</MudStack>
</MudStack>
</ChildContent>
Expand All @@ -47,7 +46,7 @@
else
{
<div class="d-flex justify-center my-3">
<MudAvatar Image="@UserProfile.ProfilePictureDataUrl" />
<MudAvatar Image="@UserProfile?.ProfilePictureDataUrl" />
</div>
}

Expand Down
27 changes: 20 additions & 7 deletions src/Blazor.Server.UI/Components/Shared/SideMenu.razor.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using Blazor.Server.UI.Models.SideMenu;
using Blazor.Server.UI.Services;
using Blazor.Server.UI.Services.Navigation;

using CleanArchitecture.Blazor.Application.Features.Identity.Notification;

namespace Blazor.Server.UI.Components.Shared;

public partial class SideMenu
public partial class SideMenu:INotificationHandler<UpdateUserProfileCommand>
{
[Inject]
private IState<UserProfileState> UserProfileState { get; set; } = null!;
private UserProfile UserProfile => UserProfileState.Value.UserProfile;

private UserProfile? UserProfile { get; set; } = null!;

[EditorRequired] [Parameter]
public bool SideMenuDrawerOpen { get; set; }
Expand All @@ -24,7 +23,21 @@ [EditorRequired] [Parameter]
[Inject]
private LayoutService LayoutService { get; set; } = default!;

private string[] _roles => UserProfile.AssignedRoles??new string[] { };
private string[] _roles => UserProfile?.AssignedRoles??new string[] { };


protected override void OnInitialized()
{
UserProfileChanged += (s, e) =>
{
UserProfile = e.UserProfile;
InvokeAsync(() => StateHasChanged());
};
}

public static event EventHandler<UpdateUserProfileEventArgs> UserProfileChanged=null!;
public Task Handle(UpdateUserProfileCommand notification, CancellationToken cancellationToken)
{
UserProfileChanged?.Invoke(this, new UpdateUserProfileEventArgs() { UserProfile = notification.UserProfile });
return Task.CompletedTask;
}
}
11 changes: 5 additions & 6 deletions src/Blazor.Server.UI/Components/Shared/UserMenu.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@using CleanArchitecture.Blazor.Infrastructure.Services.JWT;
@inject IStringLocalizer<SharedResource> L
@inject TokenAuthProvider TokenProvider
@inherits FluxorComponent
<MudTooltip Arrow="true" Text="@L["User Profile"]">
<MudMenu AnchorOrigin="Origin.BottomRight"
Icon="@Icons.Material.Filled.PermIdentity"
Expand All @@ -12,19 +11,19 @@
<div class="pb-4"
style="min-width: 260px;margin-bottom:0px!important">
<MudStack Row="true" Class="ma-4">
@if (string.IsNullOrEmpty(UserProfile.ProfilePictureDataUrl))
@if (string.IsNullOrEmpty(UserProfile?.ProfilePictureDataUrl))
{
<MudAvatar Color="Color.Primary">
@UserProfile.UserName.ToUpper().FirstOrDefault()
@UserProfile?.UserName.ToUpper().FirstOrDefault()
</MudAvatar>
}
else
{
<MudAvatar Image="@UserProfile.ProfilePictureDataUrl" />
<MudAvatar Image="@UserProfile?.ProfilePictureDataUrl" />
}
<MudStack Justify="Justify.SpaceBetween" Spacing="0">
<MudText Typo="Typo.body1">@UserProfile.DisplayName</MudText>
<MudText Typo="Typo.body2">@UserProfile.Email</MudText>
<MudText Typo="Typo.body1">@UserProfile?.DisplayName</MudText>
<MudText Typo="Typo.body2">@UserProfile?.Email</MudText>
</MudStack>
</MudStack>

Expand Down
25 changes: 20 additions & 5 deletions src/Blazor.Server.UI/Components/Shared/UserMenu.razor.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using Blazor.Server.UI.Components.Dialogs;
using CleanArchitecture.Blazor.Application.Features.Identity.Notification;
using Microsoft.AspNetCore.Components.Web;


namespace Blazor.Server.UI.Components.Shared;

public partial class UserMenu
public partial class UserMenu:INotificationHandler<UpdateUserProfileCommand>
{

[Inject]
private IState<UserProfileState> UserProfileState { get; set; } = null!;
private UserProfile UserProfile => UserProfileState.Value.UserProfile;

private UserProfile? UserProfile { get; set; } = null!;
[Parameter] public EventCallback<MouseEventArgs> OnSettingClick { get; set; }
[Inject]
protected NavigationManager NavigationManager { get; set; } = null!;
Expand All @@ -29,5 +29,20 @@ private async Task OnLogout()
await TokenProvider.RemoveAuthDataFromStorage();
NavigationManager.NavigateTo("/", true);
}
}
}
protected override void OnInitialized()
{
UserProfileChanged += (s, e) =>
{
UserProfile = e.UserProfile;
InvokeAsync(() => StateHasChanged());
};
}

public static event EventHandler<UpdateUserProfileEventArgs> UserProfileChanged = null!;
public Task Handle(UpdateUserProfileCommand notification, CancellationToken cancellationToken)
{
UserProfileChanged?.Invoke(this, new UpdateUserProfileEventArgs() { UserProfile = notification.UserProfile });
return Task.CompletedTask;
}
}
4 changes: 4 additions & 0 deletions src/Blazor.Server.UI/ConfigureServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using MudBlazor.Services;
using Toolbelt.Blazor.Extensions.DependencyInjection;
using MudExtensions.Services;
using CleanArchitecture.Blazor.Application.Features.Identity.Notification;
using Blazor.Server.UI.Components.Shared;

namespace Blazor.Server.UI;

Expand Down Expand Up @@ -69,6 +71,8 @@ public static IServiceCollection AddBlazorUIServices(this IServiceCollection ser
services.AddScoped<INotificationService, InMemoryNotificationService>();
services.AddGoogleAnalytics("G-PRYNCB61NV");
services.AddHealthChecks();
services.AddScoped<INotificationHandler<UpdateUserProfileCommand>, SideMenu>();
services.AddScoped<INotificationHandler<UpdateUserProfileCommand>, UserMenu>();
return services;
}
}
Loading