From 9dc4b403f72d63e0b6adb3cfe424773d4b56581c Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Tue, 3 Nov 2020 12:18:47 +0100 Subject: [PATCH 1/3] AbpBlazorMessageLocalizerHelper moved to Volo.Abp.AspNetCore.Components.WebAssembly project --- .../WebAssembly/AbpBlazorMessageLocalizerHelper.cs | 6 +++--- framework/src/Volo.Abp.BlazoriseUI/AbpBlazoriseModule.cs | 3 +++ .../src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorModule.cs | 6 +++--- .../Pages/Identity/RoleManagement.razor | 3 +-- .../Pages/Identity/UserManagement.razor | 5 ++--- 5 files changed, 12 insertions(+), 11 deletions(-) rename modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorMessageLocalizerHelper.cs => framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorMessageLocalizerHelper.cs (84%) diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorMessageLocalizerHelper.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorMessageLocalizerHelper.cs similarity index 84% rename from modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorMessageLocalizerHelper.cs rename to framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorMessageLocalizerHelper.cs index 5d858843b8..e47e7f611c 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorMessageLocalizerHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorMessageLocalizerHelper.cs @@ -3,13 +3,13 @@ using System.Linq; using JetBrains.Annotations; using Microsoft.Extensions.Localization; -namespace Volo.Abp.Identity.Blazor +namespace Volo.Abp.AspNetCore.Components.WebAssembly { - public class AbpIdentityBlazorMessageLocalizerHelper + public class AbpBlazorMessageLocalizerHelper { private readonly IStringLocalizer stringLocalizer; - public AbpIdentityBlazorMessageLocalizerHelper(IStringLocalizer stringLocalizer) + public AbpBlazorMessageLocalizerHelper(IStringLocalizer stringLocalizer) { this.stringLocalizer = stringLocalizer; } diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpBlazoriseModule.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpBlazoriseModule.cs index 716f36b1ea..7ab435a34e 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/AbpBlazoriseModule.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/AbpBlazoriseModule.cs @@ -1,4 +1,5 @@ using Blazorise; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AspNetCore.Components.WebAssembly; using Volo.Abp.Modularity; @@ -18,6 +19,8 @@ namespace Volo.Abp.BlazoriseUI { context.Services .AddBlazorise(); + + context.Services.AddSingleton(typeof(AbpBlazorMessageLocalizerHelper<>)); } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorModule.cs b/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorModule.cs index 7f11267132..7cdeb0295b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorModule.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Routing; using Volo.Abp.AutoMapper; +using Volo.Abp.BlazoriseUI; using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement.Blazor; using Volo.Abp.UI.Navigation; @@ -10,7 +11,8 @@ namespace Volo.Abp.Identity.Blazor [DependsOn( typeof(AbpIdentityHttpApiClientModule), typeof(AbpAutoMapperModule), - typeof(AbpPermissionManagementBlazorModule) + typeof(AbpPermissionManagementBlazorModule), + typeof(AbpBlazoriseUIModule) )] public class AbpIdentityBlazorModule : AbpModule { @@ -32,8 +34,6 @@ namespace Volo.Abp.Identity.Blazor { options.AdditionalAssemblies.Add(typeof(AbpIdentityBlazorModule).Assembly); }); - - context.Services.AddSingleton(typeof(AbpIdentityBlazorMessageLocalizerHelper<>)); } } } 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 946fae64c3..f1b0a53a5e 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 @@ -6,10 +6,9 @@ @using Volo.Abp.PermissionManagement.Blazor.Components @using Microsoft.Extensions.Localization @using Volo.Abp.Identity.Localization -@inject AbpIdentityBlazorMessageLocalizerHelper LH +@inject AbpBlazorMessageLocalizerHelper LH @inherits AbpCrudPageBase - @* ************************* PAGE HEADER ************************* *@ 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 36db98f78e..1db58e4440 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,14 +1,13 @@ @page "/identity/users" -@attribute [Authorize(IdentityPermissions.Users.Default)] +@attribute [Authorize( IdentityPermissions.Users.Default )] @using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Components.Forms @using Volo.Abp.PermissionManagement.Blazor.Components @using Microsoft.Extensions.Localization @using Volo.Abp.Identity.Localization +@inject AbpBlazorMessageLocalizerHelper LH @inherits AbpCrudPageBase - -@inject AbpIdentityBlazorMessageLocalizerHelper LH @* ************************* PAGE HEADER ************************* *@ From 01d71954744f7c1a7048cd6a13ccea00bd753567 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Tue, 3 Nov 2020 12:19:30 +0100 Subject: [PATCH 2/3] Validation on user edit modal used an invalid model --- .../Pages/Identity/UserManagement.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1db58e4440..8f8d872fc6 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 @@ -186,7 +186,7 @@ - + From a62fb7be317213ce8d62686bdf12ea48ce8695e0 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Tue, 3 Nov 2020 12:21:30 +0100 Subject: [PATCH 3/3] Validation for Tenant create and edit modals --- .../TenantCreateOrUpdateDtoBase.cs | 3 +- .../TenantManagement/TenantManagement.razor | 175 +++++++++++------- .../TenantManagement.razor.cs | 32 ++-- 3 files changed, 127 insertions(+), 83 deletions(-) diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Application.Contracts/Volo/Abp/TenantManagement/TenantCreateOrUpdateDtoBase.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Application.Contracts/Volo/Abp/TenantManagement/TenantCreateOrUpdateDtoBase.cs index 9f047af2fd..eb5b71ba05 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Application.Contracts/Volo/Abp/TenantManagement/TenantCreateOrUpdateDtoBase.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Application.Contracts/Volo/Abp/TenantManagement/TenantCreateOrUpdateDtoBase.cs @@ -8,11 +8,12 @@ namespace Volo.Abp.TenantManagement { [Required] [DynamicStringLength(typeof(TenantConsts), nameof(TenantConsts.MaxNameLength))] + [Display(Name = "TenantName")] public string Name { get; set; } public TenantCreateOrUpdateDtoBase() : base(false) { - + } } } \ No newline at end of file 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 81c61ae9fa..1d62dc6be0 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 @@ -1,15 +1,15 @@ @page "/tenant-management/tenants" -@attribute [Authorize(TenantManagementPermissions.Tenants.Default)] +@attribute [Authorize( TenantManagementPermissions.Tenants.Default )] @using Microsoft.AspNetCore.Authorization @using Volo.Abp.FeatureManagement.Blazor.Components @using Microsoft.AspNetCore.Components.Forms - +@using Volo.Abp.TenantManagement.Localization +@inject AbpBlazorMessageLocalizerHelper LH @inherits AbpCrudPageBase - @* ************************* PAGE HEADER ************************* *@ -

