From 700946270af5df367b2bc62ef6a2d42695ca37e5 Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Sun, 1 Nov 2020 21:29:54 +0300 Subject: [PATCH] use datagrid entity actions column usage in modules. --- .../Pages/Identity/RoleManagement.razor | 117 ++++++++---------- .../Pages/Identity/RoleManagement.razor.cs | 16 +-- .../Pages/Identity/UserManagement.razor | 62 ++++------ .../Pages/Identity/UserManagement.razor.cs | 22 ++-- .../Volo.Abp.Identity.Blazor/_Imports.razor | 1 + .../TenantManagement/TenantManagement.razor | 81 ++++++------ .../TenantManagement.razor.cs | 43 ++++--- .../_Imports.razor | 1 + 8 files changed, 154 insertions(+), 189 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor index 4639f81be2..353bfa3b6b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor @@ -1,5 +1,5 @@ @page "/identity/roles" -@attribute [Authorize( IdentityPermissions.Roles.Default )] +@attribute [Authorize(IdentityPermissions.Roles.Default)] @using Volo.Abp.Identity @using Microsoft.AspNetCore.Authorization @using Microsoft.Extensions.Localization @@ -14,7 +14,7 @@ @L["Roles"] - @if ( HasCreatePermission ) + @if (HasCreatePermission) { @@ -31,40 +31,33 @@ ShowPager="true" PageSize="PageSize"> - @if ( ShouldShowEntityActions ) - { - - - - - @L["Actions"] - - - @if ( HasUpdatePermission ) - { - @L["Edit"] - } - @if ( HasManagePermissionsPermission ) - { - @L["Permissions"] - } - @if ( HasDeletePermission ) - { - @L["Delete"] - } - - - - - } + + + + + + + + + - @(context.As().Name) - @if ( context.As().IsDefault ) + @(context.Name) + @if (context.IsDefault) { @L["DisplayName:IsDefault"] } - @if ( context.As().IsPublic ) + @if (context.IsPublic) { @L["DisplayName:IsPublic"] } @@ -74,42 +67,42 @@ @* ************************* CREATE MODAL ************************* *@ -@if ( HasCreatePermission ) +@if (HasCreatePermission) { - - - - - @L["NewRole"] - - - - - - - @L["DisplayName:RoleName"] - - - - - - - + + + + + @L["NewRole"] + + + + + - @L["DisplayName:IsDefault"] - @L["DisplayName:IsPublic"] + @L["DisplayName:RoleName"] + + + + + - - - - - - - - + + + @L["DisplayName:IsDefault"] + @L["DisplayName:IsPublic"] + + + + + + + + + } @* ************************* EDIT MODAL ************************* *@ -@if ( HasUpdatePermission ) +@if (HasUpdatePermission) { diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs index 04b7a1011d..f64615c1f0 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs @@ -13,11 +13,10 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity protected const string PermissionProviderName = "R"; protected PermissionManagementModal PermissionManagementModal; + protected string ManagePermissionsPolicyName; protected bool HasManagePermissionsPermission { get; set; } - protected bool ShouldShowEntityActions { get; set; } - public RoleManagementBase() { ObjectMapperContext = typeof(AbpIdentityBlazorModule); @@ -26,19 +25,12 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity CreatePolicyName = IdentityPermissions.Roles.Create; UpdatePolicyName = IdentityPermissions.Roles.Update; DeletePolicyName = IdentityPermissions.Roles.Delete; + ManagePermissionsPolicyName = IdentityPermissions.Roles.ManagePermissions; } - protected override async Task SetPermissionsAsync() + protected override string GetDeleteConfirmationMessage(IdentityRoleDto entity) { - await base.SetPermissionsAsync(); - - HasManagePermissionsPermission = await AuthorizationService.IsGrantedAsync( - IdentityPermissions.Roles.ManagePermissions - ); - - ShouldShowEntityActions = HasUpdatePermission || - HasDeletePermission || - HasManagePermissionsPermission; + return string.Format(L["RoleDeletionConfirmationMessage"], entity.Name); } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor index 93e0ccaa85..e5ad942275 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor @@ -1,5 +1,5 @@ @page "/identity/users" -@attribute [Authorize( IdentityPermissions.Users.Default )] +@attribute [Authorize(IdentityPermissions.Users.Default)] @using Microsoft.AspNetCore.Authorization @using Microsoft.Extensions.Localization @using Volo.Abp.Identity.Localization @@ -13,7 +13,7 @@

@L["Users"]

- @if ( HasCreatePermission ) + @if (HasCreatePermission) { @@ -30,33 +30,25 @@ ShowPager="true" PageSize="PageSize"> - @if ( ShouldShowEntityActions ) - { - - - - - @L["Actions"] - - - @if ( HasUpdatePermission ) - { - @L["Edit"] - } - @if ( HasManagePermissionsPermission ) - { - @L["Permissions"] - } - @if ( HasDeletePermission ) - { - - @L["Delete"] - } - - - - - } + + + + + + + + + @(context.As().UserName) @@ -76,7 +68,7 @@ @* ************************* CREATE MODAL ************************* *@ -@if ( HasCreatePermission ) +@if (HasCreatePermission) { @@ -159,9 +151,9 @@ - @if ( NewUserRoles != null ) + @if (NewUserRoles != null) { - @foreach ( var role in NewUserRoles ) + @foreach (var role in NewUserRoles) { @@ -183,7 +175,7 @@ } @* ************************* EDIT MODAL ************************* *@ -@if ( HasUpdatePermission ) +@if (HasUpdatePermission) { @@ -268,9 +260,9 @@ - @if ( EditUserRoles != null ) + @if (EditUserRoles != null) { - @foreach ( var role in EditUserRoles ) + @foreach (var role in EditUserRoles) { diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs index 0265bf89d1..303c511b80 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs @@ -24,8 +24,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity protected AssignedRoleViewModel[] EditUserRoles; - protected bool ShouldShowEntityActions { get; set; } - protected bool HasManagePermissionsPermission { get; set; } + protected string ManagePermissionsPolicyName; protected string CreateModalSelectedTab = DefaultSelectedTab; @@ -39,6 +38,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity CreatePolicyName = IdentityPermissions.Users.Create; UpdatePolicyName = IdentityPermissions.Users.Update; DeletePolicyName = IdentityPermissions.Users.Delete; + ManagePermissionsPolicyName = IdentityPermissions.Users.ManagePermissions; } protected override async Task OnInitializedAsync() @@ -48,19 +48,6 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity Roles = (await AppService.GetAssignableRolesAsync()).Items; } - protected override async Task SetPermissionsAsync() - { - await base.SetPermissionsAsync(); - - HasManagePermissionsPermission = await AuthorizationService.IsGrantedAsync( - IdentityPermissions.Users.ManagePermissions - ); - - ShouldShowEntityActions = HasUpdatePermission || - HasDeletePermission || - HasManagePermissionsPermission; - } - protected override async Task OnOpeningCreateModalAsync() { CreateModalSelectedTab = DefaultSelectedTab; @@ -104,6 +91,11 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity return base.OnUpdatingEntityAsync(); } + + protected override string GetDeleteConfirmationMessage(IdentityUserDto entity) + { + return string.Format(L["UserDeletionConfirmationMessage"], entity.UserName); + } } public class AssignedRoleViewModel diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/_Imports.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/_Imports.razor index bcb4626f1f..51955030c9 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/_Imports.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/_Imports.razor @@ -2,5 +2,6 @@ @using Volo.Abp.AspNetCore.Components.WebAssembly @using Microsoft.AspNetCore.Components.Forms @using Volo.Abp.BlazoriseUI +@using Volo.Abp.BlazoriseUI.Components @using Blazorise @using Blazorise.DataGrid diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor index 0b2f60d23b..c777bcb50b 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor @@ -6,7 +6,6 @@ @using Volo.Abp.FeatureManagement.Blazor.Components @inherits TenantManagementBase @inject IStringLocalizer L - @* ************************* PAGE HEADER ************************* *@ @@ -30,40 +29,32 @@ ShowPager="true" PageSize="PageSize"> - @if (ShouldShowEntityActions) - { - - - - - @L["Actions"] - - - @if (HasUpdatePermission) - { - @L["Edit"] - } - @if (HasManageConnectionStringsPermission) - { - @L["ConnectionStrings"] - } - @if (HasManageFeaturesPermission) - { - @L["Features"] - } - @if (HasDeletePermission) - { - - @L["Delete"] - } - - - - - } + + + + + + + + + + - @(context.As().Name) + @(context.Name) @@ -73,25 +64,25 @@ @if (HasCreatePermission) { - + @L["NewTenant"] - + @L["TenantName"] - + @L["DisplayName:AdminEmailAddress"] - + @L["DisplayName:AdminPassword"] - + @@ -107,17 +98,17 @@ @if (HasUpdatePermission) { - + @L["Edit"] - + @L["TenantName"] - + @@ -133,11 +124,11 @@ @if (HasUpdatePermission) { - + @L["ConnectionStrings"] - + @@ -149,7 +140,7 @@ { @L["DisplayName:DefaultConnectionString"] - + } @@ -164,5 +155,5 @@ @if (HasManageFeaturesPermission) { - + } \ No newline at end of file diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs index f9dd57422e..9106c32c78 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs @@ -7,21 +7,22 @@ using Volo.Abp.FeatureManagement.Blazor.Components; namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement { - public abstract class TenantManagementBase + public abstract class TenantManagementBase : AbpCrudPageBase { protected const string FeatureProviderName = "T"; - - protected bool ShouldShowEntityActions; + protected bool HasManageConnectionStringsPermission; protected bool HasManageFeaturesPermission; + protected string ManageConnectionStringsPolicyName; + protected string ManageFeaturesPolicyName; protected FeatureManagementModal FeatureManagementModal; - + protected Modal ManageConnectionStringModal; protected TenantInfoModel TenantInfo; - + public TenantManagementBase() { ObjectMapperContext = typeof(AbpTenantManagementBlazorModule); @@ -29,37 +30,34 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement CreatePolicyName = TenantManagementPermissions.Tenants.Create; UpdatePolicyName = TenantManagementPermissions.Tenants.Update; DeletePolicyName = TenantManagementPermissions.Tenants.Delete; - + ManageConnectionStringsPolicyName = TenantManagementPermissions.Tenants.ManageConnectionStrings; + ManageFeaturesPolicyName = TenantManagementPermissions.Tenants.ManageFeatures; + TenantInfo = new TenantInfoModel(); } - + protected override async Task SetPermissionsAsync() { await base.SetPermissionsAsync(); - HasManageConnectionStringsPermission = await AuthorizationService.IsGrantedAsync(TenantManagementPermissions.Tenants.ManageConnectionStrings); - HasManageFeaturesPermission = await AuthorizationService.IsGrantedAsync(TenantManagementPermissions.Tenants.ManageFeatures); - - ShouldShowEntityActions = HasUpdatePermission || - HasDeletePermission || - HasManageConnectionStringsPermission || - HasManageFeaturesPermission; + HasManageConnectionStringsPermission = await AuthorizationService.IsGrantedAsync(ManageConnectionStringsPolicyName); + HasManageFeaturesPermission = await AuthorizationService.IsGrantedAsync(ManageFeaturesPolicyName); } protected virtual async Task OpenEditConnectionStringModalAsync(Guid id) { var tenantConnectionString = await AppService.GetDefaultConnectionStringAsync(id); - + TenantInfo = new TenantInfoModel { Id = id, DefaultConnectionString = tenantConnectionString, UseSharedDatabase = tenantConnectionString.IsNullOrWhiteSpace() }; - + ManageConnectionStringModal.Show(); } - + protected virtual Task CloseEditConnectionStringModal() { ManageConnectionStringModal.Hide(); @@ -68,7 +66,7 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement protected virtual async Task UpdateConnectionStringAsync() { - await CheckPolicyAsync(TenantManagementPermissions.Tenants.ManageConnectionStrings); + await CheckPolicyAsync(ManageConnectionStringsPolicyName); if (TenantInfo.UseSharedDatabase || TenantInfo.DefaultConnectionString.IsNullOrWhiteSpace()) { @@ -78,9 +76,14 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement { await AppService.UpdateDefaultConnectionStringAsync(TenantInfo.Id, TenantInfo.DefaultConnectionString); } - + ManageConnectionStringModal.Hide(); } + + protected override string GetDeleteConfirmationMessage(TenantDto entity) + { + return string.Format(L["TenantDeletionConfirmationMessage"], entity.Name); + } } public class TenantInfoModel @@ -88,7 +91,7 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement public Guid Id { get; set; } public bool UseSharedDatabase { get; set; } - + public string DefaultConnectionString { get; set; } } } \ No newline at end of file diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/_Imports.razor b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/_Imports.razor index bcb4626f1f..51955030c9 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/_Imports.razor +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/_Imports.razor @@ -2,5 +2,6 @@ @using Volo.Abp.AspNetCore.Components.WebAssembly @using Microsoft.AspNetCore.Components.Forms @using Volo.Abp.BlazoriseUI +@using Volo.Abp.BlazoriseUI.Components @using Blazorise @using Blazorise.DataGrid