From f72f7379b3bf084a7aaab36e92d999db2a69ec63 Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Thu, 13 Aug 2020 08:57:56 +0800 Subject: [PATCH 001/190] Upgrade Swashbuckle.AspNetCore to 5.5.1 --- .../app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj | 2 +- .../Volo.CmsKit.HttpApi.Host/Volo.CmsKit.HttpApi.Host.csproj | 2 +- .../Volo.CmsKit.IdentityServer.csproj | 2 +- .../host/Volo.CmsKit.Web.Host/Volo.CmsKit.Web.Host.csproj | 2 +- .../host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj | 2 +- modules/docs/app/VoloDocs.Web/VoloDocs.Web.csproj | 2 +- .../MyCompanyName.MyProjectName.HttpApi.Host.csproj | 2 +- .../MyCompanyName.MyProjectName.HttpApi.HostWithIds.csproj | 2 +- .../MyCompanyName.MyProjectName.Web.Host.csproj | 2 +- .../MyCompanyName.MyProjectName.Web.csproj | 2 +- .../MyCompanyName.MyProjectName.HttpApi.Host.csproj | 2 +- .../MyCompanyName.MyProjectName.IdentityServer.csproj | 2 +- .../MyCompanyName.MyProjectName.Web.Host.csproj | 2 +- .../MyCompanyName.MyProjectName.Web.Unified.csproj | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj b/modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj index 4fb4e461af..5d56d83ec9 100644 --- a/modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj +++ b/modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj @@ -17,7 +17,7 @@ - + diff --git a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Volo.CmsKit.HttpApi.Host.csproj b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Volo.CmsKit.HttpApi.Host.csproj index 2a0c5e57c1..9fa7c4be20 100644 --- a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Volo.CmsKit.HttpApi.Host.csproj +++ b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/Volo.CmsKit.HttpApi.Host.csproj @@ -12,7 +12,7 @@ - + diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Volo.CmsKit.IdentityServer.csproj b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Volo.CmsKit.IdentityServer.csproj index da90915bf2..b26c2bbe06 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Volo.CmsKit.IdentityServer.csproj +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Volo.CmsKit.IdentityServer.csproj @@ -10,7 +10,7 @@ - + diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/Volo.CmsKit.Web.Host.csproj b/modules/cms-kit/host/Volo.CmsKit.Web.Host/Volo.CmsKit.Web.Host.csproj index 46b83d5180..e58aa309c6 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/Volo.CmsKit.Web.Host.csproj +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/Volo.CmsKit.Web.Host.csproj @@ -12,7 +12,7 @@ - + diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj index d500cbce2d..e3436aaa93 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj @@ -12,7 +12,7 @@ - + diff --git a/modules/docs/app/VoloDocs.Web/VoloDocs.Web.csproj b/modules/docs/app/VoloDocs.Web/VoloDocs.Web.csproj index 2e06315603..d2f04bb1f5 100644 --- a/modules/docs/app/VoloDocs.Web/VoloDocs.Web.csproj +++ b/modules/docs/app/VoloDocs.Web/VoloDocs.Web.csproj @@ -19,7 +19,7 @@ - + diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj index 2776d2ed85..71b248c32e 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj @@ -13,7 +13,7 @@ - + diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyCompanyName.MyProjectName.HttpApi.HostWithIds.csproj b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyCompanyName.MyProjectName.HttpApi.HostWithIds.csproj index c7faed9653..373d19dcfb 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyCompanyName.MyProjectName.HttpApi.HostWithIds.csproj +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyCompanyName.MyProjectName.HttpApi.HostWithIds.csproj @@ -13,7 +13,7 @@ - + diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj index 469d83804c..777288a513 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj @@ -19,7 +19,7 @@ - + diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj index de399f2ef5..eb374cb80e 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj @@ -35,7 +35,7 @@ - + diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj index 589ec5df65..35e73d4868 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj @@ -12,7 +12,7 @@ - + diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj index 17f9cdb076..c70808deed 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj @@ -10,7 +10,7 @@ - + diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj index 3923a71691..f9e00d53d3 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj @@ -12,7 +12,7 @@ - + diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyCompanyName.MyProjectName.Web.Unified.csproj b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyCompanyName.MyProjectName.Web.Unified.csproj index 3cd14d2086..8f278d0a03 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyCompanyName.MyProjectName.Web.Unified.csproj +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyCompanyName.MyProjectName.Web.Unified.csproj @@ -12,7 +12,7 @@ - + From 429bf596a1c59340987a675b56c87b26b371a447 Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Thu, 13 Aug 2020 10:19:23 +0800 Subject: [PATCH 002/190] Add Identity service error page to account module. --- .../AbpAccountWebIdentityServerModule.cs | 9 ++++- .../Pages/Account/Error.cshtml | 24 ++++++++++++ .../Pages/Account/Error.cshtml.cs | 37 +++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Error.cshtml create mode 100644 modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Error.cshtml.cs diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/AbpAccountWebIdentityServerModule.cs b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/AbpAccountWebIdentityServerModule.cs index 273659fd69..bf76e1dbe3 100644 --- a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/AbpAccountWebIdentityServerModule.cs +++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/AbpAccountWebIdentityServerModule.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Identity; +using IdentityServer4.Configuration; +using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Identity.AspNetCore; using Volo.Abp.IdentityServer; @@ -33,6 +34,12 @@ namespace Volo.Abp.Account.Web options.FileSets.AddEmbedded(); }); + Configure(options => + { + options.UserInteraction.ConsentUrl = "/Consent"; + options.UserInteraction.ErrorUrl = "/Account/Error"; + }); + //TODO: Try to reuse from AbpIdentityAspNetCoreModule context.Services .AddAuthentication(o => diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Error.cshtml b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Error.cshtml new file mode 100644 index 0000000000..2b43f1527c --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Error.cshtml @@ -0,0 +1,24 @@ +@page +@using Localization.Resources.AbpUi +@using Microsoft.AspNetCore.Mvc.Localization +@model Volo.Abp.Account.Web.Pages.Account.ErrorModel +@inject IHtmlLocalizer L +@{ + var errorMessage = Model.ErrorMessage.Error; + var errorDetails = Model.ErrorMessage.ErrorDescription; + if (errorDetails.IsNullOrEmpty()) + { + errorDetails = errorMessage; + errorMessage = L["Error"].Value + "!"; + } +} + +

+ @errorMessage +

+ +
+

+ @errorDetails +