@L["Tenants"]

+ @L["Tenants"]
@if (HasCreatePermission) @@ -65,31 +65,52 @@ { - - - @L["NewTenant"] - - - - - - @L["TenantName"] - - - - @L["DisplayName:AdminEmailAddress"] - - - - @L["DisplayName:AdminPassword"] - - - - - - - - + +
+ + @L["NewTenant"] + + + + + + + + @L["TenantName"] + + + + + + + + + + @L["DisplayName:AdminEmailAddress"] + + + + + + + + + + @L["DisplayName:AdminPassword"] + + + + + + + + + + + + + +
} @@ -99,23 +120,31 @@ { - - - @L["Edit"] - - - - - - @L["TenantName"] - - - - - - - - + +
+ + @L["Edit"] + + + + + + + @L["TenantName"] + + + + + + + + + + + + + +
} @@ -125,30 +154,36 @@ { - - - @L["ConnectionStrings"] - - - - - - @L["DisplayName:DefaultConnectionString"] - - - @if (!TenantInfo.UseSharedDatabase) - { - - @L["DisplayName:DefaultConnectionString"] - - - } - - - - - - + +
+ + @L["ConnectionStrings"] + + + + + + + @L["DisplayName:DefaultConnectionString"] + + + + @if (!TenantInfo.UseSharedDatabase) + { + + + @L["DisplayName:DefaultConnectionString"] + + + + } + + + + + + +
} 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 e5fcc9c4a3..ad33b68e5c 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 @@ -1,4 +1,5 @@ using System; +using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using Blazorise; using Microsoft.AspNetCore.Authorization; @@ -20,9 +21,10 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement protected FeatureManagementModal FeatureManagementModal; protected Modal ManageConnectionStringModal; + protected Validations ManageConnectionStringValidations; protected TenantInfoModel TenantInfo; - + public TenantManagement() { LocalizationResource = typeof(AbpTenantManagementResource); @@ -36,7 +38,7 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement TenantInfo = new TenantInfoModel(); } - + protected async override Task SetPermissionsAsync() { await base.SetPermissionsAsync(); @@ -47,6 +49,8 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement protected virtual async Task OpenEditConnectionStringModalAsync(Guid id) { + ManageConnectionStringValidations.ClearAll(); + var tenantConnectionString = await AppService.GetDefaultConnectionStringAsync(id); TenantInfo = new TenantInfoModel @@ -67,18 +71,21 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement protected virtual async Task UpdateConnectionStringAsync() { - await CheckPolicyAsync(ManageConnectionStringsPolicyName); - - if (TenantInfo.UseSharedDatabase || TenantInfo.DefaultConnectionString.IsNullOrWhiteSpace()) + if (ManageConnectionStringValidations.ValidateAll()) { - await AppService.DeleteDefaultConnectionStringAsync(TenantInfo.Id); + await CheckPolicyAsync(ManageConnectionStringsPolicyName); + + if (TenantInfo.UseSharedDatabase || TenantInfo.DefaultConnectionString.IsNullOrWhiteSpace()) + { + await AppService.DeleteDefaultConnectionStringAsync(TenantInfo.Id); + } + else + { + await AppService.UpdateDefaultConnectionStringAsync(TenantInfo.Id, TenantInfo.DefaultConnectionString); + } + + ManageConnectionStringModal.Hide(); } - else - { - await AppService.UpdateDefaultConnectionStringAsync(TenantInfo.Id, TenantInfo.DefaultConnectionString); - } - - ManageConnectionStringModal.Hide(); } protected override string GetDeleteConfirmationMessage(TenantDto entity) @@ -93,6 +100,7 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement public bool UseSharedDatabase { get; set; } + [Required] public string DefaultConnectionString { get; set; } } } \ No newline at end of file