Skip to content

Commit

Permalink
Update Role Permissions.
Browse files Browse the repository at this point in the history
Update User Roles
  • Loading branch information
Casparus J Van Zyl committed Jan 21, 2025
1 parent 61f1b54 commit 06bcd00
Show file tree
Hide file tree
Showing 11 changed files with 925 additions and 609 deletions.
23 changes: 11 additions & 12 deletions src/apps/blazor/client/Pages/Identity/Roles/RolePermissions.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page "/identity/roles/{Id}/permissions"
@inject Microsoft.Extensions.Localization.IStringLocalizer<RolePermissions> _localizer

<PageHeader Title="@_title" Header="@_title" SubHeader="@_description" />

@if (!_loaded)
Expand All @@ -19,46 +20,44 @@ else
<ToolBarContent>
<div class="justify-center mud-text-align-center">
<MudButton Variant="Variant.Filled" DropShadow="false" Color="Color.Info" Class="ml-auto" StartIcon="@Icons.Material.Filled.ArrowBack" Href="/identity/roles">
Back
@_localizer["Back"]
</MudButton>
@if (_canEditRoleClaims)
{
<MudButton Variant="Variant.Filled" DropShadow="false" Color="Color.Primary" Class="ml-auto" OnClick="SaveAsync"
ButtonType="ButtonType.Submit" Style="margin-left: 5px!important;" StartIcon="@Icons.Material.Filled.Save">Update Permissions
ButtonType="ButtonType.Submit" Style="margin-left: 5px!important;" StartIcon="@Icons.Material.Filled.Save">
@_localizer["Update Permissions"]
</MudButton>
}
</div>
<MudSpacer />
@if (_canSearchRoleClaims)
{
<MudTextField @bind-Value="_searchString" Immediate="true" FullWidth=false
Placeholder="Search For Role Permissions" Adornment="Adornment.End"
Placeholder="@_localizer["Search For Role Permissions"]" Adornment="Adornment.End"
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0 mb-3">
</MudTextField>
}
</ToolBarContent>
<HeaderContent>
<MudTh>
<MudTableSortLabel SortBy="new Func<PermissionViewModel, object?>(x => x.Name)">
Permission Name</MudTableSortLabel>
<MudTableSortLabel SortBy="new Func<PermissionViewModel, object?>(x => x.Name)">@_localizer["Permission Name"]</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="new Func<PermissionViewModel, object?>(x => x.Description)">
Description</MudTableSortLabel>
<MudTableSortLabel SortBy="new Func<PermissionViewModel, object?>(x => x.Description)">@_localizer["Description"]</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="new Func<PermissionViewModel, object>(x => x.Enabled)">Status
</MudTableSortLabel>
<MudTableSortLabel SortBy="new Func<PermissionViewModel, object>(x => x.Enabled)">@_localizer["Status"]</MudTableSortLabel>
</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Permission Name">
<MudTd DataLabel="@_localizer["Permission Name"]">
<MudHighlighter Text="@context.Name" HighlightedText="@_searchString" />
</MudTd>
<MudTd DataLabel="Description">
<MudTd DataLabel="@_localizer["Description"]">
<MudHighlighter Text="@context.Description" HighlightedText="@_searchString" />
</MudTd>
<MudTd DataLabel="Permission">
<MudTd DataLabel="@_localizer["Permission"]">
<MudCheckBox T="bool" @bind-Value="@context.Enabled" Disabled="@(!_canEditRoleClaims)" Color="Color.Secondary">
</MudCheckBox>
</MudTd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ protected override async Task OnInitializedAsync()
() => RolesClient.GetRolePermissionsEndpointAsync(Id), Toast, Navigation)
is RoleDto role && role.Permissions is not null)
{
_title = string.Format("{0} Permissions", role.Name);
_description = string.Format("Manage {0} Role Permissions", role.Name);
_title = $"{role.Name} {_localizer["Permissions"]}";
_description = $"{_localizer["Manage"]} {role.Name} {_localizer["Role Permissions"]}";

var permissions = state.User.GetTenant() == TenantConstants.Root.Id
? FshPermissions.All
Expand Down Expand Up @@ -88,7 +88,7 @@ private async Task SaveAsync()
await ApiHelper.ExecuteCallGuardedAsync(
() => RolesClient.UpdateRolePermissionsEndpointAsync(request.RoleId, request),
Toast,
successMessage: "Updated Permissions.");
successMessage: _localizer["Updated Permissions."]);
Navigation.NavigateTo("/identity/roles");
}

