Refactored IModule and ITheme interfaces for future compatibility scenarios. Added Permissions property to IModule interface to allow for explicit ordering and custom module permissions.
This commit is contained in:
@ -81,9 +81,7 @@
|
||||
[Parameter]
|
||||
public string Permissions { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string PermissionNames { get; set; } // optional - can be used to specify permissions order or add custom permissions
|
||||
|
||||
string permissionnames = "";
|
||||
List<Role> roles;
|
||||
List<PermissionString> permissions = new List<PermissionString>();
|
||||
List<User> users = new List<User>();
|
||||
@ -92,14 +90,15 @@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (string.IsNullOrEmpty(PermissionNames))
|
||||
permissionnames = PageState.ModuleDefinitions.Find(item => item.ModuleDefinitionName == ModuleState.ModuleDefinitionName).Permissions;
|
||||
if (string.IsNullOrEmpty(permissionnames))
|
||||
{
|
||||
PermissionNames = "View,Edit";
|
||||
permissionnames = "View,Edit";
|
||||
}
|
||||
roles = await RoleService.GetRolesAsync(ModuleState.SiteId);
|
||||
roles.Insert(0, new Role { Name = Constants.AllUsersRole });
|
||||
|
||||
foreach (string permissionname in PermissionNames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
foreach (string permissionname in permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
permissions.Add(new PermissionString { PermissionName = permissionname, Permissions = "" });
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
using Oqtane.Modules;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Client.Modules.Counter
|
||||
{
|
||||
public class Module : IModule
|
||||
{
|
||||
public string Name { get { return "Counter"; } }
|
||||
public string Description { get { return "Increments a counter"; } }
|
||||
public string Version { get { return "1.0.0"; } }
|
||||
public string Owner { get { return ""; } }
|
||||
public string Url { get { return ""; } }
|
||||
public string Contact { get { return ""; } }
|
||||
public string License { get { return ""; } }
|
||||
public string Dependencies { get { return ""; } }
|
||||
public Dictionary<string, string> Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<string, string> properties = new Dictionary<string, string>
|
||||
{
|
||||
{ "Name", "Counter" },
|
||||
{ "Description", "Increments a counter" },
|
||||
{ "Version", "1.0.0" }
|
||||
};
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
using Oqtane.Modules;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Client.Modules.HtmlText
|
||||
{
|
||||
public class Module : IModule
|
||||
{
|
||||
public string Name { get { return "HtmlText"; } }
|
||||
public string Description { get { return "Renders HTML or Text"; } }
|
||||
public string Version { get { return "1.0.0"; } }
|
||||
public string Owner { get { return ""; } }
|
||||
public string Url { get { return ""; } }
|
||||
public string Contact { get { return ""; } }
|
||||
public string License { get { return ""; } }
|
||||
public string Dependencies { get { return ""; } }
|
||||
public Dictionary<string, string> Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<string, string> properties = new Dictionary<string, string>
|
||||
{
|
||||
{ "Name", "HtmlText" },
|
||||
{ "Description", "Renders HTML or Text" },
|
||||
{ "Version", "1.0.0" }
|
||||
};
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,9 @@
|
||||
namespace Oqtane.Modules
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Modules
|
||||
{
|
||||
public interface IModule
|
||||
{
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
string Version { get; }
|
||||
string Owner { get; }
|
||||
string Url { get; }
|
||||
string Contact { get; }
|
||||
string License { get; }
|
||||
string Dependencies { get; }
|
||||
Dictionary<string, string> Properties { get; }
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,22 @@
|
||||
using Oqtane.Modules;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Client.Modules.Weather
|
||||
{
|
||||
public class Module : IModule
|
||||
{
|
||||
public string Name { get { return "Weather"; } }
|
||||
public string Description { get { return "Displays random weather using a service"; } }
|
||||
public string Version { get { return "1.0.0"; } }
|
||||
public string Owner { get { return ""; } }
|
||||
public string Url { get { return ""; } }
|
||||
public string Contact { get { return ""; } }
|
||||
public string License { get { return ""; } }
|
||||
public string Dependencies { get { return ""; } }
|
||||
public Dictionary<string, string> Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<string, string> properties = new Dictionary<string, string>
|
||||
{
|
||||
{ "Name", "Weather" },
|
||||
{ "Description", "Displays random weather using a service" },
|
||||
{ "Version", "1.0.0" }
|
||||
};
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Themes
|
||||
{
|
||||
public interface ITheme
|
||||
{
|
||||
string Name { get; }
|
||||
string Version { get; }
|
||||
string Owner { get; }
|
||||
string Url { get; }
|
||||
string Contact { get; }
|
||||
string License { get; }
|
||||
string Dependencies { get; }
|
||||
Dictionary<string, string> Properties { get; }
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,20 @@
|
||||
namespace Oqtane.Themes.Theme1
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Themes.Theme1
|
||||
{
|
||||
public class Theme : ITheme
|
||||
{
|
||||
public string Name { get { return "Theme1"; } }
|
||||
public string Version { get { return "1.0.0"; } }
|
||||
public string Owner { get { return ""; } }
|
||||
public string Url { get { return ""; } }
|
||||
public string Contact { get { return ""; } }
|
||||
public string License { get { return ""; } }
|
||||
public string Dependencies { get { return ""; } }
|
||||
public Dictionary<string, string> Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<string, string> properties = new Dictionary<string, string>
|
||||
{
|
||||
{ "Name", "Theme1" },
|
||||
{ "Version", "1.0.0" }
|
||||
};
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,20 @@
|
||||
namespace Oqtane.Themes.Theme2
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Themes.Theme2
|
||||
{
|
||||
public class Theme : ITheme
|
||||
{
|
||||
public string Name { get { return "Theme2"; } }
|
||||
public string Version { get { return "1.0.0"; } }
|
||||
public string Owner { get { return ""; } }
|
||||
public string Url { get { return ""; } }
|
||||
public string Contact { get { return ""; } }
|
||||
public string License { get { return ""; } }
|
||||
public string Dependencies { get { return ""; } }
|
||||
public Dictionary<string, string> Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<string, string> properties = new Dictionary<string, string>
|
||||
{
|
||||
{ "Name", "Theme2" },
|
||||
{ "Version", "1.0.0" }
|
||||
};
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,20 @@
|
||||
namespace Oqtane.Themes.Theme3
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Themes.Theme3
|
||||
{
|
||||
public class Theme : ITheme
|
||||
{
|
||||
public string Name { get { return "Theme3"; } }
|
||||
public string Version { get { return "1.0.0"; } }
|
||||
public string Owner { get { return ""; } }
|
||||
public string Url { get { return ""; } }
|
||||
public string Contact { get { return ""; } }
|
||||
public string License { get { return ""; } }
|
||||
public string Dependencies { get { return ""; } }
|
||||
public Dictionary<string, string> Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<string, string> properties = new Dictionary<string, string>
|
||||
{
|
||||
{ "Name", "Theme3" },
|
||||
{ "Version", "1.0.0" }
|
||||
};
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user