From 1221d50d6246f512d6e687ac9562c162e74a0e33 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Mon, 28 Dec 2020 11:54:42 +0100 Subject: [PATCH 01/23] Update to latest Blazorise 0.9.3-preview4 --- .../src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj | 6 +++--- .../MyCompanyName.MyProjectName.Blazor.csproj | 4 ++-- .../MyCompanyName.MyProjectName.Blazor.Host.csproj | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj b/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj index 1dce47face..de793e078f 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj +++ b/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj @@ -12,9 +12,9 @@ - - - + + + diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj index 9bc6fb7092..8ac2e020e5 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj index 444e49801f..6bd1d01269 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj @@ -8,8 +8,8 @@ - - + + From 348d1cbda8222f4c3fe3ddaec217979fa728bb77 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Mon, 28 Dec 2020 11:56:43 +0100 Subject: [PATCH 02/23] Created UiPageProgress component and service --- .../Themes/Basic/MainLayout.razor | 1 + .../Progression/IUiPageProgressService.cs | 10 ++++ .../Progression/NullUiPageProgressService.cs | 14 +++++ .../Progression/UiPageProgressEventArgs.cs | 17 ++++++ .../Progression/UiPageProgressOptions.cs | 13 +++++ .../Progression/UiPageProgressType.cs | 11 ++++ .../BlazoriseUiPageProgressService.cs | 32 ++++++++++ .../Components/UiPageProgress.razor | 1 + .../Components/UiPageProgress.razor.cs | 58 +++++++++++++++++++ 9 files changed, 157 insertions(+) create mode 100644 framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressEventArgs.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressOptions.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressType.cs create mode 100644 framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs create mode 100644 framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor create mode 100644 framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor index e85e899123..5993d17e0d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor @@ -21,4 +21,5 @@ + diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs new file mode 100644 index 0000000000..c3855e9c7f --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs @@ -0,0 +1,10 @@ +using System; +using System.Threading.Tasks; + +namespace Volo.Abp.AspNetCore.Components.Progression +{ + public interface IUiPageProgressService + { + Task Go(int? percentage, Action options = null); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs new file mode 100644 index 0000000000..887599ce99 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs @@ -0,0 +1,14 @@ +using System; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.AspNetCore.Components.Progression +{ + public class NullUiPageProgressService : IUiPageProgressService, ITransientDependency + { + public Task Go(int? percentage, Action options = null) + { + return Task.CompletedTask; + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressEventArgs.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressEventArgs.cs new file mode 100644 index 0000000000..74af5cb971 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressEventArgs.cs @@ -0,0 +1,17 @@ +using System; + +namespace Volo.Abp.AspNetCore.Components.Progression +{ + public class UiPageProgressEventArgs : EventArgs + { + public UiPageProgressEventArgs(int? percentage, UiPageProgressOptions options) + { + Percentage = percentage; + Options = options; + } + + public int? Percentage { get; } + + public UiPageProgressOptions Options { get; } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressOptions.cs new file mode 100644 index 0000000000..0ce243552d --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressOptions.cs @@ -0,0 +1,13 @@ +namespace Volo.Abp.AspNetCore.Components.Progression +{ + /// + /// Options to override page progress appearance. + /// + public class UiPageProgressOptions + { + /// + /// Type or color, of the page progress. + /// + public UiPageProgressType Type { get; set; } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressType.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressType.cs new file mode 100644 index 0000000000..db1d00932d --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressType.cs @@ -0,0 +1,11 @@ +namespace Volo.Abp.AspNetCore.Components.Progression +{ + public enum UiPageProgressType + { + Default, + Info, + Success, + Warning, + Error, + } +} diff --git a/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs b/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs new file mode 100644 index 0000000000..bb33e42342 --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs @@ -0,0 +1,32 @@ +using System; +using System.Threading.Tasks; +using Volo.Abp.AspNetCore.Components.Progression; +using Volo.Abp.AspNetCore.Components.WebAssembly; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.BlazoriseUI +{ + [Dependency(ReplaceServices = true)] + public class BlazoriseUiPageProgressService : IUiPageProgressService, IScopedDependency + { + /// + /// An event raised after the notification is received. + /// + public event EventHandler ProgressChanged; + + public Task Go(int? percentage, Action options = null) + { + var uiPageProgressOptions = CreateDefaultOptions(); + options?.Invoke(uiPageProgressOptions); + + ProgressChanged?.Invoke(this, new UiPageProgressEventArgs(percentage, uiPageProgressOptions)); + + return Task.CompletedTask; + } + + protected virtual UiPageProgressOptions CreateDefaultOptions() + { + return new UiPageProgressOptions(); + } + } +} diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor new file mode 100644 index 0000000000..91799182dd --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor.cs new file mode 100644 index 0000000000..bfb95a1536 --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor.cs @@ -0,0 +1,58 @@ +using System; +using Blazorise; +using Microsoft.AspNetCore.Components; +using Volo.Abp.AspNetCore.Components.Progression; + +namespace Volo.Abp.BlazoriseUI.Components +{ + public partial class UiPageProgress : ComponentBase, IDisposable + { + protected PageProgress PageProgressRef { get; set; } + + protected int? Percentage { get; set; } + + protected bool Visible { get; set; } + + protected Color Color { get; set; } + + [Inject] protected BlazoriseUiPageProgressService UiPageProgressService { get; set; } + + protected override void OnInitialized() + { + base.OnInitialized(); + + UiPageProgressService.ProgressChanged += OnProgressChanged; + } + + private async void OnProgressChanged(object sender, UiPageProgressEventArgs e) + { + Percentage = e.Percentage; + Visible = e.Percentage == null || (e.Percentage >= 0 && e.Percentage <= 100); + Color = GetColor(e.Options.Type); + + await PageProgressRef.SetValueAsync(e.Percentage); + + await InvokeAsync(StateHasChanged); + } + + public virtual void Dispose() + { + if (UiPageProgressService != null) + { + UiPageProgressService.ProgressChanged -= OnProgressChanged; + } + } + + protected virtual Color GetColor(UiPageProgressType pageProgressType) + { + return pageProgressType switch + { + UiPageProgressType.Info => Color.Info, + UiPageProgressType.Success => Color.Success, + UiPageProgressType.Warning => Color.Warning, + UiPageProgressType.Error => Color.Danger, + _ => Color.None, + }; + } + } +} From 3f04c995fb7ee02dee6b6aa38dc93a90a92b420c Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Mon, 28 Dec 2020 12:02:24 +0100 Subject: [PATCH 03/23] Implement IUiPageProgressService into IUiPageProgressService --- .../Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs | 68 ++++++++++++++----- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs index 612034af19..4f4d923fd7 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs @@ -13,6 +13,7 @@ using Microsoft.Extensions.Localization; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.AspNetCore.Components; +using Volo.Abp.AspNetCore.Components.Progression; using Volo.Abp.AspNetCore.Components.WebAssembly; using Volo.Abp.Authorization; using Volo.Abp.BlazoriseUI.Components; @@ -172,6 +173,7 @@ namespace Volo.Abp.BlazoriseUI { [Inject] protected TAppService AppService { get; set; } [Inject] protected IStringLocalizer UiLocalizer { get; set; } + [Inject] protected IUiPageProgressService PageProgressService { get; set; } protected virtual int PageSize { get; } = LimitedResultRequestDto.DefaultMaxResultCount; @@ -356,20 +358,46 @@ namespace Volo.Abp.BlazoriseUI return Task.CompletedTask; } + protected virtual async Task RunProcess(Func process) + { + try + { + // null means the progress will loop itself + await PageProgressService?.Go(null, options => + { + options.Type = UiPageProgressType.Info; + }); + + await process.Invoke(); + } + catch (Exception) + { + throw; + } + finally + { + // -1 is not valid value so the progress will hide + await PageProgressService?.Go(-1); + } + } + protected virtual async Task CreateEntityAsync() { if (CreateValidationsRef?.ValidateAll() ?? true) { - await OnCreatingEntityAsync(); + await RunProcess(async () => + { + await OnCreatingEntityAsync(); - await CheckCreatePolicyAsync(); - var createInput = MapToCreateInput(NewEntity); - await AppService.CreateAsync(createInput); - await GetEntitiesAsync(); + await CheckCreatePolicyAsync(); + var createInput = MapToCreateInput(NewEntity); + await AppService.CreateAsync(createInput); + await GetEntitiesAsync(); - await OnCreatedEntityAsync(); + await OnCreatedEntityAsync(); - CreateModal.Hide(); + CreateModal.Hide(); + }); } } @@ -387,16 +415,19 @@ namespace Volo.Abp.BlazoriseUI { if (EditValidationsRef?.ValidateAll() ?? true) { - await OnUpdatingEntityAsync(); + await RunProcess(async () => + { + await OnUpdatingEntityAsync(); - await CheckUpdatePolicyAsync(); - var updateInput = MapToUpdateInput(EditingEntity); - await AppService.UpdateAsync(EditingEntityId, updateInput); - await GetEntitiesAsync(); + await CheckUpdatePolicyAsync(); + var updateInput = MapToUpdateInput(EditingEntity); + await AppService.UpdateAsync(EditingEntityId, updateInput); + await GetEntitiesAsync(); - await OnUpdatedEntityAsync(); + await OnUpdatedEntityAsync(); - EditModal.Hide(); + EditModal.Hide(); + }); } } @@ -412,10 +443,13 @@ namespace Volo.Abp.BlazoriseUI protected virtual async Task DeleteEntityAsync(TListViewModel entity) { - await CheckDeletePolicyAsync(); + await RunProcess(async () => + { + await CheckDeletePolicyAsync(); - await AppService.DeleteAsync(entity.Id); - await GetEntitiesAsync(); + await AppService.DeleteAsync(entity.Id); + await GetEntitiesAsync(); + }); } protected virtual string GetDeleteConfirmationMessage(TListViewModel entity) From 7ac1877b73e4b2f0d8552182b61b65cd8667a10b Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Wed, 30 Dec 2020 12:28:46 +0100 Subject: [PATCH 04/23] IUiPageProgressService moved to AbpBlazorClientHttpMessageHandler --- .../AbpBlazorClientHttpMessageHandler.cs | 29 ++++++++++++++++--- .../Progression/IUiPageProgressService.cs | 11 +++++++ .../Progression/NullUiPageProgressService.cs | 4 ++- .../Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs | 21 +------------- .../BlazoriseUiPageProgressService.cs | 5 +++- .../Components/UiPageProgress.razor.cs | 2 +- 6 files changed, 45 insertions(+), 27 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorClientHttpMessageHandler.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorClientHttpMessageHandler.cs index 84f9743a1e..310e9cc8a8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorClientHttpMessageHandler.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorClientHttpMessageHandler.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Configuration; using Microsoft.JSInterop; +using Volo.Abp.AspNetCore.Components.Progression; using Volo.Abp.DependencyInjection; namespace Volo.Abp.AspNetCore.Components.WebAssembly @@ -18,6 +19,8 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly private readonly NavigationManager _navigationManager; + private readonly IUiPageProgressService _uiPageProgressService; + private const string AntiForgeryCookieName = "XSRF-TOKEN"; private const string AntiForgeryHeaderName = "RequestVerificationToken"; @@ -25,19 +28,37 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly public AbpBlazorClientHttpMessageHandler( IJSRuntime jsRuntime, ICookieService cookieService, - NavigationManager navigationManager) + NavigationManager navigationManager, + IUiPageProgressService uiPageProgressService) { _jsRuntime = jsRuntime; _cookieService = cookieService; _navigationManager = navigationManager; + _uiPageProgressService = uiPageProgressService; } protected async override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { - await SetLanguageAsync(request, cancellationToken); - await SetAntiForgeryTokenAsync(request); + try + { + await _uiPageProgressService.Go(null, options => + { + options.Type = UiPageProgressType.Info; + }); - return await base.SendAsync(request, cancellationToken); + await SetLanguageAsync(request, cancellationToken); + await SetAntiForgeryTokenAsync(request); + + return await base.SendAsync(request, cancellationToken); + } + catch (Exception) + { + throw; + } + finally + { + await _uiPageProgressService.Go(-1); + } } private async Task SetLanguageAsync(HttpRequestMessage request, CancellationToken cancellationToken) diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs index c3855e9c7f..fa9781e2d9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs @@ -5,6 +5,17 @@ namespace Volo.Abp.AspNetCore.Components.Progression { public interface IUiPageProgressService { + /// + /// An event raised after the notification is received. + /// + public event EventHandler ProgressChanged; + + /// + /// Sets the progress percentage. + /// + /// Value of the progress from 0 to 100, or null for indeterminate progress. + /// Additional options. + /// Awaitable task. Task Go(int? percentage, Action options = null); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs index 887599ce99..5c375e2b40 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs @@ -4,8 +4,10 @@ using Volo.Abp.DependencyInjection; namespace Volo.Abp.AspNetCore.Components.Progression { - public class NullUiPageProgressService : IUiPageProgressService, ITransientDependency + public class NullUiPageProgressService : IUiPageProgressService, ISingletonDependency { + public event EventHandler ProgressChanged; + public Task Go(int? percentage, Action options = null) { return Task.CompletedTask; diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs index 4f4d923fd7..2ec9e8a090 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs @@ -173,7 +173,6 @@ namespace Volo.Abp.BlazoriseUI { [Inject] protected TAppService AppService { get; set; } [Inject] protected IStringLocalizer UiLocalizer { get; set; } - [Inject] protected IUiPageProgressService PageProgressService { get; set; } protected virtual int PageSize { get; } = LimitedResultRequestDto.DefaultMaxResultCount; @@ -360,25 +359,7 @@ namespace Volo.Abp.BlazoriseUI protected virtual async Task RunProcess(Func process) { - try - { - // null means the progress will loop itself - await PageProgressService?.Go(null, options => - { - options.Type = UiPageProgressType.Info; - }); - - await process.Invoke(); - } - catch (Exception) - { - throw; - } - finally - { - // -1 is not valid value so the progress will hide - await PageProgressService?.Go(-1); - } + await process.Invoke(); } protected virtual async Task CreateEntityAsync() diff --git a/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs b/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs index bb33e42342..92e611df58 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs @@ -7,7 +7,10 @@ using Volo.Abp.DependencyInjection; namespace Volo.Abp.BlazoriseUI { [Dependency(ReplaceServices = true)] - public class BlazoriseUiPageProgressService : IUiPageProgressService, IScopedDependency + public class BlazoriseUiPageProgressService : IUiPageProgressService, + // WARNING: this is made Singleton because there was an issue with ABP internal DI. + // TODO: make it Scoped once the issue is solved. + ISingletonDependency { /// /// An event raised after the notification is received. diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor.cs index bfb95a1536..8a0a8e28d2 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor.cs @@ -15,7 +15,7 @@ namespace Volo.Abp.BlazoriseUI.Components protected Color Color { get; set; } - [Inject] protected BlazoriseUiPageProgressService UiPageProgressService { get; set; } + [Inject] protected IUiPageProgressService UiPageProgressService { get; set; } protected override void OnInitialized() { From 106a398d0a05ec2bdfe544d5758d55cce399e4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 1 Jan 2021 17:36:57 +0300 Subject: [PATCH 05/23] Introduce IClientScopeServiceProviderAccessor to access the main scope for the current client. --- .../AbpWebAssemblyHostBuilderExtensions.cs | 13 +++++--- .../AbpBlazorClientHttpMessageHandler.cs | 8 ++--- ...emblyClientScopeServiceProviderAccessor.cs | 12 +++++++ ...ntextClientScopeServiceProviderAccessor.cs | 33 +++++++++++++++++++ .../BlazoriseUiPageProgressService.cs | 5 +-- .../IClientScopeServiceProviderAccessor.cs | 9 +++++ 6 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/DependencyInjection/WebAssemblyClientScopeServiceProviderAccessor.cs create mode 100644 framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/DependencyInjection/HttpContextClientScopeServiceProviderAccessor.cs create mode 100644 framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IClientScopeServiceProviderAccessor.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyHostBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyHostBuilderExtensions.cs index 7cba7ce9b3..9e1752ffda 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyHostBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyHostBuilderExtensions.cs @@ -1,6 +1,5 @@ using System; using System.Globalization; -using System.Reflection; using System.Runtime.CompilerServices; using System.Threading.Tasks; using JetBrains.Annotations; @@ -8,7 +7,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Volo.Abp; using Volo.Abp.AspNetCore.Components.WebAssembly; +using Volo.Abp.AspNetCore.Components.WebAssembly.DependencyInjection; using Volo.Abp.AspNetCore.Mvc.Client; +using Volo.Abp.DependencyInjection; using Volo.Abp.Modularity; namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting @@ -39,13 +40,17 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting return application; } - public async static Task InitializeAsync( + public static async Task InitializeAsync( [NotNull] this IAbpApplicationWithExternalServiceProvider application, [NotNull] IServiceProvider serviceProvider) { Check.NotNull(application, nameof(application)); Check.NotNull(serviceProvider, nameof(serviceProvider)); + var serviceProviderAccessor = (WebAssemblyClientScopeServiceProviderAccessor) + serviceProvider.GetRequiredService(); + serviceProviderAccessor.ServiceProvider = serviceProvider; + application.Initialize(serviceProvider); using (var scope = serviceProvider.CreateScope()) @@ -55,7 +60,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting } } - private async static Task InitializeModulesAsync(IServiceProvider serviceProvider) + private static async Task InitializeModulesAsync(IServiceProvider serviceProvider) { foreach (var service in serviceProvider.GetServices()) { @@ -63,7 +68,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting } } - private async static Task SetCurrentLanguageAsync(IServiceScope scope) + private static async Task SetCurrentLanguageAsync(IServiceScope scope) { var configurationClient = scope.ServiceProvider.GetRequiredService(); var utilsService = scope.ServiceProvider.GetRequiredService(); diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorClientHttpMessageHandler.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorClientHttpMessageHandler.cs index 310e9cc8a8..fcdf065943 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorClientHttpMessageHandler.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorClientHttpMessageHandler.cs @@ -4,7 +4,7 @@ using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Components; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.JSInterop; using Volo.Abp.AspNetCore.Components.Progression; using Volo.Abp.DependencyInjection; @@ -29,15 +29,15 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly IJSRuntime jsRuntime, ICookieService cookieService, NavigationManager navigationManager, - IUiPageProgressService uiPageProgressService) + IClientScopeServiceProviderAccessor clientScopeServiceProviderAccessor) { _jsRuntime = jsRuntime; _cookieService = cookieService; _navigationManager = navigationManager; - _uiPageProgressService = uiPageProgressService; + _uiPageProgressService = clientScopeServiceProviderAccessor.ServiceProvider.GetRequiredService(); } - protected async override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { try { diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/DependencyInjection/WebAssemblyClientScopeServiceProviderAccessor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/DependencyInjection/WebAssemblyClientScopeServiceProviderAccessor.cs new file mode 100644 index 0000000000..74b16ec951 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/DependencyInjection/WebAssemblyClientScopeServiceProviderAccessor.cs @@ -0,0 +1,12 @@ +using System; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.AspNetCore.Components.WebAssembly.DependencyInjection +{ + public class WebAssemblyClientScopeServiceProviderAccessor : + IClientScopeServiceProviderAccessor, + ISingletonDependency + { + public IServiceProvider ServiceProvider { get; set; } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/DependencyInjection/HttpContextClientScopeServiceProviderAccessor.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/DependencyInjection/HttpContextClientScopeServiceProviderAccessor.cs new file mode 100644 index 0000000000..943c11ebc3 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/DependencyInjection/HttpContextClientScopeServiceProviderAccessor.cs @@ -0,0 +1,33 @@ +using System; +using Microsoft.AspNetCore.Http; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.AspNetCore.DependencyInjection +{ + public class HttpContextClientScopeServiceProviderAccessor : + IClientScopeServiceProviderAccessor, + ISingletonDependency + { + public IServiceProvider ServiceProvider + { + get + { + var httpContext = _httpContextAccessor.HttpContext; + if (httpContext == null) + { + throw new AbpException("HttpContextClientScopeServiceProviderAccessor should only be used in a web request scope!"); + } + + return httpContext.RequestServices; + } + } + + private readonly IHttpContextAccessor _httpContextAccessor; + + public HttpContextClientScopeServiceProviderAccessor( + IHttpContextAccessor httpContextAccessor) + { + _httpContextAccessor = httpContextAccessor; + } + } +} diff --git a/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs b/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs index 92e611df58..5285669c00 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs @@ -1,16 +1,13 @@ using System; using System.Threading.Tasks; using Volo.Abp.AspNetCore.Components.Progression; -using Volo.Abp.AspNetCore.Components.WebAssembly; using Volo.Abp.DependencyInjection; namespace Volo.Abp.BlazoriseUI { [Dependency(ReplaceServices = true)] public class BlazoriseUiPageProgressService : IUiPageProgressService, - // WARNING: this is made Singleton because there was an issue with ABP internal DI. - // TODO: make it Scoped once the issue is solved. - ISingletonDependency + IScopedDependency { /// /// An event raised after the notification is received. diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IClientScopeServiceProviderAccessor.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IClientScopeServiceProviderAccessor.cs new file mode 100644 index 0000000000..7c1d1ed08d --- /dev/null +++ b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IClientScopeServiceProviderAccessor.cs @@ -0,0 +1,9 @@ +using System; + +namespace Volo.Abp.DependencyInjection +{ + public interface IClientScopeServiceProviderAccessor + { + IServiceProvider ServiceProvider { get; } + } +} From 3aa4efaa0a72b20263b505fa4f07f48b0b078438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 1 Jan 2021 17:44:48 +0300 Subject: [PATCH 06/23] Remove unnecessary code. --- .../WebAssembly/AbpBlazorClientHttpMessageHandler.cs | 4 ---- framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs | 4 ---- 2 files changed, 8 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorClientHttpMessageHandler.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorClientHttpMessageHandler.cs index fcdf065943..7b40ca5286 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorClientHttpMessageHandler.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorClientHttpMessageHandler.cs @@ -51,10 +51,6 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly return await base.SendAsync(request, cancellationToken); } - catch (Exception) - { - throw; - } finally { await _uiPageProgressService.Go(-1); diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs index 2ec9e8a090..10c421fb6e 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs @@ -8,16 +8,12 @@ using JetBrains.Annotations; using Localization.Resources.AbpUi; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Components; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.AspNetCore.Components; -using Volo.Abp.AspNetCore.Components.Progression; -using Volo.Abp.AspNetCore.Components.WebAssembly; using Volo.Abp.Authorization; using Volo.Abp.BlazoriseUI.Components; -using Volo.Abp.ObjectMapping; namespace Volo.Abp.BlazoriseUI { From 82700d6351121949eb7bc02c0e6c10e392e12e01 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Mon, 4 Jan 2021 10:21:37 +0100 Subject: [PATCH 07/23] Remove RunProcess method --- .../Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs | 48 +++++++------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs index e2c714219a..4a4d4df722 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs @@ -353,28 +353,20 @@ namespace Volo.Abp.BlazoriseUI return Task.CompletedTask; } - protected virtual async Task RunProcess(Func process) - { - await process.Invoke(); - } - protected virtual async Task CreateEntityAsync() { if (CreateValidationsRef?.ValidateAll() ?? true) { - await RunProcess(async () => - { - await OnCreatingEntityAsync(); + await OnCreatingEntityAsync(); - await CheckCreatePolicyAsync(); - var createInput = MapToCreateInput(NewEntity); - await AppService.CreateAsync(createInput); - await GetEntitiesAsync(); + await CheckCreatePolicyAsync(); + var createInput = MapToCreateInput(NewEntity); + await AppService.CreateAsync(createInput); + await GetEntitiesAsync(); - await OnCreatedEntityAsync(); + await OnCreatedEntityAsync(); - CreateModal.Hide(); - }); + CreateModal.Hide(); } } @@ -392,19 +384,16 @@ namespace Volo.Abp.BlazoriseUI { if (EditValidationsRef?.ValidateAll() ?? true) { - await RunProcess(async () => - { - await OnUpdatingEntityAsync(); + await OnUpdatingEntityAsync(); - await CheckUpdatePolicyAsync(); - var updateInput = MapToUpdateInput(EditingEntity); - await AppService.UpdateAsync(EditingEntityId, updateInput); - await GetEntitiesAsync(); + await CheckUpdatePolicyAsync(); + var updateInput = MapToUpdateInput(EditingEntity); + await AppService.UpdateAsync(EditingEntityId, updateInput); + await GetEntitiesAsync(); - await OnUpdatedEntityAsync(); + await OnUpdatedEntityAsync(); - EditModal.Hide(); - }); + EditModal.Hide(); } } @@ -420,13 +409,10 @@ namespace Volo.Abp.BlazoriseUI protected virtual async Task DeleteEntityAsync(TListViewModel entity) { - await RunProcess(async () => - { - await CheckDeletePolicyAsync(); + await CheckDeletePolicyAsync(); - await AppService.DeleteAsync(entity.Id); - await GetEntitiesAsync(); - }); + await AppService.DeleteAsync(entity.Id); + await GetEntitiesAsync(); } protected virtual string GetDeleteConfirmationMessage(TListViewModel entity) From 6753332c2f095faed87df4d1abe3035a892b30a8 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Mon, 4 Jan 2021 11:16:19 +0100 Subject: [PATCH 08/23] Page progress page documentation and example --- docs/en/UI/Blazor/Page-Progress.md | 61 +++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/docs/en/UI/Blazor/Page-Progress.md b/docs/en/UI/Blazor/Page-Progress.md index 149c35293e..14daa41d3c 100644 --- a/docs/en/UI/Blazor/Page-Progress.md +++ b/docs/en/UI/Blazor/Page-Progress.md @@ -1,3 +1,62 @@ # Blazor UI: Page Progress -TODO \ No newline at end of file +Page progress is the newest component introduced with Blazorise and ABP Framework. It is used to show scoped page progress on top of the page and to indicate to the user that currently a long running process is in the work. By default you don't need to do anything to show the progress indicator, as all the work is done automatically by the ABP Framework internals. This means that all calls to the ABP backend(through Rest API) will activate page progress and show the loading indicator. + +This doesn't mean that you don't have the control over it. On the contrary. If you also want to show progress for your own processes, it is really easy to do. All you have to do is to use `IUiPageProgressService`. + +To use `IUiPageProgressService` you need to inject it into your own Blazor component or page. You have two options of injection. + +1. Parameter injection +2. Constructor injection + +Whichever you chose the end result is the same. In this guide we're going to use parameter injection. So let us begin. + +## Example + +First, inject the `IUiPageProgressService` + +```cs +@inject IUiPageProgressService pageProgressService +``` + +Next, all you have to do is invoke the `Go` method in `IUiPageProgressService`. It's that simple. + +```cs +Task OnClick() +{ + return pageProgressService.Go(null); +} +``` + +The previous example will show the progress with a default settings. If, for example you want to change the progress color you can override it by setting the options through the `Go` method. + +```cs +Task OnClick() +{ + return pageProgressService.Go(null, options => + { + options.Type = UiPageProgressType.Warning; + }); +} +``` + +## Breakdown + +The first parameter of the `Go` needs a little explanation. In the previous example we have set it to `null` which means, once called it will show an _indeterminate_ indicator and will cycle the loading animation indefinitely, until we hide the progress. You also have the option of defining the actual percentage of the progress and the code is the same, just instead of sending it the `null` you will send it a number between `0` and `100`. + +```cs +pageProgressService.Go(25) +``` + +### Valid values + +1. `null` - show _indeterminate_ indicator +2. `>= 0` and `<= 100` - show the regular _percentage_ progress + +## Hiding progress + +To hide the progress just set the actual values to something other then the _Valid value_. + +```cs +pageProgressService.Go(-1) +``` \ No newline at end of file From 46d65e708bfec83732094402976fa86fdb42df47 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 5 Jan 2021 15:41:24 +0800 Subject: [PATCH 09/23] Introduce AbpRequestLocalizationOptions Sometimes the module may need to configure RequestLocalizationOptions --- .../AbpRequestLocalizationMiddleware.cs | 4 +- .../AbpRequestLocalizationOptions.cs | 17 +++++++ ...ltAbpRequestLocalizationOptionsProvider.cs | 8 ++++ .../LocalizationTestController.cs | 15 +++++++ .../LocalizationTestController_Tests.cs | 45 +++++++++++++++++++ 5 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationOptions.cs create mode 100644 framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Localization/LocalizationTestController.cs create mode 100644 framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Localization/LocalizationTestController_Tests.cs diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationMiddleware.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationMiddleware.cs index e83e240c85..06f3922b22 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationMiddleware.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationMiddleware.cs @@ -23,10 +23,10 @@ namespace Microsoft.AspNetCore.RequestLocalization public async Task InvokeAsync(HttpContext context, RequestDelegate next) { - var middleware = new RequestLocalizationMiddleware( next, - new OptionsWrapper(await _requestLocalizationOptionsProvider.GetLocalizationOptionsAsync()), _loggerFactory + new OptionsWrapper(await _requestLocalizationOptionsProvider.GetLocalizationOptionsAsync()), + _loggerFactory ); await middleware.Invoke(context); diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationOptions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationOptions.cs new file mode 100644 index 0000000000..ccf2aeb3f4 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationOptions.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; + +namespace Microsoft.AspNetCore.RequestLocalization +{ + public class AbpRequestLocalizationOptions + { + public List> RequestLocalizationOptionConfigurators { get; } + + public AbpRequestLocalizationOptions() + { + RequestLocalizationOptionConfigurators = new List>(); + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/DefaultAbpRequestLocalizationOptionsProvider.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/DefaultAbpRequestLocalizationOptionsProvider.cs index 93ced35c45..226c0a9f6c 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/DefaultAbpRequestLocalizationOptionsProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/DefaultAbpRequestLocalizationOptionsProvider.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Localization; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; using Volo.Abp.Localization; using Volo.Abp.Settings; @@ -67,6 +68,13 @@ namespace Microsoft.AspNetCore.RequestLocalization .ToArray() }; + foreach (var configurator in serviceScope.ServiceProvider + .GetRequiredService>() + .Value.RequestLocalizationOptionConfigurators) + { + await configurator(serviceScope.ServiceProvider, options); + } + _optionsAction?.Invoke(options); _requestLocalizationOptions = options; } diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Localization/LocalizationTestController.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Localization/LocalizationTestController.cs new file mode 100644 index 0000000000..7426f95148 --- /dev/null +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Localization/LocalizationTestController.cs @@ -0,0 +1,15 @@ +using System.Globalization; +using Microsoft.AspNetCore.Mvc; + +namespace Volo.Abp.AspNetCore.Mvc.Localization +{ + [Route("api/LocalizationTestController")] + public class LocalizationTestController : AbpController + { + [HttpGet] + public string Culture() + { + return CultureInfo.CurrentCulture.Name + ":" + CultureInfo.CurrentUICulture.Name; + } + } +} diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Localization/LocalizationTestController_Tests.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Localization/LocalizationTestController_Tests.cs new file mode 100644 index 0000000000..726717c2a6 --- /dev/null +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Localization/LocalizationTestController_Tests.cs @@ -0,0 +1,45 @@ +using System.Net; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Localization; +using Microsoft.AspNetCore.RequestLocalization; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Primitives; +using Shouldly; +using Volo.Abp.DependencyInjection; +using Xunit; + +namespace Volo.Abp.AspNetCore.Mvc.Localization +{ + public class LocalizationTestController_Tests : AspNetCoreMvcTestBase + { + class TestRequestCultureProvider : RequestCultureProvider, ITransientDependency + { + public override Task DetermineProviderCultureResult(HttpContext httpContext) + { + return Task.FromResult(new ProviderCultureResult((StringSegment) "tr", (StringSegment) "hu")); + } + } + + protected override void ConfigureServices(HostBuilderContext context, IServiceCollection services) + { + services.Configure(options => + { + options.RequestLocalizationOptionConfigurators.Add((provider, localizationOptions) => + { + localizationOptions.RequestCultureProviders.Insert(0, provider.GetRequiredService()); + return Task.CompletedTask; + }); + }); + } + + [Fact] + public async Task TestRequestCultureProvider_Test() + { + var response = await GetResponseAsync("api/LocalizationTestController", HttpStatusCode.OK); + var resultAsString = await response.Content.ReadAsStringAsync(); + resultAsString.ToLower().ShouldBe("tr:hu"); + } + } +} From 1d761eb49b9ab79d8a7a94eb1c1f7a94711c8963 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 5 Jan 2021 15:59:30 +0800 Subject: [PATCH 10/23] Update LocalizationTestController_Tests --- .../Mvc/Localization/LocalizationTestController_Tests.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Localization/LocalizationTestController_Tests.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Localization/LocalizationTestController_Tests.cs index 726717c2a6..872d85013c 100644 --- a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Localization/LocalizationTestController_Tests.cs +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Localization/LocalizationTestController_Tests.cs @@ -7,14 +7,13 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Primitives; using Shouldly; -using Volo.Abp.DependencyInjection; using Xunit; namespace Volo.Abp.AspNetCore.Mvc.Localization { public class LocalizationTestController_Tests : AspNetCoreMvcTestBase { - class TestRequestCultureProvider : RequestCultureProvider, ITransientDependency + class TestRequestCultureProvider : RequestCultureProvider { public override Task DetermineProviderCultureResult(HttpContext httpContext) { @@ -26,9 +25,9 @@ namespace Volo.Abp.AspNetCore.Mvc.Localization { services.Configure(options => { - options.RequestLocalizationOptionConfigurators.Add((provider, localizationOptions) => + options.RequestLocalizationOptionConfigurators.Add((serviceProvider, localizationOptions) => { - localizationOptions.RequestCultureProviders.Insert(0, provider.GetRequiredService()); + localizationOptions.RequestCultureProviders.Insert(0, new TestRequestCultureProvider()); return Task.CompletedTask; }); }); From 8973c6e853ccca8f15849db8ee6a4d8fbfc83572 Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Tue, 5 Jan 2021 14:52:45 +0300 Subject: [PATCH 11/23] missing attributes added. --- .../Tags/{TagController.cs => TagAdminController.cs} | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) rename modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/{TagController.cs => TagAdminController.cs} (76%) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagAdminController.cs similarity index 76% rename from modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagController.cs rename to modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagAdminController.cs index 11dcc9a846..cc755fa63f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Tags/TagAdminController.cs @@ -2,18 +2,26 @@ using Microsoft.AspNetCore.Mvc; using System; using System.Threading.Tasks; +using Volo.Abp; using Volo.Abp.Application.Dtos; +using Volo.Abp.GlobalFeatures; using Volo.CmsKit.Admin.Tags; +using Volo.CmsKit.GlobalFeatures; using Volo.CmsKit.Permissions; using Volo.CmsKit.Tags; namespace Volo.CmsKit.Admin.Tags { - public class TagController : CmsKitAdminController, ITagAdminAppService + [RequiresGlobalFeature(typeof(TagsFeature))] + [RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] + [Area("cms-kit")] + [Authorize(CmsKitAdminPermissions.Tags.Default)] + [Route("api/cms-kit-admin/tags")] + public class TagAdminController : CmsKitAdminController, ITagAdminAppService { protected ITagAdminAppService TagAdminAppService { get; } - public TagController(ITagAdminAppService tagAdminAppService) + public TagAdminController(ITagAdminAppService tagAdminAppService) { TagAdminAppService = tagAdminAppService; } From 1153d72ffaaad6882f3c7bfe04be81f60df1e69f Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Tue, 5 Jan 2021 14:53:44 +0300 Subject: [PATCH 12/23] tag methods refactoring. Renamed controllers. Changed method signatures. --- .../CmsKit/Public/Tags/GetRelatedTagsInput.cs | 13 ------- .../Volo/CmsKit/Public/Tags/ITagAppService.cs | 4 +- .../Volo/CmsKit/Public/Tags/TagAppService.cs | 19 +++------ .../Volo/CmsKit/Public/Tags/TagController.cs | 27 ------------- .../CmsKit/Public/Tags/TagPublicController.cs | 31 +++++++++++++++ .../Components/Tags/TagViewComponent.cs | 6 +-- .../Tags/TagPublicAppService_Tests.cs | 39 ++----------------- 7 files changed, 44 insertions(+), 95 deletions(-) delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Tags/GetRelatedTagsInput.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagController.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagPublicController.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Tags/GetRelatedTagsInput.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Tags/GetRelatedTagsInput.cs deleted file mode 100644 index b8df8ec439..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Tags/GetRelatedTagsInput.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Volo.CmsKit.Public.Tags -{ - public class GetRelatedTagsInput - { - [Required] - public string EntityType { get; set; } - - [Required] - public string EntityId { get; set; } - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Tags/ITagAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Tags/ITagAppService.cs index 29d786f086..34d54b9006 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Tags/ITagAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Tags/ITagAppService.cs @@ -7,6 +7,6 @@ namespace Volo.CmsKit.Public.Tags { public interface ITagAppService : IApplicationService { - Task> GetAllRelatedTagsAsync(GetRelatedTagsInput input); + Task> GetAllRelatedTagsAsync(string entityType, string entityId); } -} +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Tags/TagAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Tags/TagAppService.cs index 8feaaa0130..593f011b02 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Tags/TagAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Tags/TagAppService.cs @@ -9,28 +9,21 @@ namespace Volo.CmsKit.Public.Tags { public class TagAppService : CmsKitAppServiceBase, ITagAppService { - protected readonly ITagManager TagManager; protected readonly ITagRepository TagRepository; - protected readonly IEntityTagRepository EntityTagRepository; - public TagAppService( - ITagManager tagManager, - ITagRepository tagRepository, - IEntityTagRepository entityTagRepository) + public TagAppService(ITagRepository tagRepository) { - TagManager = tagManager; TagRepository = tagRepository; - EntityTagRepository = entityTagRepository; } - public virtual async Task> GetAllRelatedTagsAsync(GetRelatedTagsInput input) + public virtual async Task> GetAllRelatedTagsAsync(string entityType, string entityId) { var entities = await TagRepository.GetAllRelatedTagsAsync( - input.EntityType, - input.EntityId, - CurrentTenant.Id); + entityType, + entityId, + CurrentTenant.Id); return ObjectMapper.Map, List>(entities); } } -} +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagController.cs deleted file mode 100644 index 307c5a4247..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagController.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using System.Collections.Generic; -using System.Threading.Tasks; -using Volo.Abp; -using Volo.CmsKit.Tags; - -namespace Volo.CmsKit.Public.Tags -{ - [RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] - [Area("cms-kit")] - [Route("api/cms-kit/tags")] - public class TagController : CmsKitPublicControllerBase, ITagAppService - { - protected readonly ITagAppService TagAppService; - - public TagController(ITagAppService tagAppService) - { - TagAppService = tagAppService; - } - - [HttpGet] - public Task> GetAllRelatedTagsAsync(GetRelatedTagsInput input) - { - return TagAppService.GetAllRelatedTagsAsync(input); - } - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagPublicController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagPublicController.cs new file mode 100644 index 0000000000..55041e5c6e --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagPublicController.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.GlobalFeatures; +using Volo.CmsKit.GlobalFeatures; +using Volo.CmsKit.Tags; + +namespace Volo.CmsKit.Public.Tags +{ + [RequiresGlobalFeature(typeof(TagsFeature))] + [RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] + [Area("cms-kit")] + [Route("api/cms-kit-public/tags")] + public class TagPublicController : CmsKitPublicControllerBase, ITagAppService + { + protected readonly ITagAppService TagAppService; + + public TagPublicController(ITagAppService tagAppService) + { + TagAppService = tagAppService; + } + + [HttpGet] + [Route("{entityType}/{entityId}")] + public Task> GetAllRelatedTagsAsync(string entityType, string entityId) + { + return TagAppService.GetAllRelatedTagsAsync(entityType, entityId); + } + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs index 44deaad0ed..c40408117a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Tags/TagViewComponent.cs @@ -24,11 +24,7 @@ namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Tags string entityType, string entityId) { - var tagDtos = await TagAppService.GetAllRelatedTagsAsync(new GetRelatedTagsInput - { - EntityId = entityId, - EntityType = entityType - }); + var tagDtos = await TagAppService.GetAllRelatedTagsAsync(entityType, entityId); var viewModel = new TagViewModel { diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagPublicAppService_Tests.cs index 6ad1136167..50eefd186b 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagPublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagPublicAppService_Tests.cs @@ -2,9 +2,7 @@ using NSubstitute; using Shouldly; using System.Threading.Tasks; -using Volo.Abp.Clients; using Volo.Abp.Users; -using Volo.Abp.Validation; using Volo.CmsKit.Public.Tags; using Xunit; @@ -31,11 +29,8 @@ namespace Volo.CmsKit.Tags [Fact] public async Task GetAllRelatedTagsAsync() { - var list = await _tagAppService.GetAllRelatedTagsAsync(new GetRelatedTagsInput - { - EntityType = _cmsKitTestData.Content_1_EntityType, - EntityId = _cmsKitTestData.EntityId1 - }); + var list = await _tagAppService.GetAllRelatedTagsAsync(_cmsKitTestData.Content_1_EntityType, + _cmsKitTestData.EntityId1); list.ShouldNotBeEmpty(); list.Count.ShouldBe(2); @@ -44,35 +39,9 @@ namespace Volo.CmsKit.Tags [Fact] public async Task ShouldntGet_GetAllRelatedTagsAsync() { - var list = await _tagAppService.GetAllRelatedTagsAsync(new GetRelatedTagsInput - { - EntityType = "any_other_type", - EntityId = "1" - }); + var list = await _tagAppService.GetAllRelatedTagsAsync("any_other_type", "1"); list.ShouldBeEmpty(); } - - [Fact] - public async Task GetRelatedTagsAsync_ShouldThrowValidationException_WithoutEntityType() - { - await Assert.ThrowsAsync(async () => - await _tagAppService.GetAllRelatedTagsAsync(new GetRelatedTagsInput - { - EntityType = null, - EntityId = _cmsKitTestData.EntityId1 - })); - } - - [Fact] - public async Task GetRelatedTagsAsync_ShouldThrowValidationException_WithoutEntityId() - { - await Assert.ThrowsAsync(async () => - await _tagAppService.GetAllRelatedTagsAsync(new GetRelatedTagsInput - { - EntityType = null, - EntityId = _cmsKitTestData.EntityId1 - })); - } } -} +} \ No newline at end of file From 563a62dc7f53eeb2c9d737f1595a0a2e7d187c15 Mon Sep 17 00:00:00 2001 From: Norbert Bietsch Date: Tue, 5 Jan 2021 15:00:06 +0100 Subject: [PATCH 13/23] Fixes #7025 --- .../Volo/Abp/TextTemplating/TemplateRenderer.cs | 1 + .../Volo.Abp.TextTemplating.Tests.csproj | 4 ++++ .../SampleTemplates/ShowDecimalNumber.tpl | 1 + .../Abp/TextTemplating/TemplateRenderer_Tests.cs | 15 +++++++++++++++ .../TestTemplateDefinitionProvider.cs | 8 ++++++++ .../Volo/Abp/TextTemplating/TestTemplates.cs | 1 + 6 files changed, 30 insertions(+) create mode 100644 framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/SampleTemplates/ShowDecimalNumber.tpl diff --git a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateRenderer.cs b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateRenderer.cs index c7d7b9d016..1d89dc3b68 100644 --- a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateRenderer.cs +++ b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateRenderer.cs @@ -144,6 +144,7 @@ namespace Volo.Abp.TextTemplating } context.PushGlobal(scriptObject); + context.PushCulture(System.Globalization.CultureInfo.CurrentCulture); return context; } diff --git a/framework/test/Volo.Abp.TextTemplating.Tests/Volo.Abp.TextTemplating.Tests.csproj b/framework/test/Volo.Abp.TextTemplating.Tests/Volo.Abp.TextTemplating.Tests.csproj index 555c2934b0..23a817b16b 100644 --- a/framework/test/Volo.Abp.TextTemplating.Tests/Volo.Abp.TextTemplating.Tests.csproj +++ b/framework/test/Volo.Abp.TextTemplating.Tests/Volo.Abp.TextTemplating.Tests.csproj @@ -15,6 +15,10 @@ + + + + diff --git a/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/SampleTemplates/ShowDecimalNumber.tpl b/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/SampleTemplates/ShowDecimalNumber.tpl new file mode 100644 index 0000000000..1c54056382 --- /dev/null +++ b/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/SampleTemplates/ShowDecimalNumber.tpl @@ -0,0 +1 @@ +{{ model.amount}} \ No newline at end of file diff --git a/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TemplateRenderer_Tests.cs b/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TemplateRenderer_Tests.cs index fef287a2b1..74566442c3 100644 --- a/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TemplateRenderer_Tests.cs +++ b/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TemplateRenderer_Tests.cs @@ -91,6 +91,21 @@ namespace Volo.Abp.TextTemplating cultureName: "tr" )).ShouldBe("*BEGIN*Merhaba John, nasılsın?. Please click to the following link to get an email to reset your password!*END*"); } + + [Fact] + public async Task Should_Get_Localized_Numbers() + { + (await _templateRenderer.RenderAsync( + TestTemplates.ShowDecimalNumber, + new Dictionary(new List>{new("amount", 123.45M)}), + cultureName: "en" + )).ShouldBe("*BEGIN*123.45*END*"); + + (await _templateRenderer.RenderAsync( + TestTemplates.ShowDecimalNumber, + new Dictionary(new List>{new("amount", 123.45M)}), + cultureName: "de" + )).ShouldBe("*BEGIN*123,45*END*"); } private class WelcomeEmailModel { diff --git a/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TestTemplateDefinitionProvider.cs b/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TestTemplateDefinitionProvider.cs index af6386e9f7..9db711d70c 100644 --- a/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TestTemplateDefinitionProvider.cs +++ b/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TestTemplateDefinitionProvider.cs @@ -27,6 +27,14 @@ namespace Volo.Abp.TextTemplating isLayout: true ).WithVirtualFilePath("/SampleTemplates/TestTemplateLayout1.tpl", true) ); + + context.Add( + new TemplateDefinition( + TestTemplates.ShowDecimalNumber, + localizationResource: typeof(TestLocalizationSource), + layout: TestTemplates.TestTemplateLayout1 + ).WithVirtualFilePath("/SampleTemplates/ShowDecimalNumber.tpl", true) + ); } } } diff --git a/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TestTemplates.cs b/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TestTemplates.cs index a2b605c213..29a8604f3b 100644 --- a/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TestTemplates.cs +++ b/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TestTemplates.cs @@ -5,5 +5,6 @@ public const string WelcomeEmail = "WelcomeEmail"; public const string ForgotPasswordEmail = "ForgotPasswordEmail"; public const string TestTemplateLayout1 = "TestTemplateLayout1"; + public const string ShowDecimalNumber = "ShowDecimalNumber"; } } \ No newline at end of file From c883e24cd5c7b9c3cfd957efeaea2e73cc4c925a Mon Sep 17 00:00:00 2001 From: GameBelial <243387971@qq.com> Date: Wed, 6 Jan 2021 17:14:11 +0800 Subject: [PATCH 14/23] Fix the problem of path under UNIX-like. --- .../VirtualFiles/LocalizedTemplateContentReaderFactory_Tests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/VirtualFiles/LocalizedTemplateContentReaderFactory_Tests.cs b/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/VirtualFiles/LocalizedTemplateContentReaderFactory_Tests.cs index b1dba4bdb5..63e526ac1d 100644 --- a/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/VirtualFiles/LocalizedTemplateContentReaderFactory_Tests.cs +++ b/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/VirtualFiles/LocalizedTemplateContentReaderFactory_Tests.cs @@ -23,7 +23,7 @@ namespace Volo.Abp.TextTemplating.VirtualFiles var localizedTemplateContentReaderFactory = new LocalizedTemplateContentReaderFactory( new PhysicalFileVirtualFileProvider( new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), - @"Volo\Abp\TextTemplating\")))); + "Volo", "Abp", "TextTemplating")))); var reader = await localizedTemplateContentReaderFactory.CreateAsync(_templateDefinitionManager.Get(TestTemplates.WelcomeEmail)); From 76846b6cac3e1fa9bf0f7e9a897f4a0b8e676567 Mon Sep 17 00:00:00 2001 From: GameBelial <243387971@qq.com> Date: Wed, 6 Jan 2021 17:15:38 +0800 Subject: [PATCH 15/23] Clean up the code. --- .../Volo.Abp.TextTemplating.Tests.csproj | 4 ---- .../Volo/Abp/TextTemplating/TemplateRenderer_Tests.cs | 7 ++++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/framework/test/Volo.Abp.TextTemplating.Tests/Volo.Abp.TextTemplating.Tests.csproj b/framework/test/Volo.Abp.TextTemplating.Tests/Volo.Abp.TextTemplating.Tests.csproj index 23a817b16b..555c2934b0 100644 --- a/framework/test/Volo.Abp.TextTemplating.Tests/Volo.Abp.TextTemplating.Tests.csproj +++ b/framework/test/Volo.Abp.TextTemplating.Tests/Volo.Abp.TextTemplating.Tests.csproj @@ -15,10 +15,6 @@ - - - - diff --git a/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TemplateRenderer_Tests.cs b/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TemplateRenderer_Tests.cs index 74566442c3..ca4ae3e3fd 100644 --- a/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TemplateRenderer_Tests.cs +++ b/framework/test/Volo.Abp.TextTemplating.Tests/Volo/Abp/TextTemplating/TemplateRenderer_Tests.cs @@ -97,15 +97,16 @@ namespace Volo.Abp.TextTemplating { (await _templateRenderer.RenderAsync( TestTemplates.ShowDecimalNumber, - new Dictionary(new List>{new("amount", 123.45M)}), + new Dictionary(new List> {new("amount", 123.45M)}), cultureName: "en" )).ShouldBe("*BEGIN*123.45*END*"); (await _templateRenderer.RenderAsync( TestTemplates.ShowDecimalNumber, - new Dictionary(new List>{new("amount", 123.45M)}), + new Dictionary(new List> {new("amount", 123.45M)}), cultureName: "de" - )).ShouldBe("*BEGIN*123,45*END*"); } + )).ShouldBe("*BEGIN*123,45*END*"); + } private class WelcomeEmailModel { From ae5dfd86343c056a7a6ca7e77a0a9553ffdd82cb Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 6 Jan 2021 17:27:16 +0800 Subject: [PATCH 16/23] Include symbol files (*.pdb) in the built .nupkg. Resolve #6702 --- common.props | 6 ++---- nupkg/pack.ps1 | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/common.props b/common.props index 39ce965ec0..2d119f7124 100644 --- a/common.props +++ b/common.props @@ -10,10 +10,8 @@ https://github.com/abpframework/abp/ true - - true - snupkg - + + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb diff --git a/nupkg/pack.ps1 b/nupkg/pack.ps1 index 8c1dcdf10c..4799ba36f2 100644 --- a/nupkg/pack.ps1 +++ b/nupkg/pack.ps1 @@ -26,8 +26,6 @@ foreach($project in $projects) { $projectName = $project.Substring($project.LastIndexOf("/") + 1) $projectPackPath = Join-Path $projectFolder ("/bin/Release/" + $projectName + ".*.nupkg") Move-Item $projectPackPath $packFolder - $projectSymbolPackPath = Join-Path $projectFolder ("/bin/Release/" + $projectName + ".*.snupkg") - Move-Item $projectSymbolPackPath $packFolder } # Go back to the pack folder From f48409be6c6f2f6ed745be5b62a63c8ee48d81a5 Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 6 Jan 2021 14:42:23 +0300 Subject: [PATCH 17/23] CmsKit - Add GlobalFeature check to configuration of ModelBuilder --- .../CmsKitDbContextModelCreatingExtensions.cs | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs index 8d32de7958..a0a4ca06d0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs @@ -41,8 +41,8 @@ namespace Volo.CmsKit.EntityFrameworkCore b.ConfigureByConvention(); b.ConfigureAbpUser(); - b.HasIndex(x => new {x.TenantId, x.UserName}); - b.HasIndex(x => new {x.TenantId, x.Email}); + b.HasIndex(x => new { x.TenantId, x.UserName }); + b.HasIndex(x => new { x.TenantId, x.Email }); }); } @@ -93,59 +93,62 @@ namespace Volo.CmsKit.EntityFrameworkCore r.Property(x => x.EntityType).IsRequired().HasMaxLength(RatingConsts.MaxEntityTypeLength); r.Property(x => x.EntityId).IsRequired().HasMaxLength(RatingConsts.MaxEntityIdLength); - r.HasIndex(x => new {x.TenantId, x.EntityType, x.EntityId, x.CreatorId}); + r.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId, x.CreatorId }); }); } builder.Entity(b => { b.ToTable(options.TablePrefix + "Contents", options.Schema); - + b.ConfigureByConvention(); - + b.Property(x => x.EntityType).IsRequired().HasMaxLength(ContentConsts.MaxEntityTypeLength); b.Property(x => x.EntityId).IsRequired().HasMaxLength(ContentConsts.MaxEntityIdLength); b.Property(x => x.Value).IsRequired().HasMaxLength(ContentConsts.MaxValueLength); - + b.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId }); }); - - builder.Entity(b => + + if (GlobalFeatureManager.Instance.IsEnabled()) { - b.ToTable(options.TablePrefix + "Tags", options.Schema); - - b.ConfigureByConvention(); - - b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength); - b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength); - - b.HasIndex(x => new { x.TenantId, x.Name }); - }); - + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Tags", options.Schema); + + b.ConfigureByConvention(); + + b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength); + b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength); + + b.HasIndex(x => new { x.TenantId, x.Name }); + }); + } + builder.Entity(b => { b.ToTable(options.TablePrefix + "EntityTags", options.Schema); - + b.ConfigureByConvention(); b.HasKey(x => new { x.EntityId, x.TagId }); - + b.Property(x => x.EntityId).IsRequired(); b.Property(x => x.TagId).IsRequired(); - + b.HasIndex(x => new { x.TenantId, x.EntityId, x.TagId }); }); - + builder.Entity(b => { b.ToTable(options.TablePrefix + "Pages", options.Schema); - + b.ConfigureByConvention(); - + b.Property(x => x.Title).IsRequired().HasMaxLength(PageConsts.MaxTitleLength); b.Property(x => x.Url).IsRequired().HasMaxLength(PageConsts.MaxUrlLength); b.Property(x => x.Description).HasMaxLength(PageConsts.MaxDescriptionLength); - + b.HasIndex(x => new { x.TenantId, x.Url }); }); } From b94ae17b4ea4f8dcb002e822e3273cd1c6b4c834 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 7 Jan 2021 09:59:09 +0800 Subject: [PATCH 18/23] Update SubmitButton document path. https://github.com/abpframework/abp/issues/6672#issuecomment-755379234 --- docs/en/docs-nav.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 217467e666..c7a7554fdc 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -689,7 +689,7 @@ "items": [ { "text": "SubmitButton", - "path": "UI/Blazor/SubmitButton.md" + "path": "UI/Blazor/Components/SubmitButton.md" } ] }, From 79575ff040747def938f1670f4926afca5b0b988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 7 Jan 2021 09:55:00 +0300 Subject: [PATCH 19/23] #6853 Document improved. --- docs/en/UI/Blazor/Page-Progress.md | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/docs/en/UI/Blazor/Page-Progress.md b/docs/en/UI/Blazor/Page-Progress.md index 14daa41d3c..b1d5b0df12 100644 --- a/docs/en/UI/Blazor/Page-Progress.md +++ b/docs/en/UI/Blazor/Page-Progress.md @@ -1,30 +1,25 @@ # Blazor UI: Page Progress -Page progress is the newest component introduced with Blazorise and ABP Framework. It is used to show scoped page progress on top of the page and to indicate to the user that currently a long running process is in the work. By default you don't need to do anything to show the progress indicator, as all the work is done automatically by the ABP Framework internals. This means that all calls to the ABP backend(through Rest API) will activate page progress and show the loading indicator. +Page Progress is used to show a progress bar indicator on top of the page and to show to the user that currently a long running process is in the work. -This doesn't mean that you don't have the control over it. On the contrary. If you also want to show progress for your own processes, it is really easy to do. All you have to do is to use `IUiPageProgressService`. +By default you don't need to do anything to show the progress indicator, as all the work is done automatically by the ABP Framework internals. This means that all calls to the ABP backend (through your HTTP API) will activate page progress and show the loading indicator. -To use `IUiPageProgressService` you need to inject it into your own Blazor component or page. You have two options of injection. - -1. Parameter injection -2. Constructor injection - -Whichever you chose the end result is the same. In this guide we're going to use parameter injection. So let us begin. +This doesn't mean that you don't have the control over it. On the contrary, if you want to show progress for your own processes, it is really easy to do. All you have to do is to use inject and use the `IUiPageProgressService`. ## Example -First, inject the `IUiPageProgressService` +First, inject the `IUiPageProgressService` into your page/component. ```cs @inject IUiPageProgressService pageProgressService ``` -Next, all you have to do is invoke the `Go` method in `IUiPageProgressService`. It's that simple. +Next, invoke the `Go` method in `IUiPageProgressService`. It's that simple: ```cs Task OnClick() { - return pageProgressService.Go(null); + return pageProgressService.Go(null); } ``` @@ -53,7 +48,7 @@ pageProgressService.Go(25) 1. `null` - show _indeterminate_ indicator 2. `>= 0` and `<= 100` - show the regular _percentage_ progress -## Hiding progress +### Hiding progress To hide the progress just set the actual values to something other then the _Valid value_. From 0adc4afb5cb23e1bc86536b8945f73b4a1558121 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 7 Jan 2021 16:55:45 +0800 Subject: [PATCH 20/23] Set DispatchConsumersAsync to true --- .../Volo/Abp/RabbitMQ/ConnectionPool.cs | 5 ++-- .../Volo/Abp/RabbitMQ/RabbitMqConnections.cs | 6 ++--- .../Abp/RabbitMQ/RabbitMqMessageConsumer.cs | 23 ++++++++----------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/ConnectionPool.cs b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/ConnectionPool.cs index 08d9d48036..5856f7bb16 100644 --- a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/ConnectionPool.cs +++ b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/ConnectionPool.cs @@ -22,8 +22,7 @@ namespace Volo.Abp.RabbitMQ public virtual IConnection Get(string connectionName = null) { - connectionName = connectionName - ?? RabbitMqConnections.DefaultConnectionName; + connectionName ??= RabbitMqConnections.DefaultConnectionName; return Connections.GetOrAdd( connectionName, @@ -58,4 +57,4 @@ namespace Volo.Abp.RabbitMQ Connections.Clear(); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqConnections.cs b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqConnections.cs index a30db4c96a..f2b5168d82 100644 --- a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqConnections.cs +++ b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqConnections.cs @@ -9,7 +9,7 @@ namespace Volo.Abp.RabbitMQ public class RabbitMqConnections : Dictionary { public const string DefaultConnectionName = "Default"; - + [NotNull] public ConnectionFactory Default { @@ -19,7 +19,7 @@ namespace Volo.Abp.RabbitMQ public RabbitMqConnections() { - Default = new ConnectionFactory(); + Default = new ConnectionFactory() { DispatchConsumersAsync = true }; } public ConnectionFactory GetOrDefault(string connectionName) @@ -32,4 +32,4 @@ namespace Volo.Abp.RabbitMQ return Default; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs index fb1b0c7fe2..b94663d886 100644 --- a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs +++ b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs @@ -143,10 +143,10 @@ namespace Volo.Abp.RabbitMQ try { - var channel = ConnectionPool + Channel = ConnectionPool .Get(ConnectionName) .CreateModel(); - channel.ExchangeDeclare( + Channel.ExchangeDeclare( exchange: Exchange.ExchangeName, type: Exchange.Type, durable: Exchange.Durable, @@ -154,7 +154,7 @@ namespace Volo.Abp.RabbitMQ arguments: Exchange.Arguments ); - channel.QueueDeclare( + Channel.QueueDeclare( queue: Queue.QueueName, durable: Queue.Durable, exclusive: Queue.Exclusive, @@ -162,19 +162,14 @@ namespace Volo.Abp.RabbitMQ arguments: Queue.Arguments ); - var consumer = new EventingBasicConsumer(channel); - consumer.Received += async (model, basicDeliverEventArgs) => - { - await HandleIncomingMessageAsync(channel, basicDeliverEventArgs); - }; + var consumer = new AsyncEventingBasicConsumer(Channel); + consumer.Received += HandleIncomingMessageAsync; - channel.BasicConsume( + Channel.BasicConsume( queue: Queue.QueueName, autoAck: false, consumer: consumer ); - - Channel = channel; } catch (Exception ex) { @@ -183,16 +178,16 @@ namespace Volo.Abp.RabbitMQ } } - protected virtual async Task HandleIncomingMessageAsync(IModel channel, BasicDeliverEventArgs basicDeliverEventArgs) + protected virtual async Task HandleIncomingMessageAsync(object sender, BasicDeliverEventArgs basicDeliverEventArgs) { try { foreach (var callback in Callbacks) { - await callback(channel, basicDeliverEventArgs); + await callback(Channel, basicDeliverEventArgs); } - channel.BasicAck(basicDeliverEventArgs.DeliveryTag, multiple: false); + Channel.BasicAck(basicDeliverEventArgs.DeliveryTag, multiple: false); } catch (Exception ex) { From e8a4f89fd25c6a4ab7dfc307ccc7cc93ee5941a7 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 7 Jan 2021 13:10:38 +0300 Subject: [PATCH 21/23] replace forRoot with withConfig --- .../theme-basic/testing/src/lib/theme-basic-testing.module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/theme-basic/testing/src/lib/theme-basic-testing.module.ts b/npm/ng-packs/packages/theme-basic/testing/src/lib/theme-basic-testing.module.ts index 7df6d40231..0bcab2ed08 100644 --- a/npm/ng-packs/packages/theme-basic/testing/src/lib/theme-basic-testing.module.ts +++ b/npm/ng-packs/packages/theme-basic/testing/src/lib/theme-basic-testing.module.ts @@ -12,7 +12,7 @@ import { VALIDATION_ERROR_TEMPLATE, VALIDATION_TARGET_SELECTOR } from '@ngx-vali imports: [BaseThemeBasicModule], }) export class ThemeBasicTestingModule { - static forRoot(): ModuleWithProviders { + static withConfig(): ModuleWithProviders { return { ngModule: ThemeBasicTestingModule, providers: [ From a75b26cc30fd4b7da385121e31994efb388bdf76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 7 Jan 2021 15:08:05 +0300 Subject: [PATCH 22/23] Add more claims to the access token. --- .../Abp/IdentityServer/AbpClaimsService.cs | 28 +++++++++++++++---- .../AbpResourceOwnerPasswordValidator.cs | 7 ++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpClaimsService.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpClaimsService.cs index c60c241209..3e6a7c76b2 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpClaimsService.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpClaimsService.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; +using IdentityModel; using IdentityServer4.Services; using Microsoft.Extensions.Logging; using Volo.Abp.Security.Claims; @@ -9,6 +10,16 @@ namespace Volo.Abp.IdentityServer { public class AbpClaimsService : DefaultClaimsService { + private static readonly string[] AdditionalOptionalClaimNames = + { + AbpClaimTypes.TenantId, + AbpClaimTypes.Name, + AbpClaimTypes.SurName, + JwtClaimTypes.PreferredUserName, + JwtClaimTypes.GivenName, + JwtClaimTypes.FamilyName, + }; + public AbpClaimsService(IProfileService profile, ILogger logger) : base(profile, logger) { @@ -16,13 +27,20 @@ namespace Volo.Abp.IdentityServer protected override IEnumerable GetOptionalClaims(ClaimsPrincipal subject) { - var tenantClaim = subject.FindFirst(AbpClaimTypes.TenantId); - if (tenantClaim == null) + return base.GetOptionalClaims(subject) + .Union(GetAdditionalOptionalClaims(subject)); + } + + protected virtual IEnumerable GetAdditionalOptionalClaims(ClaimsPrincipal subject) + { + foreach (var claimName in AdditionalOptionalClaimNames) { - return base.GetOptionalClaims(subject); + var claim = subject.FindFirst(claimName); + if (claim != null) + { + yield return claim; + } } - - return base.GetOptionalClaims(subject).Union(new[] { tenantClaim }); } } } diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpResourceOwnerPasswordValidator.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpResourceOwnerPasswordValidator.cs index eee4c001ed..e024976548 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpResourceOwnerPasswordValidator.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpResourceOwnerPasswordValidator.cs @@ -200,7 +200,12 @@ namespace Volo.Abp.IdentityServer.AspNetIdentity { if (user.TenantId.HasValue) { - customClaims.Add(new Claim(AbpClaimTypes.TenantId, user.TenantId?.ToString())); + customClaims.Add( + new Claim( + AbpClaimTypes.TenantId, + user.TenantId?.ToString() + ) + ); } return Task.CompletedTask; From 0f786308893ebb8bccdd5e4875d508f6f7ca476c Mon Sep 17 00:00:00 2001 From: enisn Date: Thu, 7 Jan 2021 15:21:53 +0300 Subject: [PATCH 23/23] Fix syntax error at CmsKitDbContextModelCreatingExtensions --- .../CmsKitDbContextModelCreatingExtensions.cs | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs index d089a8fe9d..8e3b7160db 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs @@ -99,16 +99,19 @@ namespace Volo.CmsKit.EntityFrameworkCore if (GlobalFeatureManager.Instance.IsEnabled()) { - b.ToTable(options.TablePrefix + "Contents", options.Schema); + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Contents", options.Schema); - b.ConfigureByConvention(); + b.ConfigureByConvention(); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(ContentConsts.MaxEntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(ContentConsts.MaxEntityIdLength); - b.Property(x => x.Value).IsRequired().HasMaxLength(ContentConsts.MaxValueLength); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(ContentConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(ContentConsts.MaxEntityIdLength); + b.Property(x => x.Value).IsRequired().HasMaxLength(ContentConsts.MaxValueLength); - b.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId }); - }); + b.HasIndex(x => new { x.TenantId, x.EntityType, x.EntityId }); + }); + } if (GlobalFeatureManager.Instance.IsEnabled()) { @@ -121,7 +124,11 @@ namespace Volo.CmsKit.EntityFrameworkCore b.Property(x => x.EntityType).IsRequired().HasMaxLength(TagConsts.MaxEntityTypeLength); b.Property(x => x.Name).IsRequired().HasMaxLength(TagConsts.MaxNameLength); - b.HasIndex(x => new { x.TenantId, x.Name }); + b.HasIndex(x => new + { + x.TenantId, + x.Name + }); }); builder.Entity(b => @@ -151,7 +158,7 @@ namespace Volo.CmsKit.EntityFrameworkCore b.Property(x => x.Url).IsRequired().HasMaxLength(PageConsts.MaxUrlLength); b.Property(x => x.Description).HasMaxLength(PageConsts.MaxDescriptionLength); - b.HasIndex(x => new {x.TenantId, x.Url}); + b.HasIndex(x => new { x.TenantId, x.Url }); }); } }