Files
Heimdall/src/Heimdall.Web/Components/Shared/NotificationBadge.razor
T
arnaud.dartois e042b832d8
Heimdall Gitea / Detect CI scope (push) Successful in 6s
Heimdall Gitea / Build and tests (push) Successful in 26m44s
Heimdall Gitea / Publish versioned release (push) Skipped
Heimdall Gitea / Build and scan server image (push) Successful in 7m47s
Heimdall Gitea / Build and scan agent image (push) Successful in 11m47s
Heimdall Gitea / Publish Docker Hub latest tags (push) Successful in 2m3s
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Successful in 17m11s
Heimdall Gitea / CI policy (push) Successful in 2s
fix(web): open a notification center from the header (#307)
## Résumé
La cloche du bandeau ouvre `/notifications`, qui affiche les notifications du compte courant et permet leur lecture individuelle ou globale.

Closes #302

## Validation
- `dotnet restore tests/Heimdall.Web.Tests/Heimdall.Web.Tests.csproj --locked-mode` : réussi.
- Tests bUnit ciblés `NotificationsPageTests` : 2/2 réussis; suite Web Release : 438/438 réussis avant merge concurrent de `main`.
- Build Web Release : 0 avertissement, 0 erreur avant le merge concurrent.
- Compose jetable `heimdall-notifications-acceptance-20261108140737-223989` : événement synthétique, isolation Admin/Viewer, lecture simple/globale, refus anonyme et compteur 0 vérifiés via API.
- Navigateur Orca : clic de la cloche depuis `/profile`, contenu et badge sur `/notifications`, lecture simple et état vide Viewer vérifiés. `/events` n’a pas été chargé.
- Nettoyage vérifié : conteneurs/volumes/réseaux absents et tags exacts supprimés pour les projets jetables. Voir le commentaire de l’issue pour les noms et tags.
- Après merge concurrent de `main`, deux reruns locaux ont échoué par manque de ressources (`Out of memory`), pas par échec de test. CI du commit courant à surveiller avant fusion.

Reviewed-on: #307
Co-authored-by: Arnaud Dartois <admin@tordais.cc>
2026-11-08 18:57:33 +01:00

49 lines
1.8 KiB
Plaintext

@* NotificationBadge.razor — cloche avec badge compteur temps réel (SignalR). *@
@implements IAsyncDisposable
@inject NotificationsHubClient Hub
@inject NavigationManager Navigation
@inject AuthenticationStateProvider AuthenticationStateProvider
@inject Heimdall.Web.Services.UiText Text
<MudTooltip Text="@Text["SharedNotificationBadge_Title"]">
<MudBadge Color="Color.Error" Overlap="true" Bordered="true" Content="@Hub.UnreadCount"
Visible="@(Hub.UnreadCount > 0)">
<MudIconButton Icon="@Icons.Material.Filled.Notifications" Color="Color.Inherit"
aria-label="@Text["SharedNotificationBadge_Title"]"
OnClick="@(() => Navigation.NavigateTo("/notifications"))" />
</MudBadge>
</MudTooltip>
@code {
protected override async Task OnInitializedAsync()
{
Hub.UnreadCountChanged += OnUnreadChanged;
AuthenticationStateProvider.AuthenticationStateChanged += OnAuthenticationStateChanged;
await Hub.StartAsync();
await Hub.RefreshUnreadCountAsync();
}
private void OnAuthenticationStateChanged(Task<AuthenticationState> authenticationStateTask)
{
_ = InvokeAsync(async () =>
{
var authenticationState = await authenticationStateTask;
if (authenticationState.User.Identity?.IsAuthenticated == true)
{
await Hub.StartAsync();
await Hub.RefreshUnreadCountAsync();
}
StateHasChanged();
});
}
private void OnUnreadChanged(int _) => InvokeAsync(StateHasChanged);
public async ValueTask DisposeAsync()
{
Hub.UnreadCountChanged -= OnUnreadChanged;
AuthenticationStateProvider.AuthenticationStateChanged -= OnAuthenticationStateChanged;
await Hub.DisposeAsync();
}
}