added DefaultAction property to IModule (#765)

This commit is contained in:
Shaun Walker 2020-10-03 15:50:15 -04:00
parent 26c40fb367
commit 6a7be12758
4 changed files with 21 additions and 14 deletions

View File

@ -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);
}

View File

@ -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))

View File

@ -1,8 +1,8 @@
{
"Runtime": "Server",
"ConnectionStrings": {
"DefaultConnection": ""
},
"Runtime": "Server",
"Installation": {
"DefaultAlias": "",
"HostPassword": "",
@ -11,5 +11,9 @@
"DefaultTheme": "",
"DefaultLayout": "",
"DefaultContainer": ""
},
"Localization": {
"DefaultCulture": "",
"SupportedCultures": []
}
}

View File

@ -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]