diff --git a/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj b/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj index e042047563..2e4c93e8df 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj +++ b/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj @@ -14,10 +14,10 @@ - - - - + + + + diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DbContextFileBuilderConfigureAdder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DbContextFileBuilderConfigureAdder.cs index d369a9af43..3586f66956 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DbContextFileBuilderConfigureAdder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DbContextFileBuilderConfigureAdder.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Linq; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.DependencyInjection; @@ -22,26 +23,34 @@ namespace Volo.Abp.Cli.ProjectModification { var file = File.ReadAllText(path); - file = UsingStatementAdder.Add(file, GetNamespace(moduleConfiguration)); + var parsedModuleConfiguration = moduleConfiguration.Split(", "); - var stringToAdd = GetLineToAdd(moduleConfiguration); - if (!file.Contains(stringToAdd)) + var namespaces = parsedModuleConfiguration.Select(GetNamespace); + var configurationLines = parsedModuleConfiguration.Select(GetLineToAdd); + + var indexToInsert = FindIndexToInsert(file); + + if (indexToInsert <= 0 || indexToInsert >= file.Length) { - var indexToInsert = FindIndexToInsert(file); + Logger.LogWarning($"\"OnModelCreating(ModelBuilder builder)\" method couldn't be found in {path}"); + return false; + } - if (indexToInsert <= 0 || indexToInsert >= file.Length) + foreach (var configurationLine in configurationLines) + { + if (file.Contains(configurationLine)) { - Logger.LogWarning($"\"OnModelCreating(ModelBuilder builder)\" method couldn't be found in {path}"); - return false; + continue; } - file = file.Insert(indexToInsert, " " + stringToAdd + Environment.NewLine + " "); + + file = file.Insert(indexToInsert, " " + configurationLine + Environment.NewLine + " "); } - else + + foreach (var namespaceOfConfiguration in namespaces) { - return false; + file = UsingStatementAdder.Add(file, namespaceOfConfiguration); } - File.WriteAllText(path, file); return true; } @@ -49,7 +58,8 @@ namespace Volo.Abp.Cli.ProjectModification protected int FindIndexToInsert(string file) { var indexOfMethodDeclaration = file.IndexOf("OnModelCreating(", StringComparison.Ordinal); - var indexOfOpeningBracket = indexOfMethodDeclaration + file.Substring(indexOfMethodDeclaration).IndexOf('{'); + var indexOfOpeningBracket = + indexOfMethodDeclaration + file.Substring(indexOfMethodDeclaration).IndexOf('{'); var stack = 1; var index = indexOfOpeningBracket; diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/AppUrlProvider.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/AppUrlProvider.cs index c722529eca..8570ae9f6e 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/AppUrlProvider.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/AppUrlProvider.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using JetBrains.Annotations; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; using Volo.Abp.MultiTenancy; @@ -42,36 +43,24 @@ namespace Volo.Abp.UI.Navigation.Urls return Options.RedirectAllowedUrls.Any(url.StartsWith); } - protected virtual Task GetConfiguredUrl(string appName, string urlName) + protected virtual async Task GetConfiguredUrl(string appName, string urlName) { - var app = Options.Applications[appName]; - - if (urlName.IsNullOrEmpty()) + var url = await GetUrlOrNullAsync(appName, urlName); + if (!url.IsNullOrEmpty()) { - if (app.RootUrl.IsNullOrEmpty()) - { - throw new AbpException( - $"RootUrl for the application '{appName}' was not configured. Use {nameof(AppUrlOptions)} to configure it!" - ); - } - - return Task.FromResult(app.RootUrl); + return url; } - var url = app.Urls.GetOrDefault(urlName); - if (url.IsNullOrEmpty()) + if (!urlName.IsNullOrEmpty()) { throw new AbpException( $"Url, named '{urlName}', for the application '{appName}' was not configured. Use {nameof(AppUrlOptions)} to configure it!" ); } - if (app.RootUrl == null) - { - return Task.FromResult(url); - } - - return Task.FromResult(app.RootUrl.EnsureEndsWith('/') + url); + throw new AbpException( + $"RootUrl for the application '{appName}' was not configured. Use {nameof(AppUrlOptions)} to configure it!" + ); } protected virtual async Task ReplacePlaceHoldersAsync(string url) @@ -118,5 +107,24 @@ namespace Volo.Abp.UI.Navigation.Urls return CurrentTenant.Name; } + + public Task GetUrlOrNullAsync([NotNull] string appName, [CanBeNull] string urlName = null) + { + var app = Options.Applications[appName]; + + if (urlName.IsNullOrEmpty()) + { + return Task.FromResult(app.RootUrl); + } + + var url = app.Urls.GetOrDefault(urlName); + + if (app.RootUrl == null) + { + return Task.FromResult(url); + } + + return Task.FromResult(app.RootUrl.EnsureEndsWith('/') + url); + } } } diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/IAppUrlProvider.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/IAppUrlProvider.cs index 61b6fc2bac..3a67da538b 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/IAppUrlProvider.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/IAppUrlProvider.cs @@ -7,6 +7,8 @@ namespace Volo.Abp.UI.Navigation.Urls { Task GetUrlAsync([NotNull] string appName, [CanBeNull] string urlName = null); + Task GetUrlOrNullAsync([NotNull] string appName, [CanBeNull] string urlName = null); + bool IsRedirectAllowedUrl(string url); } } diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor index 0bddf36c98..9cd0164a02 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor @@ -48,7 +48,7 @@ @L["DisplayName:RoleName"] - + @@ -86,7 +86,7 @@ @L["DisplayName:RoleName"] - + diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor index 172d41c019..17d24c1d9b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor @@ -53,7 +53,7 @@ @L["DisplayName:UserName"] - + @@ -164,7 +164,7 @@ @L["DisplayName:UserName"] - + diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor index 65e6c3d87f..1662d8a961 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor @@ -47,7 +47,7 @@ @L["TenantName"] - + @@ -101,7 +101,7 @@ @L["TenantName"] - + diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyCompanyName.MyProjectName.Blazor.Server.Tiered.csproj b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyCompanyName.MyProjectName.Blazor.Server.Tiered.csproj index cd4877cbd4..cee2421b60 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyCompanyName.MyProjectName.Blazor.Server.Tiered.csproj +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyCompanyName.MyProjectName.Blazor.Server.Tiered.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyCompanyName.MyProjectName.Blazor.Server.csproj b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyCompanyName.MyProjectName.Blazor.Server.csproj index b514d70d25..67c05d7e6e 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyCompanyName.MyProjectName.Blazor.Server.csproj +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyCompanyName.MyProjectName.Blazor.Server.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj index d4898cb678..6d1a41da47 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj index c71d10e65a..22602422da 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj @@ -8,8 +8,8 @@ - - + +