From 6a7be12758204715d4dc0d3642223e72aa569585 Mon Sep 17 00:00:00 2001 From: Shaun Walker Date: Sat, 3 Oct 2020 15:50:15 -0400 Subject: [PATCH] added DefaultAction property to IModule (#765) --- Oqtane.Client/UI/Pane.razor | 8 ++++---- Oqtane.Client/UI/SiteRouter.razor | 18 +++++++++--------- Oqtane.Server/appsettings.release.json | 6 +++++- Oqtane.Shared/Models/ModuleDefinition.cs | 3 +++ 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Oqtane.Client/UI/Pane.razor b/Oqtane.Client/UI/Pane.razor index a3429cca..0c2c0f69 100644 --- a/Oqtane.Client/UI/Pane.razor +++ b/Oqtane.Client/UI/Pane.razor @@ -112,8 +112,8 @@ else Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId); if (module != null && module.Pane.ToLower() == Name.ToLower() && !module.IsDeleted) { - // check if user is authorized to view module - if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions)) + // check if user is authorized to view module + if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions)) { CreateComponent(builder, module); } @@ -123,8 +123,8 @@ else { foreach (Module module in PageState.Modules.Where(item => item.PageId == PageState.Page.PageId && item.Pane.ToLower() == Name.ToLower() && !item.IsDeleted).OrderBy(x => x.Order).ToArray()) { - // check if user is authorized to view module - if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions)) + // check if user is authorized to view module + if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.Permissions)) { CreateComponent(builder, module); } diff --git a/Oqtane.Client/UI/SiteRouter.razor b/Oqtane.Client/UI/SiteRouter.razor index a93661b7..b79ea29d 100644 --- a/Oqtane.Client/UI/SiteRouter.razor +++ b/Oqtane.Client/UI/SiteRouter.razor @@ -202,21 +202,15 @@ { modIdPos = i + 1; actionPos = modIdPos + 1; - // Route to index page if no action is specifed - if (actionPos > segments.Length - 1) - { - action = Constants.DefaultAction; - } - else + if (actionPos <= segments.Length - 1) { action = segments[actionPos]; - } } } - // check if path has moduleid and action specification ie. pagename/moduleid/action/ + // check if path has moduleid and action specification ie. pagename/*/moduleid/action/ if (modIdPos > 0) { int.TryParse(segments[modIdPos], out result); @@ -460,7 +454,13 @@ typename = Constants.ErrorModule; } - // check if the module defines custom routes*@ + // handle default action + if (action == Constants.DefaultAction && !string.IsNullOrEmpty(module.ModuleDefinition.DefaultAction)) + { + action = module.ModuleDefinition.DefaultAction; + } + + // check if the module defines custom action routes if (module.ModuleDefinition.ControlTypeRoutes != "") { foreach (string route in module.ModuleDefinition.ControlTypeRoutes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) diff --git a/Oqtane.Server/appsettings.release.json b/Oqtane.Server/appsettings.release.json index 4fe3a03a..1af87b4c 100644 --- a/Oqtane.Server/appsettings.release.json +++ b/Oqtane.Server/appsettings.release.json @@ -1,8 +1,8 @@ { - "Runtime": "Server", "ConnectionStrings": { "DefaultConnection": "" }, + "Runtime": "Server", "Installation": { "DefaultAlias": "", "HostPassword": "", @@ -11,5 +11,9 @@ "DefaultTheme": "", "DefaultLayout": "", "DefaultContainer": "" + }, + "Localization": { + "DefaultCulture": "", + "SupportedCultures": [] } } \ No newline at end of file diff --git a/Oqtane.Shared/Models/ModuleDefinition.cs b/Oqtane.Shared/Models/ModuleDefinition.cs index 1e66735f..0fd8b892 100644 --- a/Oqtane.Shared/Models/ModuleDefinition.cs +++ b/Oqtane.Shared/Models/ModuleDefinition.cs @@ -20,6 +20,7 @@ namespace Oqtane.Models ServerManagerType = ""; ControlTypeRoutes = ""; ReleaseVersions = ""; + DefaultAction = ""; Runtimes = ""; Template = ""; } @@ -57,6 +58,8 @@ namespace Oqtane.Models public string ControlTypeRoutes { get; set; } [NotMapped] public string ReleaseVersions { get; set; } + [NotMapped] + public string DefaultAction { get; set; } // internal properties [NotMapped]