Correct bunch of issues #36

Merged
Egamorf merged 7 commits from fix/multiple-issues-from-gitea into main 2025-04-29 23:49:11 +02:00
6 changed files with 34 additions and 15 deletions
Showing only changes of commit 48e93ab1b8 - Show all commits

View File

@@ -23,7 +23,10 @@
</Select> </Select>
</div> </div>
<div class="buttons"> <div class="buttons">
@if (CanDelete)
{
<button type="button" class="remove" @onclick="HandleRemoveClicked">@Icons.Bin</button> <button type="button" class="remove" @onclick="HandleRemoveClicked">@Icons.Bin</button>
}
@if (CanEdit) @if (CanEdit)
{ {
<button type="button" class="edit @(IsEditing ? "selected" : "")" @onclick="HandleEditClicked">@Icons.Pen</button> <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 UserDto User { get; set; } = new();
[Parameter] public List<RoleDto> Roles { get; set; } = []; [Parameter] public List<RoleDto> Roles { get; set; } = [];
[Parameter] public bool CanEdit { get; set; } = true; [Parameter] public bool CanEdit { get; set; } = true;
[Parameter] public bool CanDelete { get; set; } = true;
[Parameter] public bool IsEditing { get; set; } = false; [Parameter] public bool IsEditing { get; set; } = false;
[Parameter] public EventCallback<UserDto> OnRemove { get; set; } [Parameter] public EventCallback<UserDto> OnRemove { get; set; }
[Parameter] public EventCallback<UserDto> OnSubmit { get; set; } [Parameter] public EventCallback<UserDto> OnSubmit { get; set; }

View File

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

View File

@@ -13,7 +13,7 @@
<PageTitle>@ResourcesKey.GamesIdeas</PageTitle> <PageTitle>@ResourcesKey.GamesIdeas</PageTitle>
<HeaderGameIdeas DisplayAdd="false"> <HeaderGameIdeas>
<div class="header-content"> <div class="header-content">
<SearchInput Placeholder="@ResourcesKey.EnterUsername" @bind-Text="FilterParams.Name" @bind-Text:after=HandleFilterChanged /> <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 <SelectSearch TItem="RoleDto" Placeholder="@ResourcesKey.Roles" @bind-Values="FilterParams.Roles" @bind-Values:after=HandleFilterChanged
@@ -31,7 +31,7 @@
{ {
@foreach (var user in UserList.Users ?? []) @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 else

View File

@@ -1,14 +1,19 @@
using GameIdeas.BlazorApp.Pages.Users.Filters; using GameIdeas.BlazorApp.Pages.Users.Filters;
using GameIdeas.BlazorApp.Pages.Users.Gateways; using GameIdeas.BlazorApp.Pages.Users.Gateways;
using GameIdeas.BlazorApp.Shared.Components.Popup; using GameIdeas.BlazorApp.Shared.Components.Popup;
using GameIdeas.Shared.Constants;
using GameIdeas.Shared.Dto; using GameIdeas.Shared.Dto;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using System.Security.Claims;
namespace GameIdeas.BlazorApp.Pages.Users; namespace GameIdeas.BlazorApp.Pages.Users;
public partial class Users public partial class Users
{ {
[Inject] private IUserGateway UserGateway { get; set; } = default!; [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 Popup? Popup;
private bool IsLoading = false; private bool IsLoading = false;
@@ -18,9 +23,19 @@ public partial class Users
private int CurrentPage = 1; private int CurrentPage = 1;
private UserDto UserAdd = new(); private UserDto UserAdd = new();
private UserDto? UserDelete; private UserDto? UserDelete;
private string? currentUserId;
protected override async Task OnInitializedAsync() 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 FetchData();
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }

View File

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