Expand Down
18 changes: 9 additions & 9 deletions src/apps/blazor/client/Pages/Identity/Users/UserRoles.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,44 @@ else
<ToolBarContent>
<div class="justify-center mud-text-align-center">
<MudButton Variant="Variant.Filled" DropShadow="false" Color="Color.Info" Class="ml-auto" StartIcon="@Icons.Material.Filled.ArrowBack" Href="/identity/users">
Back
@_localizer["Back"]
</MudButton>
@if (_canEditUsers)
{
<MudButton Variant="Variant.Filled" DropShadow="false" Color="Color.Primary" Class="ml-auto" OnClick="SaveAsync" StartIcon="@Icons.Material.Filled.Save"
ButtonType="ButtonType.Submit" Style="margin-left: 5px!important;">
Update
@_localizer["Update"]
</MudButton>
}
</div>
<MudSpacer />
@if (_canSearchRoles)
{
<MudTextField @bind-Value="_searchString" Immediate="true" FullWidth=false
Placeholder="Search For User Roles" Adornment="Adornment.End"
Placeholder="@_localizer["Search For User Roles"]" Adornment="Adornment.End"
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0 mb-3">
</MudTextField>
}
</ToolBarContent>
<HeaderContent>
<MudTh>
<MudTableSortLabel SortBy="new Func<UserRoleDetail, object?>(x => x.RoleName)">Role Name</MudTableSortLabel>
<MudTableSortLabel SortBy="new Func<UserRoleDetail, object?>(x => x.RoleName)">@_localizer["Role Name"]</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="new Func<UserRoleDetail, object?>(x => x.Description)">Description</MudTableSortLabel>
<MudTableSortLabel SortBy="new Func<UserRoleDetail, object?>(x => x.Description)">@_localizer["Description"]</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="new Func<UserRoleDetail, object>(x => x.Enabled)">Status</MudTableSortLabel>
<MudTableSortLabel SortBy="new Func<UserRoleDetail, object>(x => x.Enabled)">@_localizer["Status"]</MudTableSortLabel>
</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Role Name">
<MudTd DataLabel="@_localizer["Role Name"]">
<MudHighlighter Text="@context.RoleName" HighlightedText="@_searchString" />
</MudTd>
<MudTd DataLabel="Description">
<MudTd DataLabel="@_localizer["Description"]">
<MudHighlighter Text="@context.Description" HighlightedText="@_searchString" />
</MudTd>
<MudTd DataLabel="Status">
<MudTd DataLabel="@_localizer["Status"]">
<MudCheckBox T="bool" @bind-Value="@context.Enabled" Disabled="@(!_canEditUsers)" Color="Color.Secondary">
</MudCheckBox>
</MudTd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ protected override async Task OnInitializedAsync()
() => UsersClient.GetUserEndpointAsync(Id!), Toast, Navigation)
is UserDetail user)
{
_title = $"{user.FirstName} {user.LastName}'s Roles";
_description = string.Format("Manage {0} {1}'s Roles", user.FirstName, user.LastName);
_title = $"{user.FirstName} {user.LastName}'s {_localizer["Roles"]}";
_description = $"{_localizer["Manage"]} {user.FirstName} {user.LastName}'s {_localizer["Roles"]}";

if (await ApiHelper.ExecuteCallGuardedAsync(
() => UsersClient.GetUserRolesEndpointAsync(user.Id.ToString()), Toast, Navigation)
Expand All @@ -67,7 +67,7 @@ private async Task SaveAsync()
await ApiHelper.ExecuteCallGuardedAsync(
() => UsersClient.AssignRolesToUserEndpointAsync(Id, request),
Toast,
successMessage: "updated user roles");
successMessage: _localizer["updated user roles"]);

Navigation.NavigateTo("/identity/users");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Cancel" xml:space="preserve">
<value>Kanseleer</value>
</data>
<data name="Logout Confirmation" xml:space="preserve">
<value>Afmeld bevestiging</value>
</data>
Expand Down
Loading

0 comments on commit 06bcd00

Please sign in to comment.