+
diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Error.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Error.cshtml.cs new file mode 100644 index 0000000000..bae4eb380e --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Error.cshtml.cs @@ -0,0 +1,37 @@ +using System.Threading.Tasks; +using IdentityServer4.Models; +using IdentityServer4.Services; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; + +namespace Volo.Abp.Account.Web.Pages.Account +{ + public class ErrorModel : AbpPageModel + { + public ErrorMessage ErrorMessage { get; set; } + + private readonly IIdentityServerInteractionService _interaction; + private readonly IWebHostEnvironment _environment; + + public ErrorModel(IIdentityServerInteractionService interaction, IWebHostEnvironment environment) + { + _interaction = interaction; + _environment = environment; + } + + public async Task OnGet(string errorId) + { + ErrorMessage = await _interaction.GetErrorContextAsync(errorId); + + if (ErrorMessage != null) + { + if (!_environment.IsDevelopment()) + { + // Only show in development + ErrorMessage.ErrorDescription = null; + } + } + } + } +} From daf7febe7c87ff8ec81927b6d5bb18778afe0ee4 Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Thu, 13 Aug 2020 10:30:44 +0800 Subject: [PATCH 003/190] Handle ErrorMessage is null. --- .../Pages/Account/Error.cshtml.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Error.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Error.cshtml.cs index bae4eb380e..90622f7dc3 100644 --- a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Error.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Error.cshtml.cs @@ -22,7 +22,10 @@ namespace Volo.Abp.Account.Web.Pages.Account public async Task OnGet(string errorId) { - ErrorMessage = await _interaction.GetErrorContextAsync(errorId); + ErrorMessage = await _interaction.GetErrorContextAsync(errorId) ?? new ErrorMessage + { + Error = L["Error"] + }; if (ErrorMessage != null) { From 483210edb23e61b26bd691cbf0e28083b4659d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 13 Aug 2020 10:09:03 +0300 Subject: [PATCH 004/190] Add authorization code grant to the App client (the angular client). --- .../appsettings.json | 3 ++- .../IdentityServerDataSeedContributor.cs | 23 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json index d45a2093e7..17ce15c462 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json @@ -11,7 +11,8 @@ }, "MyProjectName_App": { "ClientId": "MyProjectName_App", - "ClientSecret": "1q2w3e*" + "ClientSecret": "1q2w3e*", + "RootUrl": "http://localhost:4200" } } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs index 2bce06c77d..805bc0e424 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs @@ -126,15 +126,20 @@ namespace MyCompanyName.MyProjectName.IdentityServer ); } - //Console Test Client - var consoleClientId = configurationSection["MyProjectName_App:ClientId"]; - if (!consoleClientId.IsNullOrWhiteSpace()) + //Console Test / Angular Client + var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"]; + if (!consoleAndAngularClientId.IsNullOrWhiteSpace()) { + var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/'); + await CreateClientAsync( - name: consoleClientId, + name: consoleAndAngularClientId, scopes: commonScopes, - grantTypes: new[] {"password", "client_credentials"}, - secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256() + grantTypes: new[] {"password", "client_credentials", "authorization_code"}, + secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(), + requireClientSecret: false, + redirectUri: webClientRootUrl, + postLogoutRedirectUri: webClientRootUrl ); } } @@ -147,6 +152,8 @@ namespace MyCompanyName.MyProjectName.IdentityServer string redirectUri = null, string postLogoutRedirectUri = null, string frontChannelLogoutUri = null, + bool requireClientSecret = true, + bool requirePkce = false, IEnumerable permissions = null) { var client = await _clientRepository.FindByCliendIdAsync(name); @@ -168,7 +175,9 @@ namespace MyCompanyName.MyProjectName.IdentityServer AuthorizationCodeLifetime = 300, IdentityTokenLifetime = 300, RequireConsent = false, - FrontChannelLogoutUri = frontChannelLogoutUri + FrontChannelLogoutUri = frontChannelLogoutUri, + RequireClientSecret = requireClientSecret, + RequirePkce = requirePkce }, autoSave: true ); From 1b352cef4d707b4eae6cb336d21afe7ea5a5b5fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 13 Aug 2020 11:15:17 +0300 Subject: [PATCH 005/190] Double check _requestLocalizationOptions --- ...ltAbpRequestLocalizationOptionsProvider.cs | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) 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 64f339ffce..263d0532d0 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/DefaultAbpRequestLocalizationOptionsProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/DefaultAbpRequestLocalizationOptionsProvider.cs @@ -50,35 +50,38 @@ namespace Microsoft.AspNetCore.RequestLocalization { using (await _syncSemaphore.LockAsync()) { - using (var serviceScope = _serviceProviderFactory.CreateScope()) + if (_requestLocalizationOptions == null) { - var languageProvider = serviceScope.ServiceProvider.GetRequiredService(); - var settingProvider = serviceScope.ServiceProvider.GetRequiredService(); + using (var serviceScope = _serviceProviderFactory.CreateScope()) + { + var languageProvider = serviceScope.ServiceProvider.GetRequiredService(); + var settingProvider = serviceScope.ServiceProvider.GetRequiredService(); - var languages = await languageProvider.GetLanguagesAsync(); - var defaultLanguage = await settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); + var languages = await languageProvider.GetLanguagesAsync(); + var defaultLanguage = await settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); - var options = !languages.Any() - ? new RequestLocalizationOptions() - : new RequestLocalizationOptions - { - DefaultRequestCulture = DefaultGetRequestCulture(defaultLanguage, languages), + var options = !languages.Any() + ? new RequestLocalizationOptions() + : new RequestLocalizationOptions + { + DefaultRequestCulture = DefaultGetRequestCulture(defaultLanguage, languages), - SupportedCultures = languages - .Select(l => l.CultureName) - .Distinct() - .Select(c => new CultureInfo(c)) - .ToArray(), + SupportedCultures = languages + .Select(l => l.CultureName) + .Distinct() + .Select(c => new CultureInfo(c)) + .ToArray(), - SupportedUICultures = languages - .Select(l => l.UiCultureName) - .Distinct() - .Select(c => new CultureInfo(c)) - .ToArray() - }; + SupportedUICultures = languages + .Select(l => l.UiCultureName) + .Distinct() + .Select(c => new CultureInfo(c)) + .ToArray() + }; - _optionsAction?.Invoke(options); - _requestLocalizationOptions = options; + _optionsAction?.Invoke(options); + _requestLocalizationOptions = options; + } } } } @@ -98,4 +101,4 @@ namespace Microsoft.AspNetCore.RequestLocalization return new RequestCulture(cultureName, uiCultureName); } } -} \ No newline at end of file +} From c4727896f7d9d7bf7927839f267b701ce8183740 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Thu, 13 Aug 2020 11:19:42 +0300 Subject: [PATCH 006/190] update Identity Localization --- .../Volo/Abp/Identity/Localization/en.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json index bcc2108fe5..6d8a5c58c5 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json @@ -84,10 +84,10 @@ "DisplayName:Abp.Identity.Lockout.LockoutDuration": "Lockout duration(seconds)", "DisplayName:Abp.Identity.Lockout.MaxFailedAccessAttempts": "Max failed access attempts", "DisplayName:Abp.Identity.SignIn.RequireConfirmedEmail": "Require confirmed email", - "DisplayName:Abp.Identity.SignIn.EnablePhoneNumberConfirmation": "Enable phone number confirmation", - "DisplayName:Abp.Identity.SignIn.RequireConfirmedPhoneNumber": "Require confirmed phoneNumber", - "DisplayName:Abp.Identity.User.IsUserNameUpdateEnabled": "Is username update enabled", - "DisplayName:Abp.Identity.User.IsEmailUpdateEnabled": "Is email update enabled", + "DisplayName:Abp.Identity.SignIn.EnablePhoneNumberConfirmation": "Allow users to confirm their phone number", + "DisplayName:Abp.Identity.SignIn.RequireConfirmedPhoneNumber": "Require confirmed phone number", + "DisplayName:Abp.Identity.User.IsUserNameUpdateEnabled": "Allow users to change their usernames", + "DisplayName:Abp.Identity.User.IsEmailUpdateEnabled": "Allow users to change their email addresses", "Description:Abp.Identity.Password.RequiredLength": "The minimum length a password must be.", "Description:Abp.Identity.Password.RequiredUniqueChars": "The minimum number of unique characters which a password must contain.", "Description:Abp.Identity.Password.RequireNonAlphanumeric": "If passwords must contain a non-alphanumeric character.", From 31fcfbb4ffd9050d07fb7e1e03bf7f857dfb6bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 13 Aug 2020 12:30:38 +0300 Subject: [PATCH 007/190] Resolved #5043: Move AbpRequestLocalization middleware on top of all in the startup template --- .../MyProjectNameHttpApiHostModule.cs | 6 ++++-- .../MyProjectNameHttpApiHostModule.cs | 6 ++++-- .../MyProjectNameIdentityServerModule.cs | 6 ++++-- .../MyProjectNameWebModule.cs | 6 ++++-- .../MyProjectNameWebModule.cs | 6 ++++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs index 7e7817ae87..3771a1874d 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs @@ -167,7 +167,10 @@ namespace MyCompanyName.MyProjectName { app.UseDeveloperExceptionPage(); } - else + + app.UseAbpRequestLocalization(); + + if (!env.IsDevelopment()) { app.UseErrorPage(); } @@ -183,7 +186,6 @@ namespace MyCompanyName.MyProjectName app.UseMultiTenancy(); } - app.UseAbpRequestLocalization(); app.UseAuthorization(); app.UseSwagger(); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs index c671d0f223..95a26d9084 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs @@ -160,7 +160,10 @@ namespace MyCompanyName.MyProjectName { app.UseDeveloperExceptionPage(); } - else + + app.UseAbpRequestLocalization(); + + if (!env.IsDevelopment()) { app.UseErrorPage(); } @@ -177,7 +180,6 @@ namespace MyCompanyName.MyProjectName app.UseMultiTenancy(); } - app.UseAbpRequestLocalization(); app.UseIdentityServer(); app.UseAuthorization(); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs index df28fe0ccd..8a4e919161 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs @@ -143,7 +143,10 @@ namespace MyCompanyName.MyProjectName { app.UseDeveloperExceptionPage(); } - else + + app.UseAbpRequestLocalization(); + + if (!env.IsDevelopment()) { app.UseErrorPage(); } @@ -159,7 +162,6 @@ namespace MyCompanyName.MyProjectName app.UseMultiTenancy(); } - app.UseAbpRequestLocalization(); app.UseIdentityServer(); app.UseAuthorization(); app.UseAuditing(); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs index 689fe33eca..699db2cec0 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs @@ -215,7 +215,10 @@ namespace MyCompanyName.MyProjectName.Web { app.UseDeveloperExceptionPage(); } - else + + app.UseAbpRequestLocalization(); + + if (!env.IsDevelopment()) { app.UseErrorPage(); } @@ -230,7 +233,6 @@ namespace MyCompanyName.MyProjectName.Web app.UseMultiTenancy(); } - app.UseAbpRequestLocalization(); app.UseAuthorization(); app.UseSwagger(); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs index 1bafd38d5a..cf201f90cc 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs @@ -191,7 +191,10 @@ namespace MyCompanyName.MyProjectName.Web { app.UseDeveloperExceptionPage(); } - else + + app.UseAbpRequestLocalization(); + + if (!env.IsDevelopment()) { app.UseErrorPage(); } @@ -207,7 +210,6 @@ namespace MyCompanyName.MyProjectName.Web app.UseMultiTenancy(); } - app.UseAbpRequestLocalization(); app.UseIdentityServer(); app.UseAuthorization(); app.UseSwagger(); From fc2cd29f2e58a87f7d64e8076f167cbe23ee0914 Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Thu, 13 Aug 2020 17:44:46 +0800 Subject: [PATCH 008/190] Add PredicateBuilder class. Resolve #5039 --- .../System/Linq/PredicateOperator.cs | 284 ++++++++++++++++++ .../System/Linq/PredicateBuilder_Tests.cs | 72 +++++ 2 files changed, 356 insertions(+) create mode 100644 framework/src/Volo.Abp.Core/System/Linq/PredicateOperator.cs create mode 100644 framework/test/Volo.Abp.Core.Tests/System/Linq/PredicateBuilder_Tests.cs diff --git a/framework/src/Volo.Abp.Core/System/Linq/PredicateOperator.cs b/framework/src/Volo.Abp.Core/System/Linq/PredicateOperator.cs new file mode 100644 index 0000000000..a2dd9c3bee --- /dev/null +++ b/framework/src/Volo.Abp.Core/System/Linq/PredicateOperator.cs @@ -0,0 +1,284 @@ +using System.Collections.ObjectModel; +using System.Linq.Expressions; +using JetBrains.Annotations; + +namespace System.Linq +{ + // Codes below are taken from https://github.com/scottksmith95/LINQKit project. + + /// The Predicate Operator + public enum PredicateOperator + { + /// The "Or" + Or, + + /// The "And" + And + } + + /// + /// See http://www.albahari.com/expressions for information and examples. + /// + public static class PredicateBuilder + { + private class RebindParameterVisitor : ExpressionVisitor + { + private readonly ParameterExpression _oldParameter; + private readonly ParameterExpression _newParameter; + + public RebindParameterVisitor(ParameterExpression oldParameter, ParameterExpression newParameter) + { + _oldParameter = oldParameter; + _newParameter = newParameter; + } + + protected override Expression VisitParameter(ParameterExpression node) + { + if (node == _oldParameter) + { + return _newParameter; + } + + return base.VisitParameter(node); + } + } + + /// Start an expression + public static ExpressionStarter New(Expression> expr = null) + { + return new ExpressionStarter(expr); + } + + /// Create an expression with a stub expression true or false to use when the expression is not yet started. + public static ExpressionStarter New(bool defaultExpression) + { + return new ExpressionStarter(defaultExpression); + } + + /// Always true + [Obsolete("Use PredicateBuilder.New() instead.")] + public static Expression> True() + { + return new ExpressionStarter(true); + } + + /// Always false + [Obsolete("Use PredicateBuilder.New() instead.")] + public static Expression> False() + { + return new ExpressionStarter(false); + } + + /// OR + public static Expression> Or([NotNull] this Expression> expr1, + [NotNull] Expression> expr2) + { + var expr2Body = new RebindParameterVisitor(expr2.Parameters[0], expr1.Parameters[0]).Visit(expr2.Body); + return Expression.Lambda>(Expression.OrElse(expr1.Body, expr2Body), expr1.Parameters); + } + + /// AND + public static Expression> And([NotNull] this Expression> expr1, + [NotNull] Expression> expr2) + { + var expr2Body = new RebindParameterVisitor(expr2.Parameters[0], expr1.Parameters[0]).Visit(expr2.Body); + return Expression.Lambda>(Expression.AndAlso(expr1.Body, expr2Body), expr1.Parameters); + } + + /// + /// Extends the specified source Predicate with another Predicate and the specified PredicateOperator. + /// + /// The type + /// The source Predicate. + /// The second Predicate. + /// The Operator (can be "And" or "Or"). + /// Expression{Func{T, bool}} + public static Expression> Extend([NotNull] this Expression> first, + [NotNull] Expression> second, PredicateOperator @operator = PredicateOperator.Or) + { + return @operator == PredicateOperator.Or ? first.Or(second) : first.And(second); + } + + /// + /// Extends the specified source Predicate with another Predicate and the specified PredicateOperator. + /// + /// The type + /// The source Predicate. + /// The second Predicate. + /// The Operator (can be "And" or "Or"). + /// Expression{Func{T, bool}} + public static Expression> Extend([NotNull] this ExpressionStarter first, + [NotNull] Expression> second, PredicateOperator @operator = PredicateOperator.Or) + { + return @operator == PredicateOperator.Or ? first.Or(second) : first.And(second); + } + } + + /// + /// ExpressionStarter{T} which eliminates the default 1=0 or 1=1 stub expressions + /// + /// The type + public class ExpressionStarter + { + public ExpressionStarter() : this(false) + { + } + + public ExpressionStarter(bool defaultExpression) + { + if (defaultExpression) + DefaultExpression = f => true; + else + DefaultExpression = f => false; + } + + public ExpressionStarter(Expression> exp) : this(false) + { + _predicate = exp; + } + + /// The actual Predicate. It can only be set by calling Start. + private Expression> Predicate => + (IsStarted || !UseDefaultExpression) ? _predicate : DefaultExpression; + + private Expression> _predicate; + + /// Determines if the predicate is started. + public bool IsStarted => _predicate != null; + + /// A default expression to use only when the expression is null + public bool UseDefaultExpression => DefaultExpression != null; + + /// The default expression + public Expression> DefaultExpression { get; set; } + + /// Set the Expression predicate + /// The first expression + public Expression> Start(Expression> exp) + { + if (IsStarted) + { + throw new Exception("Predicate cannot be started again."); + } + + return _predicate = exp; + } + + /// Or + public Expression> Or([NotNull] Expression> expr2) + { + return (IsStarted) ? _predicate = Predicate.Or(expr2) : Start(expr2); + } + + /// And + public Expression> And([NotNull] Expression> expr2) + { + return (IsStarted) ? _predicate = Predicate.And(expr2) : Start(expr2); + } + + /// Show predicate string + public override string ToString() + { + return Predicate?.ToString(); + } + + #region Implicit Operators + + /// + /// Allows this object to be implicitely converted to an Expression{Func{T, bool}}. + /// + /// + public static implicit operator Expression>(ExpressionStarter right) + { + return right?.Predicate; + } + + /// + /// Allows this object to be implicitely converted to an Expression{Func{T, bool}}. + /// + /// + public static implicit operator Func(ExpressionStarter right) + { + return right == null ? null : + (right.IsStarted || right.UseDefaultExpression) ? right.Predicate.Compile() : null; + } + + /// + /// Allows this object to be implicitely converted to an Expression{Func{T, bool}}. + /// + /// + public static implicit operator ExpressionStarter(Expression> right) + { + return right == null ? null : new ExpressionStarter(right); + } + + #endregion + + #region Implement Expression methods and properties + +#if !(NET35) + + /// + public Func Compile() + { + return Predicate.Compile(); + } +#endif + +#if !(NET35 || WINDOWS_APP || NETSTANDARD || PORTABLE || PORTABLE40 || UAP) + /// + public Func Compile(DebugInfoGenerator debugInfoGenerator) { return Predicate.Compile(debugInfoGenerator); } + + /// + public Expression> Update(Expression body, IEnumerable parameters) { return Predicate.Update(body, parameters); } +#endif + + #endregion + + #region Implement LamdaExpression methods and properties + + /// + public Expression Body => Predicate.Body; + + + /// + public ExpressionType NodeType => Predicate.NodeType; + + /// + public ReadOnlyCollection Parameters => Predicate.Parameters; + + /// + public Type Type => Predicate.Type; + +#if !(NET35) + /// + public string Name => Predicate.Name; + + /// + public Type ReturnType => Predicate.ReturnType; + + /// + public bool TailCall => Predicate.TailCall; +#endif + +#if !(NET35 || WINDOWS_APP || NETSTANDARD || PORTABLE || PORTABLE40 || UAP) + /// + public void CompileToMethod(MethodBuilder method) { Predicate.CompileToMethod(method); } + + /// + public void CompileToMethod(MethodBuilder method, DebugInfoGenerator debugInfoGenerator) { Predicate.CompileToMethod(method, debugInfoGenerator); } + +#endif + + #endregion + + #region Implement Expression methods and properties + +#if !(NET35) + /// + public virtual bool CanReduce => Predicate.CanReduce; +#endif + + #endregion + } +} diff --git a/framework/test/Volo.Abp.Core.Tests/System/Linq/PredicateBuilder_Tests.cs b/framework/test/Volo.Abp.Core.Tests/System/Linq/PredicateBuilder_Tests.cs new file mode 100644 index 0000000000..d28617bc27 --- /dev/null +++ b/framework/test/Volo.Abp.Core.Tests/System/Linq/PredicateBuilder_Tests.cs @@ -0,0 +1,72 @@ +using Shouldly; +using Xunit; + +namespace System.Linq +{ + public class PredicateBuilder_Tests + { + [Fact] + public void Test1() + { + var args = new TestArgs(); + var predicate = PredicateBuilder.New(); + + predicate = predicate.And(t => args.Value == t.Value); + + var func = predicate.Compile(); + + args.Value = true; + var r2 = func(new TestObj { Value = true }); + r2.ShouldBeTrue(); + + args.Value = false; + var r1 = func(new TestObj { Value = false }); + r1.ShouldBeTrue(); + + args = new TestArgs {Value = true}; + var r3 = func(new TestObj { Value = false }); + r3.ShouldBeFalse(); + + args = new TestArgs { Value = false }; + var r4 = func(new TestObj { Value = false }); + r4.ShouldBeTrue(); + } + + [Fact] + public void Test2() + { + var args = new TestArgs(); + var predicate = PredicateBuilder.New(); + + predicate = predicate.And(t => !args.Value); + + var func = predicate.Compile(); + + args.Value = true; + var r2 = func(new TestObj { Value = true }); + r2.ShouldBeFalse(); + + args.Value = false; + var r1 = func(new TestObj { Value = false }); + r1.ShouldBeTrue(); + + args = new TestArgs { Value = true }; + var r3 = func(new TestObj { Value = false }); + r3.ShouldBeFalse(); + + args = new TestArgs { Value = false }; + var r4 = func(new TestObj { Value = false }); + r4.ShouldBeTrue(); + } + + public class TestArgs + { + public bool Value { get; set; } + } + + public class TestObj + { + public bool Value { get; set; } + } + } +} From 362561e8d8ed3bfadfdbada6bc97e3b39857838d Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Thu, 13 Aug 2020 17:47:12 +0800 Subject: [PATCH 009/190] Remove the Obsolete methods. --- .../System/Linq/PredicateOperator.cs | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/framework/src/Volo.Abp.Core/System/Linq/PredicateOperator.cs b/framework/src/Volo.Abp.Core/System/Linq/PredicateOperator.cs index a2dd9c3bee..0732a63110 100644 --- a/framework/src/Volo.Abp.Core/System/Linq/PredicateOperator.cs +++ b/framework/src/Volo.Abp.Core/System/Linq/PredicateOperator.cs @@ -34,12 +34,7 @@ namespace System.Linq protected override Expression VisitParameter(ParameterExpression node) { - if (node == _oldParameter) - { - return _newParameter; - } - - return base.VisitParameter(node); + return node == _oldParameter ? _newParameter : base.VisitParameter(node); } } @@ -55,20 +50,6 @@ namespace System.Linq return new ExpressionStarter(defaultExpression); } - /// Always true - [Obsolete("Use PredicateBuilder.New() instead.")] - public static Expression> True() - { - return new ExpressionStarter(true); - } - - /// Always false - [Obsolete("Use PredicateBuilder.New() instead.")] - public static Expression> False() - { - return new ExpressionStarter(false); - } - /// OR public static Expression> Or([NotNull] this Expression> expr1, [NotNull] Expression> expr2) @@ -127,9 +108,13 @@ namespace System.Linq public ExpressionStarter(bool defaultExpression) { if (defaultExpression) + { DefaultExpression = f => true; + } else + { DefaultExpression = f => false; + } } public ExpressionStarter(Expression> exp) : this(false) From 2a5ab068e779469c36eb04e00c371cbd26f3cf39 Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Thu, 13 Aug 2020 18:00:23 +0800 Subject: [PATCH 010/190] Make the method that use propertyBuildAction obsolete. https://github.com/abpframework/abp/pull/4893#issuecomment-671403321 --- .../EfCoreObjectExtensionInfoExtensions.cs | 2 ++ .../EfCoreObjectExtensionManagerExtensions.cs | 2 ++ .../EfCoreObjectExtensionPropertyInfoExtensions.cs | 1 + ...ObjectExtensionPropertyInfoEfCoreMappingOptions.cs | 11 +++++++++++ 4 files changed, 16 insertions(+) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionInfoExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionInfoExtensions.cs index 91184ecdeb..17b495cdad 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionInfoExtensions.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionInfoExtensions.cs @@ -6,6 +6,7 @@ namespace Volo.Abp.ObjectExtending { public static class EfCoreObjectExtensionInfoExtensions { + [Obsolete("Use MapEfCoreProperty with EntityTypeAndPropertyBuildAction parameters.")] public static ObjectExtensionInfo MapEfCoreProperty( [NotNull] this ObjectExtensionInfo objectExtensionInfo, [NotNull] string propertyName, @@ -18,6 +19,7 @@ namespace Volo.Abp.ObjectExtending ); } + [Obsolete("Use MapEfCoreProperty with EntityTypeAndPropertyBuildAction parameters.")] public static ObjectExtensionInfo MapEfCoreProperty( [NotNull] this ObjectExtensionInfo objectExtensionInfo, [NotNull] Type propertyType, diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionManagerExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionManagerExtensions.cs index cf6d0e1368..14fcc93784 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionManagerExtensions.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionManagerExtensions.cs @@ -39,6 +39,7 @@ namespace Volo.Abp.ObjectExtending ); } + [Obsolete("Use MapEfCoreProperty with EntityTypeAndPropertyBuildAction parameters.")] public static ObjectExtensionManager MapEfCoreProperty( [NotNull] this ObjectExtensionManager objectExtensionManager, [NotNull] string propertyName, @@ -53,6 +54,7 @@ namespace Volo.Abp.ObjectExtending ); } + [Obsolete("Use MapEfCoreProperty with EntityTypeAndPropertyBuildAction parameters.")] public static ObjectExtensionManager MapEfCoreProperty( [NotNull] this ObjectExtensionManager objectExtensionManager, [NotNull] Type entityType, diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionPropertyInfoExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionPropertyInfoExtensions.cs index 9fb466c4cd..90b26390d2 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionPropertyInfoExtensions.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionPropertyInfoExtensions.cs @@ -23,6 +23,7 @@ namespace Volo.Abp.ObjectExtending return propertyExtension; } + [Obsolete("Use MapEfCore with EntityTypeAndPropertyBuildAction parameters.")] [NotNull] public static ObjectExtensionPropertyInfo MapEfCore( [NotNull] this ObjectExtensionPropertyInfo propertyExtension, diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoEfCoreMappingOptions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoEfCoreMappingOptions.cs index 15a818478b..86f1b16a76 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoEfCoreMappingOptions.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoEfCoreMappingOptions.cs @@ -12,12 +12,14 @@ namespace Volo.Abp.ObjectExtending [NotNull] public ObjectExtensionInfo ObjectExtension => ExtensionProperty.ObjectExtension; + [Obsolete("Use EntityTypeAndPropertyBuildAction property.")] [CanBeNull] public Action PropertyBuildAction { get; set; } [CanBeNull] public Action EntityTypeAndPropertyBuildAction { get; set; } + [Obsolete("Use other constructors.")] public ObjectExtensionPropertyInfoEfCoreMappingOptions( [NotNull] ObjectExtensionPropertyInfo extensionProperty, [CanBeNull] Action propertyBuildAction = null, @@ -28,5 +30,14 @@ namespace Volo.Abp.ObjectExtending PropertyBuildAction = propertyBuildAction; EntityTypeAndPropertyBuildAction = entityTypeAndPropertyBuildAction; } + + public ObjectExtensionPropertyInfoEfCoreMappingOptions( + [NotNull] ObjectExtensionPropertyInfo extensionProperty, + [CanBeNull] Action entityTypeAndPropertyBuildAction = null) + { + ExtensionProperty = Check.NotNull(extensionProperty, nameof(extensionProperty)); + + EntityTypeAndPropertyBuildAction = entityTypeAndPropertyBuildAction; + } } } From 2664c4ee5d9aea49e253e0106cbb23932f88a2ee Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Thu, 13 Aug 2020 13:14:52 +0300 Subject: [PATCH 011/190] feat: added action callback to EntityProp #5047 --- npm/ng-packs/.vscode/settings.json | 4 +--- .../extensible-table/extensible-table.component.html | 2 ++ .../extensible-table/extensible-table.component.ts | 5 +++++ .../theme-shared/extensions/src/lib/models/entity-props.ts | 4 ++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/npm/ng-packs/.vscode/settings.json b/npm/ng-packs/.vscode/settings.json index a04bf7ca0c..9c2678df08 100644 --- a/npm/ng-packs/.vscode/settings.json +++ b/npm/ng-packs/.vscode/settings.json @@ -18,9 +18,7 @@ "titleBar.inactiveForeground": "#e7e7e799", "statusBar.background": "#1d70a2", "statusBarItem.hoverBackground": "#258ecd", - "statusBar.foreground": "#e7e7e7", - "statusBar.border": "#1d70a2", - "titleBar.border": "#1d70a2" + "statusBar.foreground": "#e7e7e7" }, "peacock.color": "#1D70A2" } diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.html b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.html index dc09088430..7cb90c3329 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.html +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.html @@ -1,5 +1,6 @@ diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts index adacc4efa8..ea7ef33687 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts @@ -22,6 +22,7 @@ import { EntityProp, EntityPropList } from '../../models/entity-props'; import { PropData } from '../../models/props'; import { ExtensionsService } from '../../services/extensions.service'; import { EXTENSIONS_IDENTIFIER } from '../../tokens/extensions.token'; +import { EntityActionList } from '../../models/entity-actions'; const DEFAULT_ACTIONS_COLUMN_WIDTH = 150; @Component({ @@ -46,6 +47,8 @@ export class ExtensibleTableComponent implements OnChanges { readonly propList: EntityPropList; + readonly actionList: EntityActionList; + readonly trackByFn: TrackByFunction> = (_, item) => item.name; constructor(@Inject(LOCALE_ID) private locale: string, injector: Injector) { @@ -54,6 +57,8 @@ export class ExtensibleTableComponent implements OnChanges { const extensions = injector.get(ExtensionsService); const name = injector.get(EXTENSIONS_IDENTIFIER); this.propList = extensions.entityProps.get(name).props; + this.actionList = (extensions['entityActions'].get(name) + .actions as unknown) as EntityActionList; this.setColumnWidths(DEFAULT_ACTIONS_COLUMN_WIDTH); } diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/entity-props.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/entity-props.ts index a49a8e8d41..14fd37ad84 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/entity-props.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/entity-props.ts @@ -11,6 +11,7 @@ import { Props, PropsFactory, } from './props'; +import { ActionCallback } from './actions'; export class EntityPropList extends PropList> {} @@ -26,6 +27,7 @@ export class EntityProp extends Prop { readonly columnWidth: number | undefined; readonly sortable: boolean; readonly valueResolver: PropCallback>; + readonly action: ActionCallback; constructor(options: EntityPropOptions) { super( @@ -40,6 +42,7 @@ export class EntityProp extends Prop { this.columnWidth = options.columnWidth; this.sortable = options.sortable || false; this.valueResolver = options.valueResolver || (data => of(data.record[this.name])); + this.action = options.action || (_ => {}); } static create(options: EntityPropOptions) { @@ -60,6 +63,7 @@ export type EntityPropOptions = O.Optional< | 'columnWidth' | 'sortable' | 'valueResolver' + | 'action' >; export type EntityPropDefaults = Record[]>; From 4ab0a18f82bafa8ad0dfc1a356cafe1f1b156c7f Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Thu, 13 Aug 2020 18:17:03 +0800 Subject: [PATCH 012/190] Add multiple constructors. --- .../EfCoreObjectExtensionPropertyInfoExtensions.cs | 2 +- .../ObjectExtensionPropertyInfoEfCoreMappingOptions.cs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionPropertyInfoExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionPropertyInfoExtensions.cs index 90b26390d2..f4dae81fac 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionPropertyInfoExtensions.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/EfCoreObjectExtensionPropertyInfoExtensions.cs @@ -50,7 +50,7 @@ namespace Volo.Abp.ObjectExtending propertyExtension.Configuration[EfCorePropertyConfigurationName] = new ObjectExtensionPropertyInfoEfCoreMappingOptions( propertyExtension, - entityTypeAndPropertyBuildAction: entityTypeAndPropertyBuildAction + entityTypeAndPropertyBuildAction ); return propertyExtension; diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoEfCoreMappingOptions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoEfCoreMappingOptions.cs index 86f1b16a76..7bf9c313e3 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoEfCoreMappingOptions.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoEfCoreMappingOptions.cs @@ -31,9 +31,15 @@ namespace Volo.Abp.ObjectExtending EntityTypeAndPropertyBuildAction = entityTypeAndPropertyBuildAction; } + public ObjectExtensionPropertyInfoEfCoreMappingOptions( + [NotNull] ObjectExtensionPropertyInfo extensionProperty) + { + ExtensionProperty = Check.NotNull(extensionProperty, nameof(extensionProperty)); + } + public ObjectExtensionPropertyInfoEfCoreMappingOptions( [NotNull] ObjectExtensionPropertyInfo extensionProperty, - [CanBeNull] Action entityTypeAndPropertyBuildAction = null) + [CanBeNull] Action entityTypeAndPropertyBuildAction) { ExtensionProperty = Check.NotNull(extensionProperty, nameof(extensionProperty)); From 598b682a1449bb063b5a65098780ef45869568e3 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Thu, 13 Aug 2020 14:09:23 +0300 Subject: [PATCH 013/190] Automatically run the DbMigrator application on the add-module command resolves https://github.com/abpframework/abp/issues/4863 --- .../EfCoreMigrationAdder.cs | 14 ++------- .../SolutionModuleAdder.cs | 31 +++++++++++++++++-- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/EfCoreMigrationAdder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/EfCoreMigrationAdder.cs index b125c55648..280d4b8f34 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/EfCoreMigrationAdder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/EfCoreMigrationAdder.cs @@ -7,22 +7,12 @@ namespace Volo.Abp.Cli.ProjectModification { public class EfCoreMigrationAdder : ITransientDependency { - public void AddMigration(string csprojFile, string module, string startupProject, bool updateDatabase = true) + public void AddMigration(string dbMigrationsCsprojFile, string module, string startupProject) { var moduleName = ParseModuleName(module); var migrationName = "Added_" + moduleName + "_Module" + GetUniquePostFix(); - CmdHelper.RunCmd("cd \"" + Path.GetDirectoryName(csprojFile) + "\" && dotnet ef migrations add " + migrationName + GetStartupProjectOption(startupProject)); - - if (updateDatabase) - { - UpdateDatabase(csprojFile, startupProject); - } - } - - protected void UpdateDatabase(string csprojFile, string startupProject) - { - CmdHelper.RunCmd("cd \"" + Path.GetDirectoryName(csprojFile) + "\" && dotnet ef database update" + GetStartupProjectOption(startupProject)); + CmdHelper.RunCmd("cd \"" + Path.GetDirectoryName(dbMigrationsCsprojFile) + "\" && dotnet ef migrations add " + migrationName + GetStartupProjectOption(startupProject)); } protected virtual string ParseModuleName(string fullModuleName) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs index a19af6f52c..1b006c25b6 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Volo.Abp.Cli.Commands.Services; using Volo.Abp.Cli.Http; using Volo.Abp.Cli.ProjectBuilding; +using Volo.Abp.Cli.Utils; using Volo.Abp.DependencyInjection; using Volo.Abp.Json; @@ -214,6 +215,11 @@ namespace Volo.Abp.Cli.ProjectModification { if (string.IsNullOrWhiteSpace(module.EfCoreConfigureMethodName)) { + if (!skipDbMigrations) + { + RunMigrator(projectFiles); + } + return; } @@ -227,6 +233,12 @@ namespace Volo.Abp.Cli.ProjectModification if (dbMigrationsProject == null) { Logger.LogDebug("Solution doesn't have a \".DbMigrations\" project."); + + if (!skipDbMigrations) + { + RunMigrator(projectFiles); + } + return; } @@ -240,9 +252,24 @@ namespace Volo.Abp.Cli.ProjectModification var addedNewBuilder = DbContextFileBuilderConfigureAdder.Add(dbContextFile, module.EfCoreConfigureMethodName); - if (addedNewBuilder && !skipDbMigrations) + if (!skipDbMigrations) + { + if (addedNewBuilder) + { + EfCoreMigrationAdder.AddMigration(dbMigrationsProject, module.Name, startupProject); + } + + RunMigrator(projectFiles); + } + } + + protected virtual async Task RunMigrator(string[] projectFiles) + { + var dbMigratorProject = projectFiles.FirstOrDefault(p => p.EndsWith(".DbMigrator.csproj")); + + if (!string.IsNullOrEmpty(dbMigratorProject)) { - EfCoreMigrationAdder.AddMigration(dbMigrationsProject, module.Name, startupProject); + CmdHelper.RunCmd("cd \"" + Path.GetDirectoryName(dbMigratorProject) + "\" && dotnet run"); } } From 5fdd53330daa6d9a9e9ef68048199573d4b331ad Mon Sep 17 00:00:00 2001 From: Mehmet Erim <34455572+mehmet-erim@users.noreply.github.com> Date: Thu, 13 Aug 2020 15:20:39 +0300 Subject: [PATCH 014/190] Update Multi-Tenancy.md --- docs/en/UI/Angular/Multi-Tenancy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/UI/Angular/Multi-Tenancy.md b/docs/en/UI/Angular/Multi-Tenancy.md index 94b3954a03..291068d22d 100644 --- a/docs/en/UI/Angular/Multi-Tenancy.md +++ b/docs/en/UI/Angular/Multi-Tenancy.md @@ -1,4 +1,4 @@ -# Multi Tenancy in Angular UI +# Multi Tenancy in Angular UI ABP Angular UI supports the multi-tenancy. The following features related to multi-tenancy are available in the startup templates. From 337b806d25c44f9f3dbbcf971c0e6b9a16f692b5 Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Thu, 13 Aug 2020 15:20:52 +0300 Subject: [PATCH 015/190] add organization parameter to login command --- docs/en/CLI.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/en/CLI.md b/docs/en/CLI.md index f7b5ab88aa..b8ab602c3b 100644 --- a/docs/en/CLI.md +++ b/docs/en/CLI.md @@ -274,11 +274,13 @@ Then review changes on your source control system to be sure that it has changed Some features of the CLI requires to be logged in to abp.io platform. To login with your username write: ```bash -abp login # Asks password separately -abp login -p # Specify the password as a parameter +abp login # Allows you to enter your password hidden +abp login -p # Specify the password as a parameter (password is visible) +abp login --organization # If you have multiple organizations, you need set your active organization +abp login -p -o # You can enter both your password and organization in the same command ``` -> Using `-p` parameter might not be safe if someone is watching your screen :) It can be useful for automation purposes. +> When using the -p parameter, be careful as your password will be visible. It's useful for CI/CD automation pipelines. A new login with an already active session overwrites the previous session. From d3fe98c43a2dc76ef754bda470af64a22cd033a0 Mon Sep 17 00:00:00 2001 From: Mehmet Erim <34455572+mehmet-erim@users.noreply.github.com> Date: Thu, 13 Aug 2020 15:28:40 +0300 Subject: [PATCH 016/190] Update Multi-Tenancy.md --- docs/en/UI/Angular/Multi-Tenancy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/UI/Angular/Multi-Tenancy.md b/docs/en/UI/Angular/Multi-Tenancy.md index 291068d22d..fb9fb54f76 100644 --- a/docs/en/UI/Angular/Multi-Tenancy.md +++ b/docs/en/UI/Angular/Multi-Tenancy.md @@ -17,7 +17,7 @@ On the page above, you can; ![Tenant Switching Component](./images/tenant-switching-box.png)

Tenant Switching Component

-You can switch between existing tenants by using the tenant switching component in the child pages of the `AccountLayoutComponent` (like Login page). Angular UI sends the selected tenant id sends to the backend as `__tenant` header on each request. +You can switch between existing tenants by using the tenant switching component in the child pages of the `AccountLayoutComponent` (like Login page). Angular UI sends the selected tenant id to the backend as `__tenant` header on each request. ## Domain Tenant Resolver From 40bc859f0385e0ebacef837c5e233fea53a15656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 13 Aug 2020 16:07:08 +0300 Subject: [PATCH 017/190] Refresh the initial migration for the CMS Kit. --- .../Pages/Index.cshtml | 4 +- ...807070949_Reaction_Comment_Multitenancy.cs | 32 - .../20200810022644_Initial.Designer.cs | 1186 ----------------- ....cs => 20200813130355_Initial.Designer.cs} | 6 +- ...4_Initial.cs => 20200813130355_Initial.cs} | 2 + 5 files changed, 7 insertions(+), 1223 deletions(-) delete mode 100644 modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.cs delete mode 100644 modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200810022644_Initial.Designer.cs rename modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/{20200807070949_Reaction_Comment_Multitenancy.Designer.cs => 20200813130355_Initial.Designer.cs} (99%) rename modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/{20200810022644_Initial.cs => 20200813130355_Initial.cs} (99%) diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Pages/Index.cshtml b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Pages/Index.cshtml index 73f229b4f3..522b6ebdf7 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Pages/Index.cshtml +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/Pages/Index.cshtml @@ -9,7 +9,7 @@ - Logout + Logout

@CurrentUser.UserName

@@ -31,4 +31,4 @@

Login -} \ No newline at end of file +} diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.cs deleted file mode 100644 index 42f880e3b4..0000000000 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Volo.CmsKit.Migrations -{ - public partial class Reaction_Comment_Multitenancy : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "TenantId", - table: "CmsUserReactions", - nullable: true); - - migrationBuilder.AddColumn( - name: "TenantId", - table: "CmsComments", - nullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "TenantId", - table: "CmsUserReactions"); - - migrationBuilder.DropColumn( - name: "TenantId", - table: "CmsComments"); - } - } -} diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200810022644_Initial.Designer.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200810022644_Initial.Designer.cs deleted file mode 100644 index a29b41671a..0000000000 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200810022644_Initial.Designer.cs +++ /dev/null @@ -1,1186 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Volo.Abp.EntityFrameworkCore; -using Volo.CmsKit.EntityFrameworkCore; - -namespace Volo.CmsKit.Migrations -{ - [DbContext(typeof(UnifiedDbContext))] - [Migration("20200810022644_Initial")] - partial class Initial - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) - .HasAnnotation("ProductVersion", "3.1.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ApplicationName") - .HasColumnName("ApplicationName") - .HasColumnType("nvarchar(96)") - .HasMaxLength(96); - - b.Property("BrowserInfo") - .HasColumnName("BrowserInfo") - .HasColumnType("nvarchar(512)") - .HasMaxLength(512); - - b.Property("ClientId") - .HasColumnName("ClientId") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("ClientIpAddress") - .HasColumnName("ClientIpAddress") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("ClientName") - .HasColumnName("ClientName") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); - - b.Property("Comments") - .HasColumnName("Comments") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnName("ConcurrencyStamp") - .HasColumnType("nvarchar(40)") - .HasMaxLength(40); - - b.Property("CorrelationId") - .HasColumnName("CorrelationId") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("Exceptions") - .HasColumnName("Exceptions") - .HasColumnType("nvarchar(4000)") - .HasMaxLength(4000); - - b.Property("ExecutionDuration") - .HasColumnName("ExecutionDuration") - .HasColumnType("int"); - - b.Property("ExecutionTime") - .HasColumnType("datetime2"); - - b.Property("ExtraProperties") - .HasColumnName("ExtraProperties") - .HasColumnType("nvarchar(max)"); - - b.Property("HttpMethod") - .HasColumnName("HttpMethod") - .HasColumnType("nvarchar(16)") - .HasMaxLength(16); - - b.Property("HttpStatusCode") - .HasColumnName("HttpStatusCode") - .HasColumnType("int"); - - b.Property("ImpersonatorTenantId") - .HasColumnName("ImpersonatorTenantId") - .HasColumnType("uniqueidentifier"); - - b.Property("ImpersonatorUserId") - .HasColumnName("ImpersonatorUserId") - .HasColumnType("uniqueidentifier"); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.Property("TenantName") - .HasColumnType("nvarchar(max)"); - - b.Property("Url") - .HasColumnName("Url") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("UserId") - .HasColumnName("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserName") - .HasColumnName("UserName") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.HasKey("Id"); - - b.HasIndex("TenantId", "ExecutionTime"); - - b.HasIndex("TenantId", "UserId", "ExecutionTime"); - - b.ToTable("AbpAuditLogs"); - }); - - modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogAction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("AuditLogId") - .HasColumnName("AuditLogId") - .HasColumnType("uniqueidentifier"); - - b.Property("ExecutionDuration") - .HasColumnName("ExecutionDuration") - .HasColumnType("int"); - - b.Property("ExecutionTime") - .HasColumnName("ExecutionTime") - .HasColumnType("datetime2"); - - b.Property("ExtraProperties") - .HasColumnName("ExtraProperties") - .HasColumnType("nvarchar(max)"); - - b.Property("MethodName") - .HasColumnName("MethodName") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); - - b.Property("Parameters") - .HasColumnName("Parameters") - .HasColumnType("nvarchar(2000)") - .HasMaxLength(2000); - - b.Property("ServiceName") - .HasColumnName("ServiceName") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("AuditLogId"); - - b.HasIndex("TenantId", "ServiceName", "MethodName", "ExecutionTime"); - - b.ToTable("AbpAuditLogActions"); - }); - - modelBuilder.Entity("Volo.Abp.AuditLogging.EntityChange", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("AuditLogId") - .HasColumnName("AuditLogId") - .HasColumnType("uniqueidentifier"); - - b.Property("ChangeTime") - .HasColumnName("ChangeTime") - .HasColumnType("datetime2"); - - b.Property("ChangeType") - .HasColumnName("ChangeType") - .HasColumnType("tinyint"); - - b.Property("EntityId") - .IsRequired() - .HasColumnName("EntityId") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); - - b.Property("EntityTenantId") - .HasColumnType("uniqueidentifier"); - - b.Property("EntityTypeFullName") - .IsRequired() - .HasColumnName("EntityTypeFullName") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); - - b.Property("ExtraProperties") - .HasColumnName("ExtraProperties") - .HasColumnType("nvarchar(max)"); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("AuditLogId"); - - b.HasIndex("TenantId", "EntityTypeFullName", "EntityId"); - - b.ToTable("AbpEntityChanges"); - }); - - modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("EntityChangeId") - .HasColumnType("uniqueidentifier"); - - b.Property("NewValue") - .HasColumnName("NewValue") - .HasColumnType("nvarchar(512)") - .HasMaxLength(512); - - b.Property("OriginalValue") - .HasColumnName("OriginalValue") - .HasColumnType("nvarchar(512)") - .HasMaxLength(512); - - b.Property("PropertyName") - .IsRequired() - .HasColumnName("PropertyName") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); - - b.Property("PropertyTypeFullName") - .IsRequired() - .HasColumnName("PropertyTypeFullName") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("EntityChangeId"); - - b.ToTable("AbpEntityPropertyChanges"); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnName("ConcurrencyStamp") - .HasColumnType("nvarchar(40)") - .HasMaxLength(40); - - b.Property("Description") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("ExtraProperties") - .HasColumnName("ExtraProperties") - .HasColumnType("nvarchar(max)"); - - b.Property("IsStatic") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("Regex") - .HasColumnType("nvarchar(512)") - .HasMaxLength(512); - - b.Property("RegexDescription") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); - - b.Property("Required") - .HasColumnType("bit"); - - b.Property("ValueType") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("AbpClaimTypes"); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnName("ConcurrencyStamp") - .HasColumnType("nvarchar(40)") - .HasMaxLength(40); - - b.Property("ExtraProperties") - .HasColumnName("ExtraProperties") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDefault") - .HasColumnName("IsDefault") - .HasColumnType("bit"); - - b.Property("IsPublic") - .HasColumnName("IsPublic") - .HasColumnType("bit"); - - b.Property("IsStatic") - .HasColumnName("IsStatic") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("NormalizedName") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName"); - - b.ToTable("AbpRoles"); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("ClaimType") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(1024)") - .HasMaxLength(1024); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AbpRoleClaims"); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("AccessFailedCount") - .ValueGeneratedOnAdd() - .HasColumnName("AccessFailedCount") - .HasColumnType("int") - .HasDefaultValue(0); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnName("ConcurrencyStamp") - .HasColumnType("nvarchar(40)") - .HasMaxLength(40); - - b.Property("CreationTime") - .HasColumnName("CreationTime") - .HasColumnType("datetime2"); - - b.Property("CreatorId") - .HasColumnName("CreatorId") - .HasColumnType("uniqueidentifier"); - - b.Property("DeleterId") - .HasColumnName("DeleterId") - .HasColumnType("uniqueidentifier"); - - b.Property("DeletionTime") - .HasColumnName("DeletionTime") - .HasColumnType("datetime2"); - - b.Property("Email") - .IsRequired() - .HasColumnName("Email") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("EmailConfirmed") - .ValueGeneratedOnAdd() - .HasColumnName("EmailConfirmed") - .HasColumnType("bit") - .HasDefaultValue(false); - - b.Property("ExtraProperties") - .HasColumnName("ExtraProperties") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .ValueGeneratedOnAdd() - .HasColumnName("IsDeleted") - .HasColumnType("bit") - .HasDefaultValue(false); - - b.Property("LastModificationTime") - .HasColumnName("LastModificationTime") - .HasColumnType("datetime2"); - - b.Property("LastModifierId") - .HasColumnName("LastModifierId") - .HasColumnType("uniqueidentifier"); - - b.Property("LockoutEnabled") - .ValueGeneratedOnAdd() - .HasColumnName("LockoutEnabled") - .HasColumnType("bit") - .HasDefaultValue(false); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("Name") - .HasColumnName("Name") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("NormalizedEmail") - .IsRequired() - .HasColumnName("NormalizedEmail") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("NormalizedUserName") - .IsRequired() - .HasColumnName("NormalizedUserName") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("PasswordHash") - .HasColumnName("PasswordHash") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("PhoneNumber") - .HasColumnName("PhoneNumber") - .HasColumnType("nvarchar(16)") - .HasMaxLength(16); - - b.Property("PhoneNumberConfirmed") - .ValueGeneratedOnAdd() - .HasColumnName("PhoneNumberConfirmed") - .HasColumnType("bit") - .HasDefaultValue(false); - - b.Property("SecurityStamp") - .IsRequired() - .HasColumnName("SecurityStamp") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("Surname") - .HasColumnName("Surname") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.Property("TwoFactorEnabled") - .ValueGeneratedOnAdd() - .HasColumnName("TwoFactorEnabled") - .HasColumnType("bit") - .HasDefaultValue(false); - - b.Property("UserName") - .IsRequired() - .HasColumnName("UserName") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.HasKey("Id"); - - b.HasIndex("Email"); - - b.HasIndex("NormalizedEmail"); - - b.HasIndex("NormalizedUserName"); - - b.HasIndex("UserName"); - - b.ToTable("AbpUsers"); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("ClaimType") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(1024)") - .HasMaxLength(1024); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AbpUserClaims"); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); - - b.Property("ProviderKey") - .IsRequired() - .HasColumnType("nvarchar(196)") - .HasMaxLength(196); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("UserId", "LoginProvider"); - - b.HasIndex("LoginProvider", "ProviderKey"); - - b.ToTable("AbpUserLogins"); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b => - { - b.Property("OrganizationUnitId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreationTime") - .HasColumnName("CreationTime") - .HasColumnType("datetime2"); - - b.Property("CreatorId") - .HasColumnName("CreatorId") - .HasColumnType("uniqueidentifier"); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("OrganizationUnitId", "UserId"); - - b.HasIndex("UserId", "OrganizationUnitId"); - - b.ToTable("AbpUserOrganizationUnits"); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId", "UserId"); - - b.ToTable("AbpUserRoles"); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("Name") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AbpUserTokens"); - }); - - modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasColumnName("Code") - .HasColumnType("nvarchar(95)") - .HasMaxLength(95); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnName("ConcurrencyStamp") - .HasColumnType("nvarchar(40)") - .HasMaxLength(40); - - b.Property("CreationTime") - .HasColumnName("CreationTime") - .HasColumnType("datetime2"); - - b.Property("CreatorId") - .HasColumnName("CreatorId") - .HasColumnType("uniqueidentifier"); - - b.Property("DeleterId") - .HasColumnName("DeleterId") - .HasColumnType("uniqueidentifier"); - - b.Property("DeletionTime") - .HasColumnName("DeletionTime") - .HasColumnType("datetime2"); - - b.Property("DisplayName") - .IsRequired() - .HasColumnName("DisplayName") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); - - b.Property("ExtraProperties") - .HasColumnName("ExtraProperties") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .ValueGeneratedOnAdd() - .HasColumnName("IsDeleted") - .HasColumnType("bit") - .HasDefaultValue(false); - - b.Property("LastModificationTime") - .HasColumnName("LastModificationTime") - .HasColumnType("datetime2"); - - b.Property("LastModifierId") - .HasColumnName("LastModifierId") - .HasColumnType("uniqueidentifier"); - - b.Property("ParentId") - .HasColumnType("uniqueidentifier"); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("Code"); - - b.HasIndex("ParentId"); - - b.ToTable("AbpOrganizationUnits"); - }); - - modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b => - { - b.Property("OrganizationUnitId") - .HasColumnType("uniqueidentifier"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreationTime") - .HasColumnName("CreationTime") - .HasColumnType("datetime2"); - - b.Property("CreatorId") - .HasColumnName("CreatorId") - .HasColumnType("uniqueidentifier"); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("OrganizationUnitId", "RoleId"); - - b.HasIndex("RoleId", "OrganizationUnitId"); - - b.ToTable("AbpOrganizationUnitRoles"); - }); - - modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); - - b.Property("ProviderKey") - .IsRequired() - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("ProviderName") - .IsRequired() - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("Name", "ProviderName", "ProviderKey"); - - b.ToTable("AbpPermissionGrants"); - }); - - modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("ProviderName") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(2048)") - .HasMaxLength(2048); - - b.HasKey("Id"); - - b.HasIndex("Name", "ProviderName", "ProviderKey"); - - b.ToTable("AbpSettings"); - }); - - modelBuilder.Entity("Volo.Abp.TenantManagement.Tenant", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnName("ConcurrencyStamp") - .HasColumnType("nvarchar(40)") - .HasMaxLength(40); - - b.Property("CreationTime") - .HasColumnName("CreationTime") - .HasColumnType("datetime2"); - - b.Property("CreatorId") - .HasColumnName("CreatorId") - .HasColumnType("uniqueidentifier"); - - b.Property("DeleterId") - .HasColumnName("DeleterId") - .HasColumnType("uniqueidentifier"); - - b.Property("DeletionTime") - .HasColumnName("DeletionTime") - .HasColumnType("datetime2"); - - b.Property("ExtraProperties") - .HasColumnName("ExtraProperties") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .ValueGeneratedOnAdd() - .HasColumnName("IsDeleted") - .HasColumnType("bit") - .HasDefaultValue(false); - - b.Property("LastModificationTime") - .HasColumnName("LastModificationTime") - .HasColumnType("datetime2"); - - b.Property("LastModifierId") - .HasColumnName("LastModifierId") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.HasKey("Id"); - - b.HasIndex("Name"); - - b.ToTable("AbpTenants"); - }); - - modelBuilder.Entity("Volo.Abp.TenantManagement.TenantConnectionString", b => - { - b.Property("TenantId") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(1024)") - .HasMaxLength(1024); - - b.HasKey("TenantId", "Name"); - - b.ToTable("AbpTenantConnectionStrings"); - }); - - modelBuilder.Entity("Volo.CmsKit.Comments.Comment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreationTime") - .HasColumnName("CreationTime") - .HasColumnType("datetime2"); - - b.Property("CreatorId") - .HasColumnName("CreatorId") - .HasColumnType("uniqueidentifier"); - - b.Property("EntityId") - .IsRequired() - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("EntityType") - .IsRequired() - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("RepliedCommentId") - .HasColumnType("uniqueidentifier"); - - b.Property("Text") - .IsRequired() - .HasColumnType("nvarchar(512)") - .HasMaxLength(512); - - b.HasKey("Id"); - - b.HasIndex("RepliedCommentId"); - - b.HasIndex("EntityType", "EntityId"); - - b.ToTable("CmsComments"); - }); - - modelBuilder.Entity("Volo.CmsKit.Reactions.UserReaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreationTime") - .HasColumnName("CreationTime") - .HasColumnType("datetime2"); - - b.Property("CreatorId") - .HasColumnName("CreatorId") - .HasColumnType("uniqueidentifier"); - - b.Property("EntityId") - .IsRequired() - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("EntityType") - .IsRequired() - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("ReactionName") - .IsRequired() - .HasColumnType("nvarchar(32)") - .HasMaxLength(32); - - b.HasKey("Id"); - - b.HasIndex("EntityType", "EntityId"); - - b.HasIndex("CreatorId", "EntityType", "EntityId", "ReactionName"); - - b.ToTable("CmsUserReactions"); - }); - - modelBuilder.Entity("Volo.CmsKit.Users.CmsUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnName("ConcurrencyStamp") - .HasColumnType("nvarchar(40)") - .HasMaxLength(40); - - b.Property("Email") - .IsRequired() - .HasColumnName("Email") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.Property("EmailConfirmed") - .ValueGeneratedOnAdd() - .HasColumnName("EmailConfirmed") - .HasColumnType("bit") - .HasDefaultValue(false); - - b.Property("ExtraProperties") - .HasColumnName("ExtraProperties") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnName("Name") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("PhoneNumber") - .HasColumnName("PhoneNumber") - .HasColumnType("nvarchar(16)") - .HasMaxLength(16); - - b.Property("PhoneNumberConfirmed") - .ValueGeneratedOnAdd() - .HasColumnName("PhoneNumberConfirmed") - .HasColumnType("bit") - .HasDefaultValue(false); - - b.Property("Surname") - .HasColumnName("Surname") - .HasColumnType("nvarchar(64)") - .HasMaxLength(64); - - b.Property("TenantId") - .HasColumnName("TenantId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserName") - .IsRequired() - .HasColumnName("UserName") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); - - b.HasKey("Id"); - - b.ToTable("CmsUsers"); - }); - - modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogAction", b => - { - b.HasOne("Volo.Abp.AuditLogging.AuditLog", null) - .WithMany("Actions") - .HasForeignKey("AuditLogId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Volo.Abp.AuditLogging.EntityChange", b => - { - b.HasOne("Volo.Abp.AuditLogging.AuditLog", null) - .WithMany("EntityChanges") - .HasForeignKey("AuditLogId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b => - { - b.HasOne("Volo.Abp.AuditLogging.EntityChange", null) - .WithMany("PropertyChanges") - .HasForeignKey("EntityChangeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => - { - b.HasOne("Volo.Abp.Identity.IdentityRole", null) - .WithMany("Claims") - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => - { - b.HasOne("Volo.Abp.Identity.IdentityUser", null) - .WithMany("Claims") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => - { - b.HasOne("Volo.Abp.Identity.IdentityUser", null) - .WithMany("Logins") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b => - { - b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) - .WithMany() - .HasForeignKey("OrganizationUnitId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Volo.Abp.Identity.IdentityUser", null) - .WithMany("OrganizationUnits") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => - { - b.HasOne("Volo.Abp.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Volo.Abp.Identity.IdentityUser", null) - .WithMany("Roles") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => - { - b.HasOne("Volo.Abp.Identity.IdentityUser", null) - .WithMany("Tokens") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => - { - b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) - .WithMany() - .HasForeignKey("ParentId"); - }); - - modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b => - { - b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) - .WithMany("Roles") - .HasForeignKey("OrganizationUnitId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Volo.Abp.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Volo.Abp.TenantManagement.TenantConnectionString", b => - { - b.HasOne("Volo.Abp.TenantManagement.Tenant", null) - .WithMany("ConnectionStrings") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.Designer.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200813130355_Initial.Designer.cs similarity index 99% rename from modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.Designer.cs rename to modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200813130355_Initial.Designer.cs index addf1e46c6..69edfcf69f 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.Designer.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200813130355_Initial.Designer.cs @@ -11,15 +11,15 @@ using Volo.CmsKit.EntityFrameworkCore; namespace Volo.CmsKit.Migrations { [DbContext(typeof(UnifiedDbContext))] - [Migration("20200807070949_Reaction_Comment_Multitenancy")] - partial class Reaction_Comment_Multitenancy + [Migration("20200813130355_Initial")] + partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) - .HasAnnotation("ProductVersion", "3.1.5") + .HasAnnotation("ProductVersion", "3.1.6") .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200810022644_Initial.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200813130355_Initial.cs similarity index 99% rename from modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200810022644_Initial.cs rename to modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200813130355_Initial.cs index 6f8b2a069c..9f2560f9c0 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200810022644_Initial.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200813130355_Initial.cs @@ -200,6 +200,7 @@ namespace Volo.CmsKit.Migrations columns: table => new { Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), EntityType = table.Column(maxLength: 64, nullable: false), EntityId = table.Column(maxLength: 64, nullable: false), Text = table.Column(maxLength: 512, nullable: false), @@ -217,6 +218,7 @@ namespace Volo.CmsKit.Migrations columns: table => new { Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), EntityType = table.Column(maxLength: 64, nullable: false), EntityId = table.Column(maxLength: 64, nullable: false), ReactionName = table.Column(maxLength: 32, nullable: false), From 1791925da6c31d4df6b64aee016478e6e8b7524b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 13 Aug 2020 16:13:19 +0300 Subject: [PATCH 018/190] Remove empty localizations and fill Turkish. --- .../Volo/CmsKit/Localization/Resources/cs.json | 5 ----- .../Volo/CmsKit/Localization/Resources/pl-PL.json | 6 ------ .../Volo/CmsKit/Localization/Resources/pt-BR.json | 6 ------ .../Volo/CmsKit/Localization/Resources/sl.json | 5 ----- .../Volo/CmsKit/Localization/Resources/tr.json | 14 +++++++++++++- .../Volo/CmsKit/Localization/Resources/vi.json | 5 ----- .../CmsKit/Localization/Resources/zh-Hans.json | 5 ----- .../CmsKit/Localization/Resources/zh-Hant.json | 5 ----- 8 files changed, 13 insertions(+), 38 deletions(-) delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/cs.json delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/pl-PL.json delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/pt-BR.json delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/sl.json delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/vi.json delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/zh-Hans.json delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/zh-Hant.json diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/cs.json b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/cs.json deleted file mode 100644 index b74a907b17..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/cs.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "culture": "cs", - "texts": { - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/pl-PL.json b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/pl-PL.json deleted file mode 100644 index 3ea7b190ee..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/pl-PL.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "culture": "pl-PL", - "texts": { - - } -} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/pt-BR.json b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/pt-BR.json deleted file mode 100644 index 6d746df04c..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/pt-BR.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "culture": "pt-BR", - "texts": { - - } -} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/sl.json b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/sl.json deleted file mode 100644 index 103359cbc2..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/sl.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "culture": "sl", - "texts": { - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/tr.json b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/tr.json index ce0d27fd3c..c1664f9122 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/tr.json +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/tr.json @@ -1,6 +1,18 @@ { "culture": "tr", "texts": { - "PickYourReaction": "Tepkinizi seçin" + "PickYourReaction": "Tepkinizi seçin", + "YourComment": "Yorumunuz", + "YourReply": "Cevabınız", + "Comments": "Yorumlar", + "Send": "Gönder", + "Delete": "Sil", + "Reply": "Cevapla", + "Update": "Güncelle", + "Edit": "Düzenle", + "LoginToAddComment": "Yorum yapmak için giriş yap", + "LoginToReply": "Cevap vermek için giriş yap", + "MessageDeletionConfirmationMessage": "Bu yorum tamamen silinecektir", + "CommentAuthorizationExceptionMessage": "Bu yorumları görebilmek için yetki gerekir." } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/vi.json b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/vi.json deleted file mode 100644 index 70fc26c87b..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/vi.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "culture": "vi", - "texts": { - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/zh-Hans.json b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/zh-Hans.json deleted file mode 100644 index df56786e15..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/zh-Hans.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "culture": "zh-Hans", - "texts": { - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/zh-Hant.json b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/zh-Hant.json deleted file mode 100644 index 445e38b82a..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/zh-Hant.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "culture": "zh-Hant", - "texts": { - } -} From 70b595f59d854a3a7f948f1052d6a13358e12906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 13 Aug 2020 16:17:57 +0300 Subject: [PATCH 019/190] Refactor constants. --- .../Volo/CmsKit/Comments/CommentConsts.cs | 8 +++++--- .../Volo/CmsKit/Entities/CmsEntityConsts.cs | 9 +++++++++ .../Volo/CmsKit/Reactions/UserReactionConsts.cs | 10 ++++++---- .../Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs | 4 ++-- .../CmsKitDbContextModelCreatingExtensions.cs | 10 +++++----- .../Volo/CmsKit/Public/Comments/CreateCommentInput.cs | 4 ++-- 6 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs index 9fed054cae..68091c7f2d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs @@ -1,10 +1,12 @@ -namespace Volo.CmsKit.Comments +using Volo.CmsKit.Entities; + +namespace Volo.CmsKit.Comments { public static class CommentConsts { - public static int EntityTypeLength { get; set; } = 64; + public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength; - public static int EntityIdLength { get; set; } = 64; + public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength; public static int MaxTextLength { get; set; } = 512; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs new file mode 100644 index 0000000000..7176240196 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs @@ -0,0 +1,9 @@ +namespace Volo.CmsKit.Entities +{ + public class CmsEntityConsts + { + public static int MaxEntityTypeLength { get; set; } = 64; + + public static int MaxEntityIdLength { get; set; } = 64; + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs index be9b10af1b..e89067f869 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs @@ -1,11 +1,13 @@ -namespace Volo.CmsKit.Reactions +using Volo.CmsKit.Entities; + +namespace Volo.CmsKit.Reactions { public static class UserReactionConsts { - public static int EntityTypeLength { get; set; } = 64; + public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength; - public static int EntityIdLength { get; set; } = 64; + public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength; - public static int ReactionNameLength { get; set; } = 32; + public static int MaxReactionNameLength { get; set; } = 32; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs index a0ee37ccb7..06e22aa919 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs @@ -38,8 +38,8 @@ namespace Volo.CmsKit.Comments Guid? tenantId = null) : base(id) { - EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.EntityTypeLength); - EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.EntityIdLength); + EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.MaxEntityTypeLength); + EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.MaxEntityIdLength); RepliedCommentId = repliedCommentId; CreatorId = creatorId; TenantId = tenantId; 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 cb7a7b78d6..e945ddc7ed 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 @@ -37,9 +37,9 @@ namespace Volo.CmsKit.EntityFrameworkCore b.ToTable(options.TablePrefix + "UserReactions", options.Schema); b.ConfigureByConvention(); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.EntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.EntityIdLength); - b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.ReactionNameLength); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityIdLength); + b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.MaxReactionNameLength); b.Property(x => x.CreationTime); b.HasIndex(x => new { x.EntityType, x.EntityId }); @@ -51,8 +51,8 @@ namespace Volo.CmsKit.EntityFrameworkCore b.ToTable(options.TablePrefix + "Comments", options.Schema); b.ConfigureByConvention(); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.EntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.EntityIdLength); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.MaxEntityIdLength); b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength); b.Property(x => x.RepliedCommentId); b.Property(x => x.CreationTime); diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs index ebbc41898e..a0bcbfd6bd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs @@ -8,11 +8,11 @@ namespace Volo.CmsKit.Public.Comments public class CreateCommentInput { [Required] - [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.EntityTypeLength))] + [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.MaxEntityTypeLength))] public string EntityType { get; set; } [Required] - [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.EntityIdLength))] + [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.MaxEntityIdLength))] public string EntityId { get; set; } [Required] From e4b04537e2db4473f029a9573d839a56c91a2fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 13 Aug 2020 16:29:33 +0300 Subject: [PATCH 020/190] Remove authorization for comments. --- .../CmsKitWebUnifiedModule.cs | 5 ----- .../Volo/CmsKit/CmsKitOptions.cs | 7 +------ .../Comments/CommentPublicAppService.cs | 20 ------------------- 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs index 3579043302..b1cd636ef0 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs @@ -113,11 +113,6 @@ namespace Volo.CmsKit { options.IsEnabled = MultiTenancyConsts.IsEnabled; }); - - Configure(options => - { - options.PublicCommentEntities.Add("publicQuote"); - }); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitOptions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitOptions.cs index 8e13acca5c..cc69f715ce 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitOptions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitOptions.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using JetBrains.Annotations; +using JetBrains.Annotations; using Volo.CmsKit.Reactions; namespace Volo.CmsKit @@ -9,13 +8,9 @@ namespace Volo.CmsKit [NotNull] public ReactionDefinitionDictionary Reactions { get; } - [NotNull] - public List PublicCommentEntities { get; } - public CmsKitOptions() { Reactions = new ReactionDefinitionDictionary(); - PublicCommentEntities = new List(); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs index 895d8c5948..be3e260c5b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs @@ -33,8 +33,6 @@ namespace Volo.CmsKit.Public.Comments public virtual async Task> GetAllForEntityAsync(string entityType, string entityId) { - CheckAuthorizationAsync(entityType); - var commentsWithAuthor = await CommentRepository.GetListWithAuthorsAsync(entityType, entityId); return new ListResultDto( @@ -120,24 +118,6 @@ namespace Volo.CmsKit.Public.Comments return parentComments; } - private async Task CheckAuthorizationAsync(string entityType) - { - if (await IsPublicEntity(entityType)) - { - return; - } - - if (!CurrentUser.IsAuthenticated) - { - throw new AbpAuthorizationException(L["CommentAuthorizationExceptionMessage"]); - } - } - - private async Task IsPublicEntity(string entityType) - { - return CmsKitOptions.PublicCommentEntities.Contains(entityType); - } - private CmsUserDto GetAuthorAsDtoFromCommentList(List comments, Guid commentId) { return ObjectMapper.Map(comments.Single(c => c.Comment.Id == commentId).Author); From e6a224db73cbf4d23ec0ac1b9ad994e30092d44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 13 Aug 2020 16:42:57 +0300 Subject: [PATCH 021/190] Refactor the domain layer of the CMS Kit. --- .../Volo/CmsKit/Comments/Comment.cs | 7 ++++++- ...r.cs => CommentWithAuthorQueryResultItem.cs} | 2 +- .../Volo/CmsKit/Comments/ICommentRepository.cs | 5 +++-- .../Reactions/DefaultReactionDefinitionStore.cs | 2 +- .../CmsKit/Reactions/IUserReactionRepository.cs | 9 ++++++--- .../Volo/CmsKit/Users/CmsUserLookupService.cs | 1 - .../CmsKit/Comments/EfCoreCommentRepository.cs | 4 ++-- .../MongoDB/Comments/MongoCommentRepository.cs | 4 ++-- .../Public/Comments/CommentPublicAppService.cs | 4 ++-- .../Reactions/ReactionPublicAppService.cs | 17 +++++++++-------- .../Reactions/ReactionPublicAppService_Tests.cs | 1 + 11 files changed, 33 insertions(+), 23 deletions(-) rename modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/{CommentWithAuthor.cs => CommentWithAuthorQueryResultItem.cs} (76%) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs index 06e22aa919..dc821eb3d3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs @@ -44,10 +44,15 @@ namespace Volo.CmsKit.Comments CreatorId = creatorId; TenantId = tenantId; - SetText(text); + SetTextInternal(text); } public virtual void SetText(string text) + { + SetTextInternal(text); + } + + protected virtual void SetTextInternal(string text) { Text = Check.NotNullOrWhiteSpace(text, nameof(text), CommentConsts.MaxTextLength); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthor.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthorQueryResultItem.cs similarity index 76% rename from modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthor.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthorQueryResultItem.cs index 3a04a31ee8..a572ec1017 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthor.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthorQueryResultItem.cs @@ -2,7 +2,7 @@ namespace Volo.CmsKit.Comments { - public class CommentWithAuthor + public class CommentWithAuthorQueryResultItem { public Comment Comment { get; set; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs index 8e5bba3427..8eb1f55f6b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs @@ -8,8 +8,9 @@ namespace Volo.CmsKit.Comments { public interface ICommentRepository : IBasicRepository { - Task> GetListWithAuthorsAsync( + Task> GetListWithAuthorsAsync( [NotNull] string entityType, - [NotNull] string entityId); + [NotNull] string entityId + ); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/DefaultReactionDefinitionStore.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/DefaultReactionDefinitionStore.cs index 4c7d4e095c..84cb15471d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/DefaultReactionDefinitionStore.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/DefaultReactionDefinitionStore.cs @@ -20,7 +20,7 @@ namespace Volo.CmsKit.Reactions return Task.FromResult(Options.Reactions.Values.ToList()); } - public Task GetReactionOrNullAsync(string reactionName, string entityType = null) + public virtual Task GetReactionOrNullAsync(string reactionName, string entityType = null) { return Task.FromResult(Options.Reactions.GetOrDefault(reactionName)); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs index 2c964c70f5..ae9398e2d0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs @@ -12,15 +12,18 @@ namespace Volo.CmsKit.Reactions Guid userId, [NotNull] string entityType, [NotNull] string entityId, - [NotNull] string reactionName); + [NotNull] string reactionName + ); Task> GetListForUserAsync( Guid userId, [NotNull] string entityType, - [NotNull] string entityId); + [NotNull] string entityId + ); Task> GetSummariesAsync( [NotNull] string entityType, - [NotNull] string entityId); + [NotNull] string entityId + ); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserLookupService.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserLookupService.cs index 0771140a10..126d2b9c60 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserLookupService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserLookupService.cs @@ -19,6 +19,5 @@ namespace Volo.CmsKit.Users { return new CmsUser(externalUser); } - } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 3c39386f03..00b3150219 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -19,7 +19,7 @@ namespace Volo.CmsKit.Comments { } - public async Task> GetListWithAuthorsAsync( + public async Task> GetListWithAuthorsAsync( string entityType, string entityId) { @@ -30,7 +30,7 @@ namespace Volo.CmsKit.Comments join user in DbContext.CmsUsers on comment.CreatorId equals user.Id where entityType == comment.EntityType && entityId == comment.EntityId orderby comment.CreationTime - select new CommentWithAuthor + select new CommentWithAuthorQueryResultItem { Comment = comment, Author = user diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs index 26a7c09a8c..3711831a46 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs @@ -18,7 +18,7 @@ namespace Volo.CmsKit.MongoDB.Comments { } - public async Task> GetListWithAuthorsAsync( + public async Task> GetListWithAuthorsAsync( string entityType, string entityId) { @@ -40,7 +40,7 @@ namespace Volo.CmsKit.MongoDB.Comments return comments .Select( comment => - new CommentWithAuthor + new CommentWithAuthorQueryResultItem { Comment = comment, Author = authors.FirstOrDefault(a => a.Id == comment.CreatorId) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs index be3e260c5b..01e172de7c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs @@ -93,7 +93,7 @@ namespace Volo.CmsKit.Public.Comments await CommentRepository.DeleteAsync(id); } - private List ConvertCommentsToNestedStructure(List comments) + private List ConvertCommentsToNestedStructure(List comments) { var parentComments = comments .Where(c=> c.Comment.RepliedCommentId == null) @@ -118,7 +118,7 @@ namespace Volo.CmsKit.Public.Comments return parentComments; } - private CmsUserDto GetAuthorAsDtoFromCommentList(List comments, Guid commentId) + private CmsUserDto GetAuthorAsDtoFromCommentList(List comments, Guid commentId) { return ObjectMapper.Map(comments.Single(c => c.Comment.Id == commentId).Author); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs index 6a1431f065..27fdd170ab 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs @@ -31,13 +31,14 @@ namespace Volo.CmsKit.Public.Reactions { var summaries = await ReactionManager.GetSummariesAsync(entityType, entityId); - var userReactions = CurrentUser.IsAuthenticated ? - (await UserReactionRepository - .GetListForUserAsync( - CurrentUser.GetId(), - entityType, - entityId - )).ToDictionary(x => x.ReactionName, x => x) : null; + var userReactionsOrNull = CurrentUser.IsAuthenticated + ? (await UserReactionRepository + .GetListForUserAsync( + CurrentUser.GetId(), + entityType, + entityId + )).ToDictionary(x => x.ReactionName, x => x) + : null; var reactionWithSelectionDtos = new List(); @@ -48,7 +49,7 @@ namespace Volo.CmsKit.Public.Reactions { Reaction = ConvertToReactionDto(summary.Reaction), Count = summary.Count, - IsSelectedByCurrentUser = userReactions?.ContainsKey(summary.Reaction.Name) ?? false + IsSelectedByCurrentUser = userReactionsOrNull?.ContainsKey(summary.Reaction.Name) ?? false } ); } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs index d03712ea07..dd74a1f1e7 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs @@ -43,6 +43,7 @@ namespace Volo.CmsKit.Reactions reactions.Items. First(r=>r.Reaction.Name == StandardReactions.Rocket).IsSelectedByCurrentUser.ShouldBeTrue(); + reactions.Items. First(r=>r.Reaction.Name == StandardReactions.Rocket).Count.ShouldBe(1); From ddc0c3c4f18b1cb917d2b506f7cb46a2fc763ab6 Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Thu, 13 Aug 2020 21:43:03 +0800 Subject: [PATCH 022/190] Update tr localize text. --- .../src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json index 7d04b9aa50..e6c90ea87c 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json @@ -13,7 +13,7 @@ "DisplayName:Abp.Ldap.UserName": "Kullanıcı adı", "Description:Abp.Ldap.UserName": "Kullanıcı adı", - "DisplayName:Abp.Ldap.Password": "parola", - "Description:Abp.Ldap.Password": "parola" + "DisplayName:Abp.Ldap.Password": "Parola", + "Description:Abp.Ldap.Password": "Parola" } } From 933ebed440710cd1e039a67dbd445c7cfe27ee16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 13 Aug 2020 16:47:49 +0300 Subject: [PATCH 023/190] User Base suffix for abstract base classes. --- ...{CmsKitAdminAppService.cs => CmsKitAdminAppServiceBase.cs} | 4 ++-- .../Volo/CmsKit/CmsKitAdminAppService.cs | 4 ++-- ...msKitPublicAppService.cs => CmsKitPublicAppServiceBase.cs} | 4 ++-- .../Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) rename modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/{CmsKitAdminAppService.cs => CmsKitAdminAppServiceBase.cs} (53%) rename modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/{CmsKitPublicAppService.cs => CmsKitPublicAppServiceBase.cs} (53%) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminAppServiceBase.cs similarity index 53% rename from modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminAppService.cs rename to modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminAppServiceBase.cs index 8ef58a46a6..3f4596f586 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminAppServiceBase.cs @@ -1,8 +1,8 @@ namespace Volo.CmsKit.Admin { - public abstract class CmsKitAdminAppService : CmsKitAppService + public abstract class CmsKitAdminAppServiceBase : CmsKitAppServiceBase { - protected CmsKitAdminAppService() + protected CmsKitAdminAppServiceBase() { ObjectMapperContext = typeof(CmsKitAdminApplicationModule); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitAdminAppService.cs index 7f8d7c8ab8..ffb2a8b197 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitAdminAppService.cs @@ -3,9 +3,9 @@ using Volo.CmsKit.Localization; namespace Volo.CmsKit { - public abstract class CmsKitAppService : ApplicationService + public abstract class CmsKitAppServiceBase : ApplicationService { - protected CmsKitAppService() + protected CmsKitAppServiceBase() { LocalizationResource = typeof(CmsKitResource); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicAppServiceBase.cs similarity index 53% rename from modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicAppService.cs rename to modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicAppServiceBase.cs index afdc42fd1a..eb2c185a6d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicAppServiceBase.cs @@ -1,8 +1,8 @@ namespace Volo.CmsKit.Public { - public abstract class CmsKitPublicAppService : CmsKitAppService + public abstract class CmsKitPublicAppServiceBase : CmsKitAppServiceBase { - protected CmsKitPublicAppService() + protected CmsKitPublicAppServiceBase() { ObjectMapperContext = typeof(CmsKitPublicApplicationModule); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs index 27fdd170ab..0108af0f51 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs @@ -9,7 +9,7 @@ using Volo.CmsKit.Reactions; namespace Volo.CmsKit.Public.Reactions { //TODO: Authorization - public class ReactionPublicAppService : CmsKitPublicAppService, IReactionPublicAppService + public class ReactionPublicAppService : CmsKitPublicAppServiceBase, IReactionPublicAppService { protected IReactionDefinitionStore ReactionDefinitionStore { get; } From 8b15001f0254a023a35045a4fca6b57e806bc39a Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Thu, 13 Aug 2020 17:05:20 +0300 Subject: [PATCH 024/190] fix(feature-management): resolve some bugs --- .../feature-management/feature-management.component.html | 6 +++--- .../feature-management/feature-management.component.ts | 4 ++-- .../feature-management/src/lib/models/feature-management.ts | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.html b/npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.html index 087a69a75c..6ee1766db7 100644 --- a/npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.html +++ b/npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.html @@ -10,11 +10,11 @@ *ngFor="let feature of features$ | async; let i = index" [ngSwitch]="feature.valueType.name" > -
{{ feature.name }}
-
+
{{ feature.displayName }}
+
-
+
diff --git a/npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.ts b/npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.ts index b8aba035bd..cd4d00491b 100644 --- a/npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.ts +++ b/npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.ts @@ -87,8 +87,8 @@ export class FeatureManagementComponent let features = this.store.selectSnapshot(FeatureManagementState.getFeatures); features = features.map((feature, i) => ({ - name: feature.name, - value: !this.form.value[i] || this.form.value[i] === 'false' ? null : this.form.value[i], + ...feature, + value: this.form.value[i], })); this.store diff --git a/npm/ng-packs/packages/feature-management/src/lib/models/feature-management.ts b/npm/ng-packs/packages/feature-management/src/lib/models/feature-management.ts index fa0165ae2e..02f6f687e2 100644 --- a/npm/ng-packs/packages/feature-management/src/lib/models/feature-management.ts +++ b/npm/ng-packs/packages/feature-management/src/lib/models/feature-management.ts @@ -13,6 +13,7 @@ export namespace FeatureManagement { export interface Feature { name: string; + displayName: string; value: string; description?: string; valueType?: ValueType; From 1b3b596eb0118dfc7b37b7cbbf47f08a378bea81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 13 Aug 2020 18:11:19 +0300 Subject: [PATCH 025/190] Added "features" to the CMS kit and implemented on the EF Core layer. --- .../FeatureConfigurer.cs | 10 ++++ .../Volo.CmsKit.Host.Shared.csproj | 4 ++ .../CmsKitHttpApiHostModule.cs | 7 ++- ...itHttpApiHostMigrationsDbContextFactory.cs | 2 + .../CmsKitIdentityServerModule.cs | 9 ++- ...ityServerHostMigrationsDbContextFactory.cs | 2 + .../CmsKitWebHostModule.cs | 4 +- .../CmsKitWebUnifiedModule.cs | 5 ++ .../UnifiedDbContextFactory.cs | 2 + .../Volo/CmsKit/CmsKitFeatures.cs | 56 +++++++++++++++++++ .../Volo/CmsKit/GlobalFeatures.cs | 42 ++++++++++++++ .../Comments/EfCoreCommentRepository.cs | 3 +- .../EntityFrameworkCore/CmsKitDbContext.cs | 9 --- .../CmsKitDbContextModelCreatingExtensions.cs | 48 +++++++++------- .../EntityFrameworkCore/ICmsKitDbContext.cs | 11 +--- .../Comments/CommentPublicAppService_Tests.cs | 11 ++-- .../ReactionPublicAppService_Tests.cs | 9 +-- .../Reactions/ReactionManager_Tests.cs | 2 +- .../CmsKitTestBaseModule.cs | 2 + 19 files changed, 179 insertions(+), 59 deletions(-) create mode 100644 modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitFeatures.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures.cs diff --git a/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs new file mode 100644 index 0000000000..3d4d983f3b --- /dev/null +++ b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs @@ -0,0 +1,10 @@ +namespace Volo.CmsKit +{ + public static class FeatureConfigurer + { + public static void Configure() + { + CmsKitFeatures.EnableAll(); + } + } +} diff --git a/modules/cms-kit/host/Volo.CmsKit.Host.Shared/Volo.CmsKit.Host.Shared.csproj b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/Volo.CmsKit.Host.Shared.csproj index 3f8c167b98..c6a4484865 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Host.Shared/Volo.CmsKit.Host.Shared.csproj +++ b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/Volo.CmsKit.Host.Shared.csproj @@ -7,4 +7,8 @@ Volo.CmsKit + + + + diff --git a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/CmsKitHttpApiHostModule.cs b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/CmsKitHttpApiHostModule.cs index c63d28081f..f1a9b8568f 100644 --- a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/CmsKitHttpApiHostModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/CmsKitHttpApiHostModule.cs @@ -52,6 +52,11 @@ namespace Volo.CmsKit { private const string DefaultCorsPolicyName = "Default"; + public override void PreConfigureServices(ServiceConfigurationContext context) + { + FeatureConfigurer.Configure(); + } + public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); @@ -163,7 +168,7 @@ namespace Volo.CmsKit app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseCors(DefaultCorsPolicyName); + app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseAbpClaimsMap(); if (MultiTenancyConsts.IsEnabled) diff --git a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContextFactory.cs b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContextFactory.cs index 3a6dbb47ad..dc19e09635 100644 --- a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContextFactory.cs +++ b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContextFactory.cs @@ -9,6 +9,8 @@ namespace Volo.CmsKit.EntityFrameworkCore { public CmsKitHttpApiHostMigrationsDbContext CreateDbContext(string[] args) { + FeatureConfigurer.Configure(); + var configuration = BuildConfiguration(); var builder = new DbContextOptionsBuilder() diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/CmsKitIdentityServerModule.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/CmsKitIdentityServerModule.cs index faf90a3fc2..b9afe934a3 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/CmsKitIdentityServerModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/CmsKitIdentityServerModule.cs @@ -77,6 +77,11 @@ namespace Volo.CmsKit { private const string DefaultCorsPolicyName = "Default"; + public override void PreConfigureServices(ServiceConfigurationContext context) + { + FeatureConfigurer.Configure(); + } + public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); @@ -182,10 +187,10 @@ namespace Volo.CmsKit app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseCors(DefaultCorsPolicyName); + app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseJwtTokenMiddleware(); - + if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs index f6e80d62ec..19402b80c1 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs @@ -9,6 +9,8 @@ namespace Volo.CmsKit.EntityFrameworkCore { public IdentityServerHostMigrationsDbContext CreateDbContext(string[] args) { + FeatureConfigurer.Configure(); + var configuration = BuildConfiguration(); var builder = new DbContextOptionsBuilder() diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostModule.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostModule.cs index 95946c54df..7587b075d0 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostModule.cs @@ -65,6 +65,8 @@ namespace Volo.CmsKit { public override void PreConfigureServices(ServiceConfigurationContext context) { + FeatureConfigurer.Configure(); + context.Services.PreConfigure(options => { options.AddAssemblyResource( @@ -222,7 +224,7 @@ namespace Volo.CmsKit app.UseHttpsRedirection(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAuthentication(); + app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) { diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs index b1cd636ef0..08dadb3dd6 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs @@ -63,6 +63,11 @@ namespace Volo.CmsKit )] public class CmsKitWebUnifiedModule : AbpModule { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + FeatureConfigurer.Configure(); + } + public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs index f2c1d8a065..170e4dc688 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs @@ -9,6 +9,8 @@ namespace Volo.CmsKit.EntityFrameworkCore { public UnifiedDbContext CreateDbContext(string[] args) { + FeatureConfigurer.Configure(); + var configuration = BuildConfiguration(); var builder = new DbContextOptionsBuilder() diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitFeatures.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitFeatures.cs new file mode 100644 index 0000000000..6e9dff0011 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitFeatures.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; + +namespace Volo.CmsKit +{ + public static class CmsKitFeatures + { + public const string NamePrefix = "CmsKit"; + + public static class Reactions + { + public const string Name = NamePrefix + ".Reactions"; + + public static bool IsEnabled + { + get => GlobalFeatures.IsEnabled(Name); + set => GlobalFeatures.SetEnabled(Name, value); + } + } + + public static class Comments + { + public const string Name = NamePrefix + ".Comments"; + + public static bool IsEnabled + { + get => GlobalFeatures.IsEnabled(Name); + set => GlobalFeatures.SetEnabled(Name, value); + } + } + + public static void EnableAll() + { + foreach (var featureName in GetAllNames()) + { + GlobalFeatures.Enable(featureName); + } + } + + public static void DisableAll() + { + foreach (var featureName in GetAllNames()) + { + GlobalFeatures.Disable(featureName); + } + } + + public static IEnumerable GetAllNames() + { + return new[] + { + Reactions.Name, + Comments.Name + }; + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures.cs new file mode 100644 index 0000000000..3c038431ca --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Volo.CmsKit +{ + internal static class GlobalFeatures //TODO: Move to the ABP Framework..? + { + private static readonly HashSet EnabledFeatures = new HashSet(); + + public static bool IsEnabled(string featureName) + { + return EnabledFeatures.Contains(featureName); + } + + public static void SetEnabled(string featureName, bool isEnabled) + { + if (isEnabled) + { + Enable(featureName); + } + else + { + Disable(featureName); + } + } + + public static void Enable(string featureName) + { + EnabledFeatures.AddIfNotContains(featureName); + } + + public static void Disable(string featureName) + { + EnabledFeatures.Remove(featureName); + } + + public static IEnumerable GetEnabledFeatures() + { + return EnabledFeatures; + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 00b3150219..6a1b8d6a50 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -8,6 +8,7 @@ using Volo.Abp; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; +using Volo.CmsKit.Users; namespace Volo.CmsKit.Comments { @@ -27,7 +28,7 @@ namespace Volo.CmsKit.Comments Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); var query = from comment in DbSet - join user in DbContext.CmsUsers on comment.CreatorId equals user.Id + join user in DbContext.Set() on comment.CreatorId equals user.Id where entityType == comment.EntityType && entityId == comment.EntityId orderby comment.CreationTime select new CommentWithAuthorQueryResultItem diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs index 8033522f70..65d9b55181 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs @@ -1,21 +1,12 @@ using Microsoft.EntityFrameworkCore; using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; -using Volo.CmsKit.Comments; -using Volo.CmsKit.Reactions; -using Volo.CmsKit.Users; namespace Volo.CmsKit.EntityFrameworkCore { [ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] public class CmsKitDbContext : AbpDbContext, ICmsKitDbContext { - public DbSet UserReactions { get; set; } - - public DbSet Comments { get; set; } - - public DbSet CmsUsers { get; set; } - public CmsKitDbContext(DbContextOptions options) : base(options) { 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 e945ddc7ed..d778f43f57 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 @@ -32,34 +32,40 @@ namespace Volo.CmsKit.EntityFrameworkCore b.ConfigureAbpUser(); }); - builder.Entity(b => + if (CmsKitFeatures.Reactions.IsEnabled) { - b.ToTable(options.TablePrefix + "UserReactions", options.Schema); - b.ConfigureByConvention(); + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "UserReactions", options.Schema); + b.ConfigureByConvention(); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityIdLength); - b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.MaxReactionNameLength); - b.Property(x => x.CreationTime); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityIdLength); + b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.MaxReactionNameLength); + b.Property(x => x.CreationTime); - b.HasIndex(x => new { x.EntityType, x.EntityId }); - b.HasIndex(x => new { x.CreatorId, x.EntityType, x.EntityId, x.ReactionName }); - }); + b.HasIndex(x => new { x.EntityType, x.EntityId }); + b.HasIndex(x => new { x.CreatorId, x.EntityType, x.EntityId, x.ReactionName }); + }); + } - builder.Entity(b => + if (CmsKitFeatures.Comments.IsEnabled) { - b.ToTable(options.TablePrefix + "Comments", options.Schema); - b.ConfigureByConvention(); + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Comments", options.Schema); + b.ConfigureByConvention(); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.MaxEntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.MaxEntityIdLength); - b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength); - b.Property(x => x.RepliedCommentId); - b.Property(x => x.CreationTime); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.MaxEntityIdLength); + b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength); + b.Property(x => x.RepliedCommentId); + b.Property(x => x.CreationTime); - b.HasIndex(x => new { x.EntityType, x.EntityId }); - b.HasIndex(x => new { x.RepliedCommentId }); - }); + b.HasIndex(x => new { x.EntityType, x.EntityId }); + b.HasIndex(x => new { x.RepliedCommentId }); + }); + } } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/ICmsKitDbContext.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/ICmsKitDbContext.cs index e63366d5ae..352335fb7c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/ICmsKitDbContext.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/ICmsKitDbContext.cs @@ -1,19 +1,10 @@ -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Data; +using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; -using Volo.CmsKit.Comments; -using Volo.CmsKit.Reactions; -using Volo.CmsKit.Users; namespace Volo.CmsKit.EntityFrameworkCore { [ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] public interface ICmsKitDbContext : IEfCoreDbContext { - DbSet UserReactions { get; } - - DbSet Comments { get; } - - DbSet CmsUsers { get; set; } } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentPublicAppService_Tests.cs index 9568f79c6f..f02339dde8 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentPublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentPublicAppService_Tests.cs @@ -1,11 +1,8 @@ -using System; -using System.Linq; +using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using NSubstitute; using Shouldly; -using Volo.Abp.MultiTenancy; using Volo.Abp.Users; using Volo.CmsKit.Public.Comments; using Xunit; @@ -54,7 +51,7 @@ namespace Volo.CmsKit.Comments UsingDbContext(context => { - var comments = context.Comments.Where(x => + var comments = context.Set().Where(x => x.EntityId == _cmsKitTestData.EntityId1 && x.EntityType == _cmsKitTestData.EntityType1).ToList(); comments @@ -75,7 +72,7 @@ namespace Volo.CmsKit.Comments UsingDbContext(context => { - var comment = context.Comments.Single(x => + var comment = context.Set().Single(x => x.Id == _cmsKitTestData.CommentWithChildId); comment.Text.ShouldBe("I'm Updated"); @@ -91,7 +88,7 @@ namespace Volo.CmsKit.Comments UsingDbContext(context => { - var comment = context.Comments.FirstOrDefault(x => + var comment = context.Set().FirstOrDefault(x => x.Id == _cmsKitTestData.CommentWithChildId); comment.ShouldBeNull(); diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs index dd74a1f1e7..615003efec 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using NSubstitute; @@ -69,7 +66,7 @@ namespace Volo.CmsKit.Reactions UsingDbContext(context => { - var reaction = context.UserReactions.FirstOrDefault(x => + var reaction = context.Set().FirstOrDefault(x => x.CreatorId == _cmsKitTestData.User1Id && x.ReactionName == StandardReactions.Hooray && x.EntityId == _cmsKitTestData.EntityId2 && @@ -93,7 +90,7 @@ namespace Volo.CmsKit.Reactions UsingDbContext(context => { - var reaction = context.UserReactions.FirstOrDefault(x => + var reaction = context.Set().FirstOrDefault(x => x.CreatorId == _cmsKitTestData.User1Id && x.ReactionName == StandardReactions.Confused && x.EntityId == _cmsKitTestData.EntityId1 && diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Reactions/ReactionManager_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Reactions/ReactionManager_Tests.cs index 6f4fe2425d..453d393bb8 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Reactions/ReactionManager_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Reactions/ReactionManager_Tests.cs @@ -69,7 +69,7 @@ namespace Volo.CmsKit.Reactions UsingDbContext(context => { - var reaction = context.UserReactions.FirstOrDefault(x => + var reaction = context.Set().FirstOrDefault(x => x.CreatorId == _cmsKitTestData.User1Id && x.ReactionName == StandardReactions.Confused && x.EntityId == _cmsKitTestData.EntityId1 && diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs index ae1f0f7296..7451c755a8 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs @@ -18,6 +18,8 @@ namespace Volo.CmsKit { public override void ConfigureServices(ServiceConfigurationContext context) { + CmsKitFeatures.EnableAll(); + context.Services.AddAlwaysAllowAuthorization(); } From 389d20c737e7fa3102e7f9b3fd9f25fbe8cd7089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 13 Aug 2020 22:57:51 +0300 Subject: [PATCH 026/190] Implement basic GlobalFeatureManager. --- .../FeatureConfigurer.cs | 6 +- .../Volo/Abp/GlobalFeatures/GlobalFeature.cs | 36 ++++++++++++ .../GlobalFeatures/GlobalFeatureManager.cs | 54 ++++++++++++++++++ .../GlobalFeatureManagerCmsKitConfigurator.cs | 12 ++++ ...tureManagerCmsKitConfiguratorExtensions.cs | 52 +++++++++++++++++ .../GlobalFeatureManagerExtensions.cs | 18 ++++++ .../GlobalFeatureManagerModuleConfigurator.cs | 36 ++++++++++++ ...nagerModuleConfiguratorCmsKitExtensions.cs | 30 ++++++++++ ...GlobalFeatureManagerModulesConfigurator.cs | 19 +++++++ .../Volo/CmsKit/CmsKitDomainSharedModule.cs | 17 +++++- .../Volo/CmsKit/CmsKitFeatures.cs | 56 ------------------- .../Volo/CmsKit/GlobalFeatures.cs | 42 -------------- .../CmsKitDbContextModelCreatingExtensions.cs | 5 +- .../CmsKitTestBaseModule.cs | 3 +- 14 files changed, 282 insertions(+), 104 deletions(-) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfiguratorExtensions.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerExtensions.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModulesConfigurator.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitFeatures.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures.cs diff --git a/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs index 3d4d983f3b..162fa7cf51 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs @@ -1,10 +1,12 @@ -namespace Volo.CmsKit +using Volo.Abp.GlobalFeatures; + +namespace Volo.CmsKit { public static class FeatureConfigurer { public static void Configure() { - CmsKitFeatures.EnableAll(); + GlobalFeatureManager.Instance.Modules().CmsKit().EnableAll(); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs new file mode 100644 index 0000000000..4221b635c0 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs @@ -0,0 +1,36 @@ +using JetBrains.Annotations; + +namespace Volo.Abp.GlobalFeatures +{ + public class GlobalFeature + { + public GlobalFeatureManagerModuleConfigurator ModuleConfigurator { get; } + + public string Name { get; } + + public bool IsEnabled => ModuleConfigurator.ModulesConfigurator.FeatureManager.IsEnabled(Name); + + public GlobalFeature( + [NotNull] GlobalFeatureManagerModuleConfigurator moduleConfigurator, + [NotNull] string name) + { + ModuleConfigurator = Check.NotNull(moduleConfigurator, nameof(moduleConfigurator)); + Name = Check.NotNullOrWhiteSpace(name, nameof(name)); + } + + public virtual void Enable() + { + ModuleConfigurator.ModulesConfigurator.FeatureManager.Enable(Name); + } + + public virtual void Disable() + { + ModuleConfigurator.ModulesConfigurator.FeatureManager.Disable(Name); + } + + public virtual void SetEnabled(bool isEnabled) + { + ModuleConfigurator.ModulesConfigurator.FeatureManager.SetEnabled(Name, isEnabled); + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs new file mode 100644 index 0000000000..bed947e4a8 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs @@ -0,0 +1,54 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using JetBrains.Annotations; + +namespace Volo.Abp.GlobalFeatures +{ + public class GlobalFeatureManager //TODO: Move to the ABP Framework..? //rename? + { + public static GlobalFeatureManager Instance { get; protected set; } = new GlobalFeatureManager(); + + [NotNull] + public ConcurrentDictionary Configuration { get; } + + protected HashSet EnabledFeatures { get; } + + private GlobalFeatureManager() + { + EnabledFeatures = new HashSet(); + Configuration = new ConcurrentDictionary(); + } + + public virtual bool IsEnabled(string featureName) + { + return EnabledFeatures.Contains(featureName); + } + + public virtual void SetEnabled(string featureName, bool isEnabled) + { + if (isEnabled) + { + Enable(featureName); + } + else + { + Disable(featureName); + } + } + + public virtual void Enable(string featureName) + { + EnabledFeatures.AddIfNotContains(featureName); + } + + public virtual void Disable(string featureName) + { + EnabledFeatures.Remove(featureName); + } + + public virtual IEnumerable GetEnabledFeatures() + { + return EnabledFeatures; + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs new file mode 100644 index 0000000000..c3a1183866 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs @@ -0,0 +1,12 @@ +namespace Volo.Abp.GlobalFeatures +{ + public class GlobalFeatureManagerCmsKitConfigurator : GlobalFeatureManagerModuleConfigurator + { + public GlobalFeatureManagerCmsKitConfigurator(GlobalFeatureManagerModulesConfigurator modulesConfigurator) + : base(modulesConfigurator) + { + this.Reactions(); + this.Comments(); + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfiguratorExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfiguratorExtensions.cs new file mode 100644 index 0000000000..4175271f0b --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfiguratorExtensions.cs @@ -0,0 +1,52 @@ +using System; +using JetBrains.Annotations; + +namespace Volo.Abp.GlobalFeatures +{ + public static class GlobalFeatureManagerCmsKitConfiguratorExtensions + { + public static GlobalFeature Reactions( + [NotNull] this GlobalFeatureManagerCmsKitConfigurator cmsKitConfigurator) + { + Check.NotNull(cmsKitConfigurator, nameof(cmsKitConfigurator)); + + return cmsKitConfigurator + .Features + .GetOrAdd("Reactions", _ => new GlobalFeature(cmsKitConfigurator, "CmsKit:Reactions")) + as GlobalFeature; + } + + public static GlobalFeatureManagerCmsKitConfigurator Reactions( + [NotNull] this GlobalFeatureManagerCmsKitConfigurator cmsKitConfigurator, + [NotNull] Action configureAction) + { + Check.NotNull(cmsKitConfigurator, nameof(cmsKitConfigurator)); + + configureAction(cmsKitConfigurator.Reactions()); + + return cmsKitConfigurator; + } + + public static GlobalFeature Comments( + [NotNull] this GlobalFeatureManagerCmsKitConfigurator cmsKitConfigurator) + { + Check.NotNull(cmsKitConfigurator, nameof(cmsKitConfigurator)); + + return cmsKitConfigurator + .Features + .GetOrAdd("Comments", _ => new GlobalFeature(cmsKitConfigurator, "CmsKit:Comments")) + as GlobalFeature; + } + + public static GlobalFeatureManagerCmsKitConfigurator Comments( + [NotNull] this GlobalFeatureManagerCmsKitConfigurator cmsKitConfigurator, + [NotNull] Action configureAction) + { + Check.NotNull(cmsKitConfigurator, nameof(cmsKitConfigurator)); + + configureAction(cmsKitConfigurator.Comments()); + + return cmsKitConfigurator; + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerExtensions.cs new file mode 100644 index 0000000000..9f148fcef9 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerExtensions.cs @@ -0,0 +1,18 @@ +using JetBrains.Annotations; + +namespace Volo.Abp.GlobalFeatures +{ + public static class GlobalFeatureManagerExtensions + { + public static GlobalFeatureManagerModulesConfigurator Modules( + [NotNull] this GlobalFeatureManager featureManager) + { + Check.NotNull(featureManager, nameof(featureManager)); + + return featureManager + .Configuration + .GetOrAdd("_Modules", _ => new GlobalFeatureManagerModulesConfigurator(featureManager)) + as GlobalFeatureManagerModulesConfigurator; + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs new file mode 100644 index 0000000000..1c9ff9ae7c --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs @@ -0,0 +1,36 @@ +using System.Collections.Concurrent; +using JetBrains.Annotations; + +namespace Volo.Abp.GlobalFeatures +{ + public abstract class GlobalFeatureManagerModuleConfigurator + { + [NotNull] + public GlobalFeatureManagerModulesConfigurator ModulesConfigurator { get; } + + [NotNull] + public ConcurrentDictionary Features { get; } + + protected GlobalFeatureManagerModuleConfigurator(GlobalFeatureManagerModulesConfigurator modulesConfigurator) + { + ModulesConfigurator = Check.NotNull(modulesConfigurator, nameof(modulesConfigurator)); + Features = new ConcurrentDictionary(); + } + + public virtual void EnableAll() + { + foreach (var feature in Features.Values) + { + feature.Enable(); + } + } + + public virtual void DisableAll() + { + foreach (var feature in Features.Values) + { + feature.Disable(); + } + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs new file mode 100644 index 0000000000..9449ef702c --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs @@ -0,0 +1,30 @@ +using System; +using JetBrains.Annotations; + +namespace Volo.Abp.GlobalFeatures +{ + public static class GlobalFeatureManagerModuleConfiguratorCmsKitExtensions + { + public static GlobalFeatureManagerCmsKitConfigurator CmsKit( + [NotNull] this GlobalFeatureManagerModulesConfigurator modulesConfigurator) + { + Check.NotNull(modulesConfigurator, nameof(modulesConfigurator)); + + return modulesConfigurator + .Modules + .GetOrAdd("CmsKit", _ => new GlobalFeatureManagerCmsKitConfigurator(modulesConfigurator)) + as GlobalFeatureManagerCmsKitConfigurator; + } + + public static GlobalFeatureManagerModulesConfigurator CmsKit( + [NotNull] this GlobalFeatureManagerModulesConfigurator modulesConfigurator, + [NotNull] Action configureAction) + { + Check.NotNull(configureAction, nameof(configureAction)); + + configureAction(modulesConfigurator.CmsKit()); + + return modulesConfigurator; + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModulesConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModulesConfigurator.cs new file mode 100644 index 0000000000..acaa13beab --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModulesConfigurator.cs @@ -0,0 +1,19 @@ +using System.Collections.Concurrent; +using JetBrains.Annotations; + +namespace Volo.Abp.GlobalFeatures +{ + public class GlobalFeatureManagerModulesConfigurator //TODO: Change to GlobalFeatureManagerModuleDictionary and inherit from ConcurrentDictionary + { + public GlobalFeatureManager FeatureManager { get; } + + [NotNull] + public ConcurrentDictionary Modules { get; } + + public GlobalFeatureManagerModulesConfigurator([NotNull] GlobalFeatureManager featureManager) + { + FeatureManager = Check.NotNull(featureManager, nameof(featureManager)); + Modules = new ConcurrentDictionary(); + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs index 925acdaf79..468222df8f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Modularity; +using Volo.Abp.GlobalFeatures; +using Volo.Abp.Modularity; using Volo.Abp.Localization; using Volo.CmsKit.Localization; using Volo.Abp.Localization.ExceptionHandling; @@ -15,6 +16,20 @@ namespace Volo.CmsKit { public override void ConfigureServices(ServiceConfigurationContext context) { + GlobalFeatureManager.Instance.Modules().CmsKit().EnableAll(); + GlobalFeatureManager.Instance.Modules().CmsKit().DisableAll(); + GlobalFeatureManager.Instance.Modules().CmsKit().Reactions().Enable(); + GlobalFeatureManager.Instance.Modules().CmsKit(cmsKit => + { + cmsKit.Reactions().Disable(); + cmsKit.Reactions(reactions => + { + reactions.Enable(); + }); + }); + + GlobalFeatureManager.Instance.IsEnabled("asd"); + Configure(options => { options.FileSets.AddEmbedded(); diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitFeatures.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitFeatures.cs deleted file mode 100644 index 6e9dff0011..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitFeatures.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Collections.Generic; - -namespace Volo.CmsKit -{ - public static class CmsKitFeatures - { - public const string NamePrefix = "CmsKit"; - - public static class Reactions - { - public const string Name = NamePrefix + ".Reactions"; - - public static bool IsEnabled - { - get => GlobalFeatures.IsEnabled(Name); - set => GlobalFeatures.SetEnabled(Name, value); - } - } - - public static class Comments - { - public const string Name = NamePrefix + ".Comments"; - - public static bool IsEnabled - { - get => GlobalFeatures.IsEnabled(Name); - set => GlobalFeatures.SetEnabled(Name, value); - } - } - - public static void EnableAll() - { - foreach (var featureName in GetAllNames()) - { - GlobalFeatures.Enable(featureName); - } - } - - public static void DisableAll() - { - foreach (var featureName in GetAllNames()) - { - GlobalFeatures.Disable(featureName); - } - } - - public static IEnumerable GetAllNames() - { - return new[] - { - Reactions.Name, - Comments.Name - }; - } - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures.cs deleted file mode 100644 index 3c038431ca..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace Volo.CmsKit -{ - internal static class GlobalFeatures //TODO: Move to the ABP Framework..? - { - private static readonly HashSet EnabledFeatures = new HashSet(); - - public static bool IsEnabled(string featureName) - { - return EnabledFeatures.Contains(featureName); - } - - public static void SetEnabled(string featureName, bool isEnabled) - { - if (isEnabled) - { - Enable(featureName); - } - else - { - Disable(featureName); - } - } - - public static void Enable(string featureName) - { - EnabledFeatures.AddIfNotContains(featureName); - } - - public static void Disable(string featureName) - { - EnabledFeatures.Remove(featureName); - } - - public static IEnumerable GetEnabledFeatures() - { - return EnabledFeatures; - } - } -} 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 d778f43f57..d16d11c40a 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 @@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore; using Volo.Abp; using Volo.Abp.EntityFrameworkCore.Modeling; +using Volo.Abp.GlobalFeatures; using Volo.CmsKit.Comments; using Volo.CmsKit.Reactions; using Volo.CmsKit.Users; @@ -32,7 +33,7 @@ namespace Volo.CmsKit.EntityFrameworkCore b.ConfigureAbpUser(); }); - if (CmsKitFeatures.Reactions.IsEnabled) + if (GlobalFeatureManager.Instance.Modules().CmsKit().Reactions().IsEnabled) { builder.Entity(b => { @@ -49,7 +50,7 @@ namespace Volo.CmsKit.EntityFrameworkCore }); } - if (CmsKitFeatures.Comments.IsEnabled) + if (GlobalFeatureManager.Instance.Modules().CmsKit().Comments().IsEnabled) { builder.Entity(b => { diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs index 7451c755a8..9ceaa348d0 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs @@ -3,6 +3,7 @@ using Volo.Abp; using Volo.Abp.Authorization; using Volo.Abp.Autofac; using Volo.Abp.Data; +using Volo.Abp.GlobalFeatures; using Volo.Abp.Modularity; using Volo.Abp.Threading; @@ -18,7 +19,7 @@ namespace Volo.CmsKit { public override void ConfigureServices(ServiceConfigurationContext context) { - CmsKitFeatures.EnableAll(); + GlobalFeatureManager.Instance.Modules().CmsKit().EnableAll(); context.Services.AddAlwaysAllowAuthorization(); } From 55c7433990e5fdfe0944480eff6c05c54f8c5467 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Fri, 14 Aug 2020 10:41:44 +0300 Subject: [PATCH 027/190] feat: display as a primary button if the actions only has a single item #4218 --- .../extensible-table.component.ts | 10 ++++- .../grid-actions/grid-actions.component.html | 42 +++++++++++++------ 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts index ea7ef33687..47a7131201 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts @@ -32,7 +32,15 @@ const DEFAULT_ACTIONS_COLUMN_WIDTH = 150; changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExtensibleTableComponent implements OnChanges { - @Input() actionsText: string; + protected _actionsText: string; + @Input() + set actionsText(value: string) { + this._actionsText = value; + } + get actionsText(): string { + return this._actionsText ?? (this.actionList.length > 1 ? 'AbpUi::Actions' : ''); + } + @Input() data: R[]; @Input() list: ListService; @Input() recordsTotal: number; diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/grid-actions/grid-actions.component.html b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/grid-actions/grid-actions.component.html index 04ac1017a4..3985faf229 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/grid-actions/grid-actions.component.html +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/grid-actions/grid-actions.component.html @@ -1,4 +1,4 @@ -
+
- - +
+ + + + + + From 563fc1c6fc01493a9986c158f418ee367b91ea31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 14 Aug 2020 12:07:49 +0300 Subject: [PATCH 028/190] Revised the feature system. --- .../FeatureConfigurer.cs | 2 +- .../Volo/Abp/GlobalFeatures/GlobalFeature.cs | 36 ------------- .../GlobalFeatureConfigurator.cs | 45 ++++++++++++++++ .../GlobalFeatureConfiguratorDictionary.cs | 9 ++++ .../GlobalFeatures/GlobalFeatureManager.cs | 35 +++++++++++-- .../GlobalFeatureManagerCmsKitConfigurator.cs | 12 ----- ...tureManagerCmsKitConfiguratorExtensions.cs | 52 ------------------- .../GlobalFeatureManagerExtensions.cs | 18 ------- .../GlobalFeatureManagerModuleConfigurator.cs | 41 +++++++++++---- ...nagerModuleConfiguratorCmsKitExtensions.cs | 25 ++++----- ...GlobalFeatureManagerModulesConfigurator.cs | 11 ++-- .../GlobalFeatureNameAttribute.cs | 40 ++++++++++++++ .../Volo/CmsKit/CmsKitDomainSharedModule.cs | 16 +++--- .../CmsKit/GlobalFeatures/CommentsFeature.cs | 17 ++++++ .../GlobalFeatureManagerCmsKitConfigurator.cs | 20 +++++++ .../CmsKit/GlobalFeatures/ReactionsFeature.cs | 17 ++++++ .../CmsKitDbContextModelCreatingExtensions.cs | 5 +- .../CmsKitTestBaseModule.cs | 2 +- 18 files changed, 239 insertions(+), 164 deletions(-) delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfigurator.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfiguratorDictionary.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfiguratorExtensions.cs delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerExtensions.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureNameAttribute.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs diff --git a/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs index 162fa7cf51..d600e99cd9 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs @@ -6,7 +6,7 @@ namespace Volo.CmsKit { public static void Configure() { - GlobalFeatureManager.Instance.Modules().CmsKit().EnableAll(); + GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll(); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs deleted file mode 100644 index 4221b635c0..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs +++ /dev/null @@ -1,36 +0,0 @@ -using JetBrains.Annotations; - -namespace Volo.Abp.GlobalFeatures -{ - public class GlobalFeature - { - public GlobalFeatureManagerModuleConfigurator ModuleConfigurator { get; } - - public string Name { get; } - - public bool IsEnabled => ModuleConfigurator.ModulesConfigurator.FeatureManager.IsEnabled(Name); - - public GlobalFeature( - [NotNull] GlobalFeatureManagerModuleConfigurator moduleConfigurator, - [NotNull] string name) - { - ModuleConfigurator = Check.NotNull(moduleConfigurator, nameof(moduleConfigurator)); - Name = Check.NotNullOrWhiteSpace(name, nameof(name)); - } - - public virtual void Enable() - { - ModuleConfigurator.ModulesConfigurator.FeatureManager.Enable(Name); - } - - public virtual void Disable() - { - ModuleConfigurator.ModulesConfigurator.FeatureManager.Disable(Name); - } - - public virtual void SetEnabled(bool isEnabled) - { - ModuleConfigurator.ModulesConfigurator.FeatureManager.SetEnabled(Name, isEnabled); - } - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfigurator.cs new file mode 100644 index 0000000000..fb259d7df6 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfigurator.cs @@ -0,0 +1,45 @@ +using JetBrains.Annotations; + +namespace Volo.Abp.GlobalFeatures +{ + public class GlobalFeature + { + [NotNull] + public GlobalModuleFeatures Module { get; } + + [NotNull] + public GlobalFeatureManager FeatureManager { get; } + + public string FeatureName { get; } + + public bool IsEnabled + { + get => FeatureManager.IsEnabled(FeatureName); + set => FeatureManager.SetEnabled(FeatureName, value); + } + + public GlobalFeature( + [NotNull] GlobalModuleFeatures module, + [NotNull] string name) + { + Module = Check.NotNull(module, nameof(module)); + FeatureName = Check.NotNullOrWhiteSpace(name, nameof(name)); + FeatureManager = Module.FeatureManager; + } + + public virtual void Enable() + { + FeatureManager.Enable(FeatureName); + } + + public virtual void Disable() + { + FeatureManager.Disable(FeatureName); + } + + public virtual void SetEnabled(bool isEnabled) + { + + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfiguratorDictionary.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfiguratorDictionary.cs new file mode 100644 index 0000000000..72114eff3d --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfiguratorDictionary.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Volo.Abp.GlobalFeatures +{ + public class GlobalFeatureConfiguratorDictionary : Dictionary + { + + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs index bed947e4a8..7819f985de 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs @@ -4,19 +4,46 @@ using JetBrains.Annotations; namespace Volo.Abp.GlobalFeatures { - public class GlobalFeatureManager //TODO: Move to the ABP Framework..? //rename? + public class GlobalFeatureManager { public static GlobalFeatureManager Instance { get; protected set; } = new GlobalFeatureManager(); [NotNull] - public ConcurrentDictionary Configuration { get; } + public Dictionary Configuration { get; } + + public GlobalFeatureManagerModuleDictionary Modules { get; } protected HashSet EnabledFeatures { get; } private GlobalFeatureManager() { EnabledFeatures = new HashSet(); - Configuration = new ConcurrentDictionary(); + Configuration = new Dictionary(); + Modules = new GlobalFeatureManagerModuleDictionary(this); + } + + public virtual bool IsEnabled() + where TFeature : GlobalFeature + { + return IsEnabled(GlobalFeatureNameAttribute.GetName()); + } + + public virtual void SetEnabled(bool isEnabled) + where TFeature : GlobalFeature + { + SetEnabled(GlobalFeatureNameAttribute.GetName(), isEnabled); + } + + public virtual void Enable() + where TFeature : GlobalFeature + { + Enable(GlobalFeatureNameAttribute.GetName()); + } + + public virtual void Disable() + where TFeature : GlobalFeature + { + Disable(GlobalFeatureNameAttribute.GetName()); } public virtual bool IsEnabled(string featureName) @@ -46,7 +73,7 @@ namespace Volo.Abp.GlobalFeatures EnabledFeatures.Remove(featureName); } - public virtual IEnumerable GetEnabledFeatures() + public virtual IEnumerable GetEnabledFeatureNames() { return EnabledFeatures; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs deleted file mode 100644 index c3a1183866..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Volo.Abp.GlobalFeatures -{ - public class GlobalFeatureManagerCmsKitConfigurator : GlobalFeatureManagerModuleConfigurator - { - public GlobalFeatureManagerCmsKitConfigurator(GlobalFeatureManagerModulesConfigurator modulesConfigurator) - : base(modulesConfigurator) - { - this.Reactions(); - this.Comments(); - } - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfiguratorExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfiguratorExtensions.cs deleted file mode 100644 index 4175271f0b..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerCmsKitConfiguratorExtensions.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using JetBrains.Annotations; - -namespace Volo.Abp.GlobalFeatures -{ - public static class GlobalFeatureManagerCmsKitConfiguratorExtensions - { - public static GlobalFeature Reactions( - [NotNull] this GlobalFeatureManagerCmsKitConfigurator cmsKitConfigurator) - { - Check.NotNull(cmsKitConfigurator, nameof(cmsKitConfigurator)); - - return cmsKitConfigurator - .Features - .GetOrAdd("Reactions", _ => new GlobalFeature(cmsKitConfigurator, "CmsKit:Reactions")) - as GlobalFeature; - } - - public static GlobalFeatureManagerCmsKitConfigurator Reactions( - [NotNull] this GlobalFeatureManagerCmsKitConfigurator cmsKitConfigurator, - [NotNull] Action configureAction) - { - Check.NotNull(cmsKitConfigurator, nameof(cmsKitConfigurator)); - - configureAction(cmsKitConfigurator.Reactions()); - - return cmsKitConfigurator; - } - - public static GlobalFeature Comments( - [NotNull] this GlobalFeatureManagerCmsKitConfigurator cmsKitConfigurator) - { - Check.NotNull(cmsKitConfigurator, nameof(cmsKitConfigurator)); - - return cmsKitConfigurator - .Features - .GetOrAdd("Comments", _ => new GlobalFeature(cmsKitConfigurator, "CmsKit:Comments")) - as GlobalFeature; - } - - public static GlobalFeatureManagerCmsKitConfigurator Comments( - [NotNull] this GlobalFeatureManagerCmsKitConfigurator cmsKitConfigurator, - [NotNull] Action configureAction) - { - Check.NotNull(cmsKitConfigurator, nameof(cmsKitConfigurator)); - - configureAction(cmsKitConfigurator.Comments()); - - return cmsKitConfigurator; - } - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerExtensions.cs deleted file mode 100644 index 9f148fcef9..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerExtensions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using JetBrains.Annotations; - -namespace Volo.Abp.GlobalFeatures -{ - public static class GlobalFeatureManagerExtensions - { - public static GlobalFeatureManagerModulesConfigurator Modules( - [NotNull] this GlobalFeatureManager featureManager) - { - Check.NotNull(featureManager, nameof(featureManager)); - - return featureManager - .Configuration - .GetOrAdd("_Modules", _ => new GlobalFeatureManagerModulesConfigurator(featureManager)) - as GlobalFeatureManagerModulesConfigurator; - } - } -} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs index 1c9ff9ae7c..edd1c7f0aa 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs @@ -1,25 +1,25 @@ -using System.Collections.Concurrent; -using JetBrains.Annotations; +using JetBrains.Annotations; namespace Volo.Abp.GlobalFeatures { - public abstract class GlobalFeatureManagerModuleConfigurator + public abstract class GlobalModuleFeatures { [NotNull] - public GlobalFeatureManagerModulesConfigurator ModulesConfigurator { get; } + public GlobalFeatureConfiguratorDictionary AllFeatures { get; } [NotNull] - public ConcurrentDictionary Features { get; } + public GlobalFeatureManager FeatureManager { get; } - protected GlobalFeatureManagerModuleConfigurator(GlobalFeatureManagerModulesConfigurator modulesConfigurator) + protected GlobalModuleFeatures( + GlobalFeatureManager featureManager) { - ModulesConfigurator = Check.NotNull(modulesConfigurator, nameof(modulesConfigurator)); - Features = new ConcurrentDictionary(); + AllFeatures = new GlobalFeatureConfiguratorDictionary(); + FeatureManager = featureManager; } public virtual void EnableAll() { - foreach (var feature in Features.Values) + foreach (var feature in AllFeatures.Values) { feature.Enable(); } @@ -27,10 +27,31 @@ namespace Volo.Abp.GlobalFeatures public virtual void DisableAll() { - foreach (var feature in Features.Values) + foreach (var feature in AllFeatures.Values) { feature.Disable(); } } + + protected void AddFeature(string featureName) + { + AddFeature(new GlobalFeature(this, featureName)); + } + + protected void AddFeature(GlobalFeature feature) + { + AllFeatures[feature.FeatureName] = feature; + } + + protected GlobalFeature GetFeature(string featureName) + { + return AllFeatures[featureName]; + } + + protected TFeature GetFeature(string featureName) + where TFeature : GlobalFeature + { + return (TFeature) AllFeatures[featureName]; + } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs index 9449ef702c..76b3df92d5 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs @@ -1,30 +1,31 @@ using System; +using System.Collections.Generic; using JetBrains.Annotations; +using Volo.CmsKit.GlobalFeatures; namespace Volo.Abp.GlobalFeatures { public static class GlobalFeatureManagerModuleConfiguratorCmsKitExtensions { - public static GlobalFeatureManagerCmsKitConfigurator CmsKit( - [NotNull] this GlobalFeatureManagerModulesConfigurator modulesConfigurator) + public static GlobalCmsKitFeatures CmsKit( + [NotNull] this GlobalFeatureManagerModuleDictionary modules) { - Check.NotNull(modulesConfigurator, nameof(modulesConfigurator)); + Check.NotNull(modules, nameof(modules)); - return modulesConfigurator - .Modules - .GetOrAdd("CmsKit", _ => new GlobalFeatureManagerCmsKitConfigurator(modulesConfigurator)) - as GlobalFeatureManagerCmsKitConfigurator; + return modules + .GetOrAdd(GlobalCmsKitFeatures.ModuleName, _ => new GlobalCmsKitFeatures(modules.FeatureManager)) + as GlobalCmsKitFeatures; } - public static GlobalFeatureManagerModulesConfigurator CmsKit( - [NotNull] this GlobalFeatureManagerModulesConfigurator modulesConfigurator, - [NotNull] Action configureAction) + public static GlobalFeatureManagerModuleDictionary CmsKit( + [NotNull] this GlobalFeatureManagerModuleDictionary modules, + [NotNull] Action configureAction) { Check.NotNull(configureAction, nameof(configureAction)); - configureAction(modulesConfigurator.CmsKit()); + configureAction(modules.CmsKit()); - return modulesConfigurator; + return modules; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModulesConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModulesConfigurator.cs index acaa13beab..d48dfee4f8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModulesConfigurator.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModulesConfigurator.cs @@ -1,19 +1,16 @@ -using System.Collections.Concurrent; +using System.Collections.Generic; using JetBrains.Annotations; namespace Volo.Abp.GlobalFeatures { - public class GlobalFeatureManagerModulesConfigurator //TODO: Change to GlobalFeatureManagerModuleDictionary and inherit from ConcurrentDictionary + public class GlobalFeatureManagerModuleDictionary : Dictionary { public GlobalFeatureManager FeatureManager { get; } - [NotNull] - public ConcurrentDictionary Modules { get; } - - public GlobalFeatureManagerModulesConfigurator([NotNull] GlobalFeatureManager featureManager) + public GlobalFeatureManagerModuleDictionary( + [NotNull] GlobalFeatureManager featureManager) { FeatureManager = Check.NotNull(featureManager, nameof(featureManager)); - Modules = new ConcurrentDictionary(); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureNameAttribute.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureNameAttribute.cs new file mode 100644 index 0000000000..b5468096d3 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureNameAttribute.cs @@ -0,0 +1,40 @@ +using System; +using System.Linq; +using System.Reflection; +using JetBrains.Annotations; + +namespace Volo.Abp.GlobalFeatures +{ + [AttributeUsage(AttributeTargets.Class)] + public class GlobalFeatureNameAttribute : Attribute + { + public string Name { get; } + + public GlobalFeatureNameAttribute([NotNull] string name) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name)); + } + + public static string GetName() + where TFeature : GlobalFeature + { + return GetName(typeof(TFeature)); + } + + public static string GetName(Type type) + { + var attribute = type + .GetCustomAttributes() + .FirstOrDefault(); + + if (attribute == null) + { + throw new AbpException($"{type.AssemblyQualifiedName} should define the {typeof(GlobalFeatureNameAttribute).FullName} atttribute!"); + } + + return attribute + .As() + .Name; + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs index 468222df8f..0afe98f7c9 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs @@ -16,16 +16,14 @@ namespace Volo.CmsKit { public override void ConfigureServices(ServiceConfigurationContext context) { - GlobalFeatureManager.Instance.Modules().CmsKit().EnableAll(); - GlobalFeatureManager.Instance.Modules().CmsKit().DisableAll(); - GlobalFeatureManager.Instance.Modules().CmsKit().Reactions().Enable(); - GlobalFeatureManager.Instance.Modules().CmsKit(cmsKit => + GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll(); + GlobalFeatureManager.Instance.Modules.CmsKit().DisableAll(); + GlobalFeatureManager.Instance.Modules.CmsKit().Reactions.Enable(); + GlobalFeatureManager.Instance.Modules.CmsKit().Reactions.Enable(); + GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit => { - cmsKit.Reactions().Disable(); - cmsKit.Reactions(reactions => - { - reactions.Enable(); - }); + cmsKit.Reactions.Disable(); + cmsKit.Comments.Enable(); }); GlobalFeatureManager.Instance.IsEnabled("asd"); diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs new file mode 100644 index 0000000000..63cafd6744 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs @@ -0,0 +1,17 @@ +using JetBrains.Annotations; +using Volo.Abp.GlobalFeatures; + +namespace Volo.CmsKit.GlobalFeatures +{ + [GlobalFeatureName(Name)] + public class CommentsFeature : GlobalFeature + { + public const string Name = "CmsKit.Comments"; + + public CommentsFeature( + [NotNull] GlobalCmsKitFeatures cmsKit + ) : base(cmsKit, Name) + { + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs new file mode 100644 index 0000000000..7fb1638e2d --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs @@ -0,0 +1,20 @@ +using Volo.Abp.GlobalFeatures; + +namespace Volo.CmsKit.GlobalFeatures +{ + public class GlobalCmsKitFeatures : GlobalModuleFeatures + { + public const string ModuleName = "CmsKit"; + + public ReactionsFeature Reactions => GetFeature(ReactionsFeature.Name); + + public CommentsFeature Comments => GetFeature(CommentsFeature.Name); + + public GlobalCmsKitFeatures(GlobalFeatureManager featureManager) + : base(featureManager) + { + AddFeature(new ReactionsFeature(this)); + AddFeature(new CommentsFeature(this)); + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs new file mode 100644 index 0000000000..ec658fd8ca --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs @@ -0,0 +1,17 @@ +using JetBrains.Annotations; +using Volo.Abp.GlobalFeatures; + +namespace Volo.CmsKit.GlobalFeatures +{ + [GlobalFeatureName(Name)] + public class ReactionsFeature : GlobalFeature + { + public const string Name = "CmsKit.Reactions"; + + public ReactionsFeature( + [NotNull] GlobalCmsKitFeatures cmsKit + ) : base(cmsKit, Name) + { + } + } +} 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 d16d11c40a..d1fcaf8211 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 @@ -7,6 +7,7 @@ using Volo.CmsKit.Comments; using Volo.CmsKit.Reactions; using Volo.CmsKit.Users; using Volo.Abp.Users.EntityFrameworkCore; +using Volo.CmsKit.GlobalFeatures; namespace Volo.CmsKit.EntityFrameworkCore { @@ -33,7 +34,7 @@ namespace Volo.CmsKit.EntityFrameworkCore b.ConfigureAbpUser(); }); - if (GlobalFeatureManager.Instance.Modules().CmsKit().Reactions().IsEnabled) + if (GlobalFeatureManager.Instance.IsEnabled()) { builder.Entity(b => { @@ -50,7 +51,7 @@ namespace Volo.CmsKit.EntityFrameworkCore }); } - if (GlobalFeatureManager.Instance.Modules().CmsKit().Comments().IsEnabled) + if (GlobalFeatureManager.Instance.IsEnabled()) { builder.Entity(b => { diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs index 9ceaa348d0..a6da60876c 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs @@ -19,7 +19,7 @@ namespace Volo.CmsKit { public override void ConfigureServices(ServiceConfigurationContext context) { - GlobalFeatureManager.Instance.Modules().CmsKit().EnableAll(); + GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll(); context.Services.AddAlwaysAllowAuthorization(); } From fcaefac06e0da3cc300b45dad141f2c7fb0607e0 Mon Sep 17 00:00:00 2001 From: wakuflair Date: Fri, 14 Aug 2020 18:02:07 +0800 Subject: [PATCH 029/190] Add `MyProjectNameMenus.cs` for the app template --- .../Menus/MyProjectNameMenuContributor.cs | 2 +- .../Menus/MyProjectNameMenus.cs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs index 9e1f3a835c..e772db8972 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs @@ -28,7 +28,7 @@ namespace MyCompanyName.MyProjectName.Web.Menus var l = context.GetLocalizer(); - context.Menu.Items.Insert(0, new ApplicationMenuItem("MyProjectName.Home", l["Menu:Home"], "~/")); + context.Menu.Items.Insert(0, new ApplicationMenuItem(MyProjectNameMenus.Home, l["Menu:Home"], "~/")); } } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs new file mode 100644 index 0000000000..d4563554b4 --- /dev/null +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs @@ -0,0 +1,11 @@ +namespace MyCompanyName.MyProjectName.Web.Menus +{ + public class MyProjectNameMenus + { + private const string Prefix = "MyProjectName"; + public const string Home = Prefix + ".Home"; + + //Add your menu items here... + + } +} \ No newline at end of file From 6a24a0de3004c3eae1c2d38b37397702235afc97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 14 Aug 2020 14:26:19 +0300 Subject: [PATCH 030/190] Make GlobalFeature abstract. --- .../{GlobalFeatureConfigurator.cs => GlobalFeature.cs} | 10 ++++------ .../GlobalFeatureManagerModuleConfigurator.cs | 5 ----- .../Volo/CmsKit/CmsKitDomainSharedModule.cs | 4 +++- .../Volo/CmsKit/GlobalFeatures/CommentsFeature.cs | 2 +- .../Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) rename modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/{GlobalFeatureConfigurator.cs => GlobalFeature.cs} (77%) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs similarity index 77% rename from modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfigurator.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs index fb259d7df6..f0c113b1bf 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfigurator.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs @@ -2,7 +2,7 @@ namespace Volo.Abp.GlobalFeatures { - public class GlobalFeature + public abstract class GlobalFeature { [NotNull] public GlobalModuleFeatures Module { get; } @@ -18,13 +18,11 @@ namespace Volo.Abp.GlobalFeatures set => FeatureManager.SetEnabled(FeatureName, value); } - public GlobalFeature( - [NotNull] GlobalModuleFeatures module, - [NotNull] string name) + protected GlobalFeature([NotNull] GlobalModuleFeatures module) { Module = Check.NotNull(module, nameof(module)); - FeatureName = Check.NotNullOrWhiteSpace(name, nameof(name)); FeatureManager = Module.FeatureManager; + FeatureName = GlobalFeatureNameAttribute.GetName(GetType()); } public virtual void Enable() @@ -39,7 +37,7 @@ namespace Volo.Abp.GlobalFeatures public virtual void SetEnabled(bool isEnabled) { - + FeatureManager.SetEnabled(FeatureName, isEnabled); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs index edd1c7f0aa..64692071e0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs @@ -33,11 +33,6 @@ namespace Volo.Abp.GlobalFeatures } } - protected void AddFeature(string featureName) - { - AddFeature(new GlobalFeature(this, featureName)); - } - protected void AddFeature(GlobalFeature feature) { AllFeatures[feature.FeatureName] = feature; diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs index 0afe98f7c9..f624f65957 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs @@ -6,6 +6,7 @@ using Volo.Abp.Localization.ExceptionHandling; using Volo.Abp.Validation; using Volo.Abp.Validation.Localization; using Volo.Abp.VirtualFileSystem; +using Volo.CmsKit.GlobalFeatures; namespace Volo.CmsKit { @@ -26,7 +27,8 @@ namespace Volo.CmsKit cmsKit.Comments.Enable(); }); - GlobalFeatureManager.Instance.IsEnabled("asd"); + GlobalFeatureManager.Instance.IsEnabled("qweasd"); + GlobalFeatureManager.Instance.IsEnabled(); Configure(options => { diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs index 63cafd6744..fb1c3fa9cb 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs @@ -10,7 +10,7 @@ namespace Volo.CmsKit.GlobalFeatures public CommentsFeature( [NotNull] GlobalCmsKitFeatures cmsKit - ) : base(cmsKit, Name) + ) : base(cmsKit) { } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs index ec658fd8ca..6c978e88e6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs @@ -10,7 +10,7 @@ namespace Volo.CmsKit.GlobalFeatures public ReactionsFeature( [NotNull] GlobalCmsKitFeatures cmsKit - ) : base(cmsKit, Name) + ) : base(cmsKit) { } } From c3770076b056861d11f922c620b8930e03abf6b8 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Fri, 14 Aug 2020 14:30:19 +0300 Subject: [PATCH 031/190] feat(core): add ngxsStoragePluginOptions property to CoreModule forRoot options resolves #4839 --- .../packages/core/src/lib/core.module.ts | 20 +++++++++++++++++-- .../packages/core/src/lib/models/common.ts | 2 ++ .../core/src/lib/tokens/options.token.ts | 9 +++------ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/core.module.ts b/npm/ng-packs/packages/core/src/lib/core.module.ts index 85cf87297f..9daa34901b 100644 --- a/npm/ng-packs/packages/core/src/lib/core.module.ts +++ b/npm/ng-packs/packages/core/src/lib/core.module.ts @@ -4,7 +4,11 @@ import { APP_INITIALIZER, Injector, ModuleWithProviders, NgModule } from '@angul import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; import { NgxsRouterPluginModule } from '@ngxs/router-plugin'; -import { NgxsStoragePluginModule } from '@ngxs/storage-plugin'; +import { + NgxsStoragePluginModule, + NGXS_STORAGE_PLUGIN_OPTIONS, + StorageOption, +} from '@ngxs/storage-plugin'; import { NgxsModule, NGXS_PLUGINS } from '@ngxs/store'; import { OAuthModule, OAuthStorage } from 'angular-oauth2-oidc'; import { AbstractNgModelComponent } from './abstracts/ng-model.component'; @@ -118,7 +122,7 @@ export class BaseCoreModule {} LocalizationModule, NgxsModule.forFeature([ReplaceableComponentsState, ProfileState, SessionState, ConfigState]), NgxsRouterPluginModule.forRoot(), - NgxsStoragePluginModule.forRoot({ key: ['SessionState'] }), + NgxsStoragePluginModule.forRoot(), OAuthModule.forRoot(), ], }) @@ -216,6 +220,18 @@ export class CoreModule { useFactory: noop, }, { provide: OAuthStorage, useFactory: storageFactory }, + { + provide: NGXS_STORAGE_PLUGIN_OPTIONS, + useValue: { + storage: StorageOption.LocalStorage, + serialize: JSON.stringify, + deserialize: JSON.parse, + beforeSerialize: obj => obj, + afterDeserialize: obj => obj, + ...options.ngxsStoragePluginOptions, + key: [...(options.ngxsStoragePluginOptions?.key || []), 'SessionState'], + }, + }, ], }; } diff --git a/npm/ng-packs/packages/core/src/lib/models/common.ts b/npm/ng-packs/packages/core/src/lib/models/common.ts index 85b1138002..b01aed1f26 100644 --- a/npm/ng-packs/packages/core/src/lib/models/common.ts +++ b/npm/ng-packs/packages/core/src/lib/models/common.ts @@ -3,6 +3,7 @@ import { Router } from '@angular/router'; import { Subject } from 'rxjs'; import { eLayoutType } from '../enums/common'; import { Config } from './config'; +import { NgxsStoragePluginOptions } from '@ngxs/storage-plugin'; export namespace ABP { export interface Root { @@ -10,6 +11,7 @@ export namespace ABP { skipGetAppConfiguration?: boolean; sendNullsAsQueryParam?: boolean; cultureNameLocaleFileMap?: Dictionary; + ngxsStoragePluginOptions?: NgxsStoragePluginOptions & { key?: string[] }; } export interface Test { diff --git a/npm/ng-packs/packages/core/src/lib/tokens/options.token.ts b/npm/ng-packs/packages/core/src/lib/tokens/options.token.ts index 4cbb13da76..ac51dbb92e 100644 --- a/npm/ng-packs/packages/core/src/lib/tokens/options.token.ts +++ b/npm/ng-packs/packages/core/src/lib/tokens/options.token.ts @@ -1,15 +1,12 @@ import { InjectionToken } from '@angular/core'; -import { ABP } from '../models/common'; import differentLocales from '../constants/different-locales'; +import { ABP } from '../models/common'; export const CORE_OPTIONS = new InjectionToken('CORE_OPTIONS'); -export function coreOptionsFactory({ - cultureNameLocaleFileMap: localeNameMap = {}, - ...options -}: ABP.Root) { +export function coreOptionsFactory({ cultureNameLocaleFileMap = {}, ...options }: ABP.Root) { return { ...options, - cultureNameLocaleFileMap: { ...differentLocales, ...localeNameMap }, + cultureNameLocaleFileMap: { ...differentLocales, ...cultureNameLocaleFileMap }, } as ABP.Root; } From a8ee1de2a56791ce185b58efa5f06b5300b8a615 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Fri, 14 Aug 2020 14:32:24 +0300 Subject: [PATCH 032/190] feat: handle error on OAuthService loading discovery document request --- .../packages/core/src/lib/strategies/auth-flow.strategy.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts index b7aa5601e2..0e86deda69 100644 --- a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts +++ b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts @@ -12,6 +12,7 @@ import { GetAppConfiguration } from '../actions/config.actions'; export abstract class AuthFlowStrategy { abstract readonly isInternalAuth: boolean; + protected store: Store; protected oAuthService: OAuthService; protected oAuthConfig: AuthConfig; abstract checkIfInternalAuth(): boolean; @@ -20,12 +21,13 @@ export abstract class AuthFlowStrategy { abstract destroy(): void; private catchError = err => { - // TODO: handle the error + return this.store.dispatch(new RestOccurError(err)); }; constructor(protected injector: Injector) { this.oAuthService = injector.get(OAuthService); this.oAuthConfig = injector.get(CORE_OPTIONS).environment.oAuthConfig; + this.store = injector.get(Store); } async init(): Promise { From dfecca309a5812ec656ec9c7e59895563fe46fcf Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Fri, 14 Aug 2020 14:32:57 +0300 Subject: [PATCH 033/190] fix: get core options from the config state in auth-flow.strategy --- .../core/src/lib/strategies/auth-flow.strategy.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts index 0e86deda69..9ee2279ec7 100644 --- a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts +++ b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts @@ -1,13 +1,13 @@ import { Injector } from '@angular/core'; +import { Router } from '@angular/router'; import { Store } from '@ngxs/store'; import { AuthConfig, OAuthService } from 'angular-oauth2-oidc'; -import { ConfigState } from '../states/config.state'; -import { CORE_OPTIONS } from '../tokens/options.token'; -import { Router } from '@angular/router'; import { Observable, of } from 'rxjs'; -import { RestService } from '../services/rest.service'; import { switchMap } from 'rxjs/operators'; import { GetAppConfiguration } from '../actions/config.actions'; +import { RestOccurError } from '../actions/rest.actions'; +import { RestService } from '../services/rest.service'; +import { ConfigState } from '../states/config.state'; export abstract class AuthFlowStrategy { abstract readonly isInternalAuth: boolean; @@ -26,8 +26,8 @@ export abstract class AuthFlowStrategy { constructor(protected injector: Injector) { this.oAuthService = injector.get(OAuthService); - this.oAuthConfig = injector.get(CORE_OPTIONS).environment.oAuthConfig; this.store = injector.get(Store); + this.oAuthConfig = this.store.selectSnapshot(ConfigState.getDeep('environment.oAuthConfig')); } async init(): Promise { @@ -76,10 +76,9 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy { } logout() { - const store = this.injector.get(Store); const rest = this.injector.get(RestService); - const issuer = store.selectSnapshot(ConfigState.getDeep('environment.oAuthConfig.issuer')); + const issuer = this.store.selectSnapshot(ConfigState.getDeep('environment.oAuthConfig.issuer')); return rest .request( { @@ -92,7 +91,7 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy { .pipe( switchMap(() => { this.oAuthService.logOut(); - return store.dispatch(new GetAppConfiguration()); + return this.store.dispatch(new GetAppConfiguration()); }), ); } From 8467024d5411098d61e348150a9d2c3a312007a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 14 Aug 2020 14:33:15 +0300 Subject: [PATCH 034/190] refactor the global feature system --- .../Volo/Abp/GlobalFeatures/GlobalFeature.cs | 1 + .../Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs | 3 +++ .../GlobalFeatureManagerModuleConfigurator.cs | 12 ++++++------ .../Abp/GlobalFeatures/GlobalFeatureNameAttribute.cs | 2 ++ .../Volo/CmsKit/GlobalFeatures/CommentsFeature.cs | 2 +- ...CmsKitConfigurator.cs => GlobalCmsKitFeatures.cs} | 10 +++++----- .../Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs | 2 +- 7 files changed, 19 insertions(+), 13 deletions(-) rename modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/{GlobalFeatureManagerCmsKitConfigurator.cs => GlobalCmsKitFeatures.cs} (72%) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs index f0c113b1bf..11fb6961ed 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs @@ -10,6 +10,7 @@ namespace Volo.Abp.GlobalFeatures [NotNull] public GlobalFeatureManager FeatureManager { get; } + [NotNull] public string FeatureName { get; } public bool IsEnabled diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs index 7819f985de..80a5fcfae0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs @@ -8,6 +8,9 @@ namespace Volo.Abp.GlobalFeatures { public static GlobalFeatureManager Instance { get; protected set; } = new GlobalFeatureManager(); + /// + /// A common dictionary to store arbitrary configurations. + /// [NotNull] public Dictionary Configuration { get; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs index 64692071e0..fc870da152 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs @@ -5,16 +5,16 @@ namespace Volo.Abp.GlobalFeatures public abstract class GlobalModuleFeatures { [NotNull] - public GlobalFeatureConfiguratorDictionary AllFeatures { get; } + public GlobalFeatureManager FeatureManager { get; } [NotNull] - public GlobalFeatureManager FeatureManager { get; } + protected GlobalFeatureConfiguratorDictionary AllFeatures { get; } protected GlobalModuleFeatures( - GlobalFeatureManager featureManager) + [NotNull] GlobalFeatureManager featureManager) { + FeatureManager = Check.NotNull(featureManager, nameof(featureManager)); AllFeatures = new GlobalFeatureConfiguratorDictionary(); - FeatureManager = featureManager; } public virtual void EnableAll() @@ -43,10 +43,10 @@ namespace Volo.Abp.GlobalFeatures return AllFeatures[featureName]; } - protected TFeature GetFeature(string featureName) + protected TFeature GetFeature() where TFeature : GlobalFeature { - return (TFeature) AllFeatures[featureName]; + return (TFeature) GetFeature(GlobalFeatureNameAttribute.GetName()); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureNameAttribute.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureNameAttribute.cs index b5468096d3..295c8727e6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureNameAttribute.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureNameAttribute.cs @@ -8,6 +8,7 @@ namespace Volo.Abp.GlobalFeatures [AttributeUsage(AttributeTargets.Class)] public class GlobalFeatureNameAttribute : Attribute { + [NotNull] public string Name { get; } public GlobalFeatureNameAttribute([NotNull] string name) @@ -21,6 +22,7 @@ namespace Volo.Abp.GlobalFeatures return GetName(typeof(TFeature)); } + [NotNull] public static string GetName(Type type) { var attribute = type diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs index fb1c3fa9cb..c9615c51d4 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs @@ -8,7 +8,7 @@ namespace Volo.CmsKit.GlobalFeatures { public const string Name = "CmsKit.Comments"; - public CommentsFeature( + internal CommentsFeature( [NotNull] GlobalCmsKitFeatures cmsKit ) : base(cmsKit) { diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs similarity index 72% rename from modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs index 7fb1638e2d..dcdef4e8c2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalFeatureManagerCmsKitConfigurator.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs @@ -1,4 +1,5 @@ -using Volo.Abp.GlobalFeatures; +using JetBrains.Annotations; +using Volo.Abp.GlobalFeatures; namespace Volo.CmsKit.GlobalFeatures { @@ -6,11 +7,10 @@ namespace Volo.CmsKit.GlobalFeatures { public const string ModuleName = "CmsKit"; - public ReactionsFeature Reactions => GetFeature(ReactionsFeature.Name); + public ReactionsFeature Reactions => GetFeature(); + public CommentsFeature Comments => GetFeature(); - public CommentsFeature Comments => GetFeature(CommentsFeature.Name); - - public GlobalCmsKitFeatures(GlobalFeatureManager featureManager) + public GlobalCmsKitFeatures([NotNull] GlobalFeatureManager featureManager) : base(featureManager) { AddFeature(new ReactionsFeature(this)); diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs index 6c978e88e6..ad9a60b64d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/ReactionsFeature.cs @@ -8,7 +8,7 @@ namespace Volo.CmsKit.GlobalFeatures { public const string Name = "CmsKit.Reactions"; - public ReactionsFeature( + internal ReactionsFeature( [NotNull] GlobalCmsKitFeatures cmsKit ) : base(cmsKit) { From 04734ec96056f15c6fd85dd0c98259bbe98084a1 Mon Sep 17 00:00:00 2001 From: olicooper Date: Fri, 14 Aug 2020 12:37:07 +0100 Subject: [PATCH 035/190] Fixed OAuth configuration bug when using remoteEnv Relates to https://github.com/abpframework/abp/pull/4967 When using `remoteEnv`, OAuth was being configured with the default `environment.ts` settings rather than the one loaded from the `remoteEnv`. This should fix the problem. bug originally mentioned here: https://github.com/abpframework/abp/pull/4967#issuecomment-673464718 --- .../packages/core/src/lib/strategies/auth-flow.strategy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts index b7aa5601e2..6b8fe91253 100644 --- a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts +++ b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts @@ -25,7 +25,7 @@ export abstract class AuthFlowStrategy { constructor(protected injector: Injector) { this.oAuthService = injector.get(OAuthService); - this.oAuthConfig = injector.get(CORE_OPTIONS).environment.oAuthConfig; + this.oAuthConfig = injector.get(Store).selectSnapshot(ConfigState.getDeep('environment.oAuthConfig')); } async init(): Promise { From da0d4718ff32e14b4fc40ce067181bc21f75575a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 14 Aug 2020 14:46:32 +0300 Subject: [PATCH 036/190] Revise the global features. --- .../Volo/Abp/GlobalFeatures/GlobalFeature.cs | 13 ++++-- ...ctionary.cs => GlobalFeatureDictionary.cs} | 2 +- .../GlobalFeatures/GlobalFeatureManager.cs | 41 +++---------------- ...nagerModuleConfiguratorCmsKitExtensions.cs | 16 ++++---- ...onfigurator.cs => GlobalModuleFeatures.cs} | 4 +- ...r.cs => GlobalModuleFeaturesDictionary.cs} | 4 +- .../CmsKit/GlobalFeatures/CommentsFeature.cs | 1 + 7 files changed, 29 insertions(+), 52 deletions(-) rename modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/{GlobalFeatureConfiguratorDictionary.cs => GlobalFeatureDictionary.cs} (50%) rename modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/{GlobalFeatureManagerModuleConfigurator.cs => GlobalModuleFeatures.cs} (89%) rename modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/{GlobalFeatureManagerModulesConfigurator.cs => GlobalModuleFeaturesDictionary.cs} (69%) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs index 11fb6961ed..de9ae0232a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeature.cs @@ -16,7 +16,7 @@ namespace Volo.Abp.GlobalFeatures public bool IsEnabled { get => FeatureManager.IsEnabled(FeatureName); - set => FeatureManager.SetEnabled(FeatureName, value); + set => SetEnabled(value); } protected GlobalFeature([NotNull] GlobalModuleFeatures module) @@ -36,9 +36,16 @@ namespace Volo.Abp.GlobalFeatures FeatureManager.Disable(FeatureName); } - public virtual void SetEnabled(bool isEnabled) + public void SetEnabled(bool isEnabled) { - FeatureManager.SetEnabled(FeatureName, isEnabled); + if (isEnabled) + { + Enable(); + } + else + { + Disable(); + } } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfiguratorDictionary.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureDictionary.cs similarity index 50% rename from modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfiguratorDictionary.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureDictionary.cs index 72114eff3d..c8f68a1ab0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureConfiguratorDictionary.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureDictionary.cs @@ -2,7 +2,7 @@ namespace Volo.Abp.GlobalFeatures { - public class GlobalFeatureConfiguratorDictionary : Dictionary + public class GlobalFeatureDictionary : Dictionary { } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs index 80a5fcfae0..456aa74a07 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManager.cs @@ -1,5 +1,4 @@ -using System.Collections.Concurrent; -using System.Collections.Generic; +using System.Collections.Generic; using JetBrains.Annotations; namespace Volo.Abp.GlobalFeatures @@ -14,7 +13,7 @@ namespace Volo.Abp.GlobalFeatures [NotNull] public Dictionary Configuration { get; } - public GlobalFeatureManagerModuleDictionary Modules { get; } + public GlobalModuleFeaturesDictionary Modules { get; } protected HashSet EnabledFeatures { get; } @@ -22,7 +21,7 @@ namespace Volo.Abp.GlobalFeatures { EnabledFeatures = new HashSet(); Configuration = new Dictionary(); - Modules = new GlobalFeatureManagerModuleDictionary(this); + Modules = new GlobalModuleFeaturesDictionary(this); } public virtual bool IsEnabled() @@ -31,47 +30,17 @@ namespace Volo.Abp.GlobalFeatures return IsEnabled(GlobalFeatureNameAttribute.GetName()); } - public virtual void SetEnabled(bool isEnabled) - where TFeature : GlobalFeature - { - SetEnabled(GlobalFeatureNameAttribute.GetName(), isEnabled); - } - - public virtual void Enable() - where TFeature : GlobalFeature - { - Enable(GlobalFeatureNameAttribute.GetName()); - } - - public virtual void Disable() - where TFeature : GlobalFeature - { - Disable(GlobalFeatureNameAttribute.GetName()); - } - public virtual bool IsEnabled(string featureName) { return EnabledFeatures.Contains(featureName); } - public virtual void SetEnabled(string featureName, bool isEnabled) - { - if (isEnabled) - { - Enable(featureName); - } - else - { - Disable(featureName); - } - } - - public virtual void Enable(string featureName) + protected internal void Enable(string featureName) { EnabledFeatures.AddIfNotContains(featureName); } - public virtual void Disable(string featureName) + protected internal void Disable(string featureName) { EnabledFeatures.Remove(featureName); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs index 76b3df92d5..eb8d4acbb3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs @@ -8,24 +8,24 @@ namespace Volo.Abp.GlobalFeatures public static class GlobalFeatureManagerModuleConfiguratorCmsKitExtensions { public static GlobalCmsKitFeatures CmsKit( - [NotNull] this GlobalFeatureManagerModuleDictionary modules) + [NotNull] this GlobalModuleFeaturesDictionary modulesFeatures) { - Check.NotNull(modules, nameof(modules)); + Check.NotNull(modulesFeatures, nameof(modulesFeatures)); - return modules - .GetOrAdd(GlobalCmsKitFeatures.ModuleName, _ => new GlobalCmsKitFeatures(modules.FeatureManager)) + return modulesFeatures + .GetOrAdd(GlobalCmsKitFeatures.ModuleName, _ => new GlobalCmsKitFeatures(modulesFeatures.FeatureManager)) as GlobalCmsKitFeatures; } - public static GlobalFeatureManagerModuleDictionary CmsKit( - [NotNull] this GlobalFeatureManagerModuleDictionary modules, + public static GlobalModuleFeaturesDictionary CmsKit( + [NotNull] this GlobalModuleFeaturesDictionary modulesFeatures, [NotNull] Action configureAction) { Check.NotNull(configureAction, nameof(configureAction)); - configureAction(modules.CmsKit()); + configureAction(modulesFeatures.CmsKit()); - return modules; + return modulesFeatures; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeatures.cs similarity index 89% rename from modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeatures.cs index fc870da152..2b3721d331 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfigurator.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeatures.cs @@ -8,13 +8,13 @@ namespace Volo.Abp.GlobalFeatures public GlobalFeatureManager FeatureManager { get; } [NotNull] - protected GlobalFeatureConfiguratorDictionary AllFeatures { get; } + protected GlobalFeatureDictionary AllFeatures { get; } protected GlobalModuleFeatures( [NotNull] GlobalFeatureManager featureManager) { FeatureManager = Check.NotNull(featureManager, nameof(featureManager)); - AllFeatures = new GlobalFeatureConfiguratorDictionary(); + AllFeatures = new GlobalFeatureDictionary(); } public virtual void EnableAll() diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModulesConfigurator.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeaturesDictionary.cs similarity index 69% rename from modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModulesConfigurator.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeaturesDictionary.cs index d48dfee4f8..9952b0c5cc 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModulesConfigurator.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeaturesDictionary.cs @@ -3,11 +3,11 @@ using JetBrains.Annotations; namespace Volo.Abp.GlobalFeatures { - public class GlobalFeatureManagerModuleDictionary : Dictionary + public class GlobalModuleFeaturesDictionary : Dictionary { public GlobalFeatureManager FeatureManager { get; } - public GlobalFeatureManagerModuleDictionary( + public GlobalModuleFeaturesDictionary( [NotNull] GlobalFeatureManager featureManager) { FeatureManager = Check.NotNull(featureManager, nameof(featureManager)); diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs index c9615c51d4..a812bd5388 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/CommentsFeature.cs @@ -12,6 +12,7 @@ namespace Volo.CmsKit.GlobalFeatures [NotNull] GlobalCmsKitFeatures cmsKit ) : base(cmsKit) { + } } } From 092093f8bb0350912201dc5d5efb124fbb93fb2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 14 Aug 2020 14:51:15 +0300 Subject: [PATCH 037/190] Update GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs --- ...ManagerModuleConfiguratorCmsKitExtensions.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs index eb8d4acbb3..e73c91e8b2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs @@ -8,24 +8,27 @@ namespace Volo.Abp.GlobalFeatures public static class GlobalFeatureManagerModuleConfiguratorCmsKitExtensions { public static GlobalCmsKitFeatures CmsKit( - [NotNull] this GlobalModuleFeaturesDictionary modulesFeatures) + [NotNull] this GlobalModuleFeaturesDictionary modules) { - Check.NotNull(modulesFeatures, nameof(modulesFeatures)); + Check.NotNull(modules, nameof(modules)); - return modulesFeatures - .GetOrAdd(GlobalCmsKitFeatures.ModuleName, _ => new GlobalCmsKitFeatures(modulesFeatures.FeatureManager)) + return modules + .GetOrAdd( + GlobalCmsKitFeatures.ModuleName, + _ => new GlobalCmsKitFeatures(modules.FeatureManager) + ) as GlobalCmsKitFeatures; } public static GlobalModuleFeaturesDictionary CmsKit( - [NotNull] this GlobalModuleFeaturesDictionary modulesFeatures, + [NotNull] this GlobalModuleFeaturesDictionary modules, [NotNull] Action configureAction) { Check.NotNull(configureAction, nameof(configureAction)); - configureAction(modulesFeatures.CmsKit()); + configureAction(modules.CmsKit()); - return modulesFeatures; + return modules; } } } From 838289552ec38ab17dafc69935285a0045ff9fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 14 Aug 2020 14:59:14 +0300 Subject: [PATCH 038/190] Use OneTimeRunner and clear the test code. --- .../FeatureConfigurer.cs | 8 +++++++- ...ModuleFeaturesDictionaryCmsKitExtensions.cs} | 2 +- .../Volo/CmsKit/CmsKitDomainSharedModule.cs | 17 +---------------- .../GlobalFeatures/GlobalCmsKitFeatures.cs | 1 + .../CmsKitTestBaseModule.cs | 7 ++++++- 5 files changed, 16 insertions(+), 19 deletions(-) rename modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/{GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs => GlobalModuleFeaturesDictionaryCmsKitExtensions.cs} (92%) diff --git a/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs index d600e99cd9..9046c60aca 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs @@ -1,12 +1,18 @@ using Volo.Abp.GlobalFeatures; +using Volo.Abp.Threading; namespace Volo.CmsKit { public static class FeatureConfigurer { + private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); + public static void Configure() { - GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll(); + OneTimeRunner.Run(() => + { + GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll(); + }); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeaturesDictionaryCmsKitExtensions.cs similarity index 92% rename from modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs rename to modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeaturesDictionaryCmsKitExtensions.cs index e73c91e8b2..72701d5e4d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalFeatureManagerModuleConfiguratorCmsKitExtensions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/Abp/GlobalFeatures/GlobalModuleFeaturesDictionaryCmsKitExtensions.cs @@ -5,7 +5,7 @@ using Volo.CmsKit.GlobalFeatures; namespace Volo.Abp.GlobalFeatures { - public static class GlobalFeatureManagerModuleConfiguratorCmsKitExtensions + public static class GlobalModuleFeaturesDictionaryCmsKitExtensions { public static GlobalCmsKitFeatures CmsKit( [NotNull] this GlobalModuleFeaturesDictionary modules) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs index f624f65957..925acdaf79 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitDomainSharedModule.cs @@ -1,12 +1,10 @@ -using Volo.Abp.GlobalFeatures; -using Volo.Abp.Modularity; +using Volo.Abp.Modularity; using Volo.Abp.Localization; using Volo.CmsKit.Localization; using Volo.Abp.Localization.ExceptionHandling; using Volo.Abp.Validation; using Volo.Abp.Validation.Localization; using Volo.Abp.VirtualFileSystem; -using Volo.CmsKit.GlobalFeatures; namespace Volo.CmsKit { @@ -17,19 +15,6 @@ namespace Volo.CmsKit { public override void ConfigureServices(ServiceConfigurationContext context) { - GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll(); - GlobalFeatureManager.Instance.Modules.CmsKit().DisableAll(); - GlobalFeatureManager.Instance.Modules.CmsKit().Reactions.Enable(); - GlobalFeatureManager.Instance.Modules.CmsKit().Reactions.Enable(); - GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit => - { - cmsKit.Reactions.Disable(); - cmsKit.Comments.Enable(); - }); - - GlobalFeatureManager.Instance.IsEnabled("qweasd"); - GlobalFeatureManager.Instance.IsEnabled(); - Configure(options => { options.FileSets.AddEmbedded(); diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs index dcdef4e8c2..646a91ef4f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures/GlobalCmsKitFeatures.cs @@ -8,6 +8,7 @@ namespace Volo.CmsKit.GlobalFeatures public const string ModuleName = "CmsKit"; public ReactionsFeature Reactions => GetFeature(); + public CommentsFeature Comments => GetFeature(); public GlobalCmsKitFeatures([NotNull] GlobalFeatureManager featureManager) diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs index a6da60876c..8e5049f55e 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs @@ -17,9 +17,14 @@ namespace Volo.CmsKit )] public class CmsKitTestBaseModule : AbpModule { + private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); + public override void ConfigureServices(ServiceConfigurationContext context) { - GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll(); + OneTimeRunner.Run(() => + { + GlobalFeatureManager.Instance.Modules.CmsKit().EnableAll(); + }); context.Services.AddAlwaysAllowAuthorization(); } From 82ecc9cf8d9bdd98579c3f907d51023a1e90ab62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 14 Aug 2020 15:01:56 +0300 Subject: [PATCH 039/190] Add Collection to the mongodb tests --- .../MongoDB/Comments/CommentRepository_Tests.cs | 2 ++ .../MongoDB/Reactions/UserReactionRepository_Tests.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Comments/CommentRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Comments/CommentRepository_Tests.cs index cf2e936ca8..06a8007683 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Comments/CommentRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Comments/CommentRepository_Tests.cs @@ -1,7 +1,9 @@ using Volo.CmsKit.Comments; +using Xunit; namespace Volo.CmsKit.MongoDB.Comments { + [Collection(MongoTestCollection.Name)] public class CommentRepository_Tests : CommentRepository_Tests { diff --git a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Reactions/UserReactionRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Reactions/UserReactionRepository_Tests.cs index 452ee211c5..16740a5803 100644 --- a/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Reactions/UserReactionRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Reactions/UserReactionRepository_Tests.cs @@ -1,7 +1,9 @@ using Volo.CmsKit.Reactions; +using Xunit; namespace Volo.CmsKit.MongoDB.Reactions { + [Collection(MongoTestCollection.Name)] public class UserReactionRepository_Tests : UserReactionRepository_Tests { } From 4bfba3a04b1735319f72338221e0efc402f2c1e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levent=20Arman=20=C3=96zak?= Date: Fri, 14 Aug 2020 15:17:13 +0300 Subject: [PATCH 040/190] Update grid-actions.component.html --- .../src/lib/components/grid-actions/grid-actions.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/grid-actions/grid-actions.component.html b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/grid-actions/grid-actions.component.html index 3985faf229..fdf6c19e8b 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/grid-actions/grid-actions.component.html +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/grid-actions/grid-actions.component.html @@ -1,4 +1,4 @@ -
+