Correct bunch of issues (#36)
All checks were successful
Game Ideas deploy / build-test-deploy (push) Successful in 1m28s

Reviewed-on: #36
This commit was merged in pull request #36.
This commit is contained in:
2025-04-29 23:49:11 +02:00
parent d3d16493e6
commit f3c9e1d9da
37 changed files with 246 additions and 186 deletions

View File

@@ -23,7 +23,10 @@
</Select>
</div>
<div class="buttons">
<button type="button" class="remove" @onclick="HandleRemoveClicked">@Icons.Bin</button>
@if (CanDelete)
{
<button type="button" class="remove" @onclick="HandleRemoveClicked">@Icons.Bin</button>
}
@if (CanEdit)
{
<button type="button" class="edit @(IsEditing ? "selected" : "")" @onclick="HandleEditClicked">@Icons.Pen</button>

View File

@@ -12,6 +12,7 @@ public partial class UserRow
[Parameter] public UserDto User { get; set; } = new();
[Parameter] public List<RoleDto> Roles { get; set; } = [];
[Parameter] public bool CanEdit { get; set; } = true;
[Parameter] public bool CanDelete { get; set; } = true;
[Parameter] public bool IsEditing { get; set; } = false;
[Parameter] public EventCallback<UserDto> OnRemove { get; set; }
[Parameter] public EventCallback<UserDto> OnSubmit { get; set; }

View File

@@ -1,7 +1,7 @@
.row {
height: 64px;
display: grid;
grid-template-columns: 48px 1fr 1fr 1fr auto;
grid-template-columns: 48px 1fr 1fr 1fr 100px;
grid-gap: 8px;
padding: 0 8px;
background: var(--input-secondary);
@@ -9,25 +9,24 @@
border-radius: var(--big-radius);
}
.row > * {
align-content: center;
}
.row > * {
align-content: center;
max-width: 160px;
width: 100%;
}
.icon ::deep svg {
fill: var(--line);
}
.role {
min-width: 160px;
width: fit-content;
}
::deep .input-name,
::deep .input-name[disabled],
::deep .input-password,
::deep .input-password[disabled],
::deep .input-password::placeholder {
color: var(--white);
max-width: 160px;
width: 100%;
}
::deep .input-name,
@@ -61,12 +60,13 @@
flex-direction: row;
gap: 8px;
height:auto;
justify-content: end;
}
.buttons > * {
border: none;
outline: none;
margin: auto;
margin: auto 0;
height: 28px;
width: 28px;
background: none;

View File

@@ -1,7 +1,7 @@
@page "/Users"
@using GameIdeas.BlazorApp.Pages.Games.Header
@using GameIdeas.BlazorApp.Layouts
@using GameIdeas.BlazorApp.Pages.Users.Components
@using GameIdeas.BlazorApp.Shared.Components.Header
@using GameIdeas.BlazorApp.Shared.Components.Popup
@using GameIdeas.BlazorApp.Shared.Components.Popup.Components
@using GameIdeas.BlazorApp.Shared.Components.Search
@@ -13,13 +13,13 @@
<PageTitle>@ResourcesKey.GamesIdeas</PageTitle>
<GameHeader DisplayAdd="false">
<HeaderGameIdeas>
<div class="header-content">
<SearchInput Placeholder="@ResourcesKey.EnterUsername" @bind-Text="FilterParams.Name" @bind-Text:after=HandleFilterChanged />
<SelectSearch TItem="RoleDto" Placeholder="@ResourcesKey.Roles" @bind-Values="FilterParams.Roles" @bind-Values:after=HandleFilterChanged
Items="Roles.ToList()" GetLabel="@(role => role.Name)" Theme="SelectTheme.Filter" />
</div>
</GameHeader>
</HeaderGameIdeas>
<div class="container">
<UserRow User="UserAdd" Roles="Roles.ToList()" CanEdit="false" IsEditing="true" OnRemove="HandleResetUser" OnSubmit="HandleSubmitUser" Validator="@(new UserCreateValidator())" />
@@ -31,7 +31,7 @@
{
@foreach (var user in UserList.Users ?? [])
{
<UserRow User="user" Roles="Roles.ToList()" OnRemove="HandleOpenConfirmationPopup" OnSubmit="HandleUpdateUser" Validator="@(new UserUpdateValidator())" />
<UserRow User="user" Roles="Roles.ToList()" OnRemove="HandleOpenConfirmationPopup" OnSubmit="HandleUpdateUser" Validator="@(new UserUpdateValidator())" CanDelete=@(user.Id != currentUserId) />
}
}
else

View File

@@ -1,14 +1,19 @@
using GameIdeas.BlazorApp.Pages.Users.Filters;
using GameIdeas.BlazorApp.Pages.Users.Gateways;
using GameIdeas.BlazorApp.Shared.Components.Popup;
using GameIdeas.Shared.Constants;
using GameIdeas.Shared.Dto;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using System.Security.Claims;
namespace GameIdeas.BlazorApp.Pages.Users;
public partial class Users
{
[Inject] private IUserGateway UserGateway { get; set; } = default!;
[Inject] private AuthenticationStateProvider StateProvider { get; set; } = default!;
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
private Popup? Popup;
private bool IsLoading = false;
@@ -18,9 +23,19 @@ public partial class Users
private int CurrentPage = 1;
private UserDto UserAdd = new();
private UserDto? UserDelete;
private string? currentUserId;
protected override async Task OnInitializedAsync()
{
var authState = await StateProvider.GetAuthenticationStateAsync();
currentUserId = authState.User.FindFirstValue(ClaimTypes.Sid);
if (authState.User.FindFirstValue(ClaimTypes.Role) != GlobalConstants.ADMINISTRATOR || string.IsNullOrEmpty(currentUserId))
{
NavigationManager.NavigateTo("/Unauthorized");
return;
}
await FetchData();
await base.OnInitializedAsync();
}

View File

@@ -1,6 +1,6 @@
.header-content {
margin: 0 auto;
display: flex;
flex-direction: row;
gap: 8px;
}