add option to Control Panel to specify module visibility
This commit is contained in:
parent
e2688e6feb
commit
07718f0449
|
@ -628,7 +628,7 @@
|
||||||
foreach (Alias alias in _aliases)
|
foreach (Alias alias in _aliases)
|
||||||
{
|
{
|
||||||
_urls += (_urls == string.Empty) ? alias.Name.Trim() : ", " + alias.Name.Trim();
|
_urls += (_urls == string.Empty) ? alias.Name.Trim() : ", " + alias.Name.Trim();
|
||||||
if (alias.IsDefault) _defaultalias = alias.Name.Trim();
|
if (alias.IsDefault && string.IsNullOrEmpty(_defaultalias)) _defaultalias = alias.Name.Trim();
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(_defaultalias)) _defaultalias = _aliases.First().Name.Trim();
|
if (string.IsNullOrEmpty(_defaultalias)) _defaultalias = _aliases.First().Name.Trim();
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,4 +177,13 @@
|
||||||
<data name="System.Update" xml:space="preserve">
|
<data name="System.Update" xml:space="preserve">
|
||||||
<value>Check For System Updates</value>
|
<value>Check For System Updates</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Visibility" xml:space="preserve">
|
||||||
|
<value>Visibility:</value>
|
||||||
|
</data>
|
||||||
|
<data name="VisibilityEdit" xml:space="preserve">
|
||||||
|
<value>Page Editors Only</value>
|
||||||
|
</data>
|
||||||
|
<data name="VisibilityView" xml:space="preserve">
|
||||||
|
<value>Same As Page</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -46,178 +46,178 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="@BodyClass">
|
<div class="@BodyClass">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
||||||
{
|
{
|
||||||
<div class="row d-flex">
|
<div class="row d-flex">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<button type="button" data-bs-dismiss="offcanvas" class="btn btn-primary col-12" @onclick=@(async () => Navigate("Admin"))>@Localizer["AdminDash"]</button>
|
<button type="button" data-bs-dismiss="offcanvas" class="btn btn-primary col-12" @onclick=@(async () => Navigate("Admin"))>@Localizer["AdminDash"]</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr class="app-rule" />
|
<hr class="app-rule" />
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col text-center">
|
<div class="col text-center">
|
||||||
<label class="control-label">@Localizer["Page.Manage"] </label>
|
<label class="control-label">@Localizer["Page.Manage"] </label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row d-flex mb-2">
|
||||||
<div class="row d-flex">
|
<div class="col d-flex justify-content-between">
|
||||||
<div class="col d-flex justify-content-between">
|
<button type="button" class="btn btn-secondary col me-1" data-bs-dismiss="offcanvas" @onclick=@(async () => Navigate("Add"))>@SharedLocalizer["Add"]</button>
|
||||||
<button type="button" class="btn btn-secondary col me-1" data-bs-dismiss="offcanvas" @onclick=@(async () => Navigate("Add"))>@SharedLocalizer["Add"]</button>
|
<button type="button" class="btn btn-secondary col" data-bs-dismiss="offcanvas" @onclick=@(async () => Navigate("Edit"))>@SharedLocalizer["Edit"]</button>
|
||||||
<button type="button" class="btn btn-secondary col" data-bs-dismiss="offcanvas" @onclick=@(async () => Navigate("Edit"))>@SharedLocalizer["Edit"]</button>
|
<button type="button" class="btn btn-danger col ms-1" @onclick="ConfirmDelete">@SharedLocalizer["Delete"]</button>
|
||||||
<button type="button" class="btn btn-danger col ms-1" @onclick="ConfirmDelete">@SharedLocalizer["Delete"]</button>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row d-flex">
|
||||||
<br />
|
<div class="col">
|
||||||
<div class="row d-flex">
|
@if (UserSecurity.GetPermissionStrings(PageState.Page.Permissions).FirstOrDefault(item => item.PermissionName == PermissionNames.View).Permissions.Split(';').Contains(RoleNames.Everyone))
|
||||||
<div class="col">
|
{
|
||||||
@if (UserSecurity.GetPermissionStrings(PageState.Page.Permissions).FirstOrDefault(item => item.PermissionName == PermissionNames.View).Permissions.Split(';').Contains(RoleNames.Everyone))
|
<button type="button" class="btn btn-secondary col-12" @onclick=@(async () => Publish("unpublish"))>@Localizer["Page.Unpublish"]</button>
|
||||||
{
|
}
|
||||||
<button type="button" class="btn btn-secondary col-12" @onclick=@(async () => Publish("unpublish"))>@Localizer["Page.Unpublish"]</button>
|
else
|
||||||
}
|
{
|
||||||
else
|
<button type="button" class="btn btn-secondary col-12" @onclick=@(async () => Publish("publish"))>@Localizer["Page.Publish"]</button>
|
||||||
{
|
}
|
||||||
<button type="button" class="btn btn-secondary col-12" @onclick=@(async () => Publish("publish"))>@Localizer["Page.Publish"]</button>
|
</div>
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@if (_deleteConfirmation)
|
@if (_deleteConfirmation)
|
||||||
{
|
{
|
||||||
<div class="app-admin-modal">
|
<div class="app-admin-modal">
|
||||||
<div class="modal" tabindex="-1" role="dialog">
|
<div class="modal" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">@Localizer["Page.Delete"]</h5>
|
<h5 class="modal-title">@Localizer["Page.Delete"]</h5>
|
||||||
<button type="button" class="btn-close" aria-label="Close" @onclick="ConfirmDelete"></button>
|
<button type="button" class="btn-close" aria-label="Close" @onclick="ConfirmDelete"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>Are You Sure You Want To Delete This Page?</p>
|
<p>Are You Sure You Want To Delete This Page?</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-danger" @onclick="DeletePage">@SharedLocalizer["Delete"]</button>
|
<button type="button" class="btn btn-danger" @onclick="DeletePage">@SharedLocalizer["Delete"]</button>
|
||||||
<button type="button" class="btn btn-secondary" @onclick="ConfirmDelete">@SharedLocalizer["Cancel"]</button>
|
<button type="button" class="btn btn-secondary" @onclick="ConfirmDelete">@SharedLocalizer["Cancel"]</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
}
|
||||||
}
|
<hr class="app-rule" />
|
||||||
<hr class="app-rule" />
|
<div class="row">
|
||||||
<div class="row">
|
<div class="col text-center">
|
||||||
<div class="col text-center">
|
<label for="Module" class="control-label">@Localizer["Module.Manage"] </label>
|
||||||
<label for="Module" class="control-label">@Localizer["Module.Manage"] </label>
|
<select class="form-select" @bind="@ModuleType">
|
||||||
<select class="form-select" @bind="@ModuleType">
|
<option value="new">@Localizer["Module.AddNew"]</option>
|
||||||
<option value="new">@Localizer["Module.AddNew"]</option>
|
<option value="existing">@Localizer["Module.AddExisting"]</option>
|
||||||
<option value="existing">@Localizer["Module.AddExisting"]</option>
|
</select>
|
||||||
</select>
|
@if (ModuleType == "new")
|
||||||
@if (ModuleType == "new")
|
|
||||||
{
|
|
||||||
@if (_moduleDefinitions != null)
|
|
||||||
{
|
{
|
||||||
<select class="form-select" @onchange="(e => CategoryChanged(e))">
|
@if (_moduleDefinitions != null)
|
||||||
@foreach (var category in _categories)
|
{
|
||||||
{
|
<select class="form-select" @onchange="(e => CategoryChanged(e))">
|
||||||
if (category == Category)
|
@foreach (var category in _categories)
|
||||||
{
|
{
|
||||||
<option value="@category" selected>@category @Localizer["Modules"]</option>
|
if (category == Category)
|
||||||
|
{
|
||||||
|
<option value="@category" selected>@category @Localizer["Modules"]</option>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<option value="@category">@category @Localizer["Modules"]</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
<select class="form-select" @onchange="(e => ModuleChanged(e))">
|
||||||
|
@if (ModuleDefinitionName == "-")
|
||||||
|
{
|
||||||
|
<option value="-" selected><@Localizer["Module.Select"]></option>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<option value="@category">@category @Localizer["Modules"]</option>
|
<option value="-"><@Localizer["Module.Select"]></option>
|
||||||
}
|
}
|
||||||
}
|
@foreach (var moduledefinition in _moduleDefinitions)
|
||||||
</select>
|
|
||||||
<select class="form-select" @onchange="(e => ModuleChanged(e))">
|
|
||||||
@if (ModuleDefinitionName == "-")
|
|
||||||
{
|
|
||||||
<option value="-" selected><@Localizer["Module.Select"]></option>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<option value="-"><@Localizer["Module.Select"]></option>
|
|
||||||
}
|
|
||||||
@foreach (var moduledefinition in _moduleDefinitions)
|
|
||||||
{
|
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Utilize, moduledefinition.Permissions))
|
|
||||||
{
|
{
|
||||||
if (moduledefinition.Runtimes == "" || moduledefinition.Runtimes.Contains(PageState.Runtime.ToString()))
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Utilize, moduledefinition.Permissions))
|
||||||
{
|
{
|
||||||
<option value="@moduledefinition.ModuleDefinitionName">@moduledefinition.Name</option>
|
if (moduledefinition.Runtimes == "" || moduledefinition.Runtimes.Contains(PageState.Runtime.ToString()))
|
||||||
|
{
|
||||||
|
<option value="@moduledefinition.ModuleDefinitionName">@moduledefinition.Name</option>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
</select>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<select class="form-select" @onchange="(e => PageChanged(e))">
|
||||||
|
<option value="-"><@Localizer["Page.Select"]></option>
|
||||||
|
@foreach (Page p in _pages)
|
||||||
|
{
|
||||||
|
<option value="@p.PageId">@p.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
<select class="form-select" @bind="@ModuleId">
|
||||||
|
<option value="-"><@Localizer["Module.Select"]></option>
|
||||||
|
@foreach (Module module in _modules)
|
||||||
|
{
|
||||||
|
<option value="@module.ModuleId">@module.Title</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
@((MarkupString) Description)
|
|
||||||
}
|
}
|
||||||
}
|
</div>
|
||||||
else
|
|
||||||
{
|
|
||||||
<select class="form-select" @onchange="(e => PageChanged(e))">
|
|
||||||
<option value="-"><@Localizer["Page.Select"]></option>
|
|
||||||
@foreach (Page p in _pages)
|
|
||||||
{
|
|
||||||
<option value="@p.PageId">@p.Name</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
<select class="form-select" @bind="@ModuleId">
|
|
||||||
<option value="-"><@Localizer["Module.Select"]></option>
|
|
||||||
@foreach (Module module in _modules)
|
|
||||||
{
|
|
||||||
<option value="@module.ModuleId">@module.Title</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col text-center">
|
|
||||||
<label for="Title" class="control-label">@Localizer["Title"] </label>
|
|
||||||
<input type="text" name="Title" class="form-control" @bind="@Title" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@if (_pane.Length > 1)
|
|
||||||
{
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col text-center">
|
<div class="col text-center">
|
||||||
<label for="Pane" class="control-label">@Localizer["Pane"] </label>
|
<label for="Title" class="control-label">@Localizer["Title"] </label>
|
||||||
<select class="form-select" @bind="@Pane">
|
<input type="text" name="Title" class="form-control" @bind="@Title" />
|
||||||
@foreach (string pane in PageState.Page.Panes)
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (_pane.Length > 1)
|
||||||
|
{
|
||||||
|
<div class="row">
|
||||||
|
<div class="col text-center">
|
||||||
|
<label for="Pane" class="control-label">@Localizer["Pane"] </label>
|
||||||
|
<select class="form-select" @bind="@Pane">
|
||||||
|
@foreach (string pane in PageState.Page.Panes)
|
||||||
|
{
|
||||||
|
<option value="@pane">@pane Pane</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col text-center">
|
||||||
|
<label for="Container" class="control-label">@Localizer["Container"] </label>
|
||||||
|
<select class="form-select" @bind="@ContainerType">
|
||||||
|
@foreach (var container in _containers)
|
||||||
{
|
{
|
||||||
<option value="@pane">@pane Pane</option>
|
<option value="@container.TypeName">@container.Name</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
<div class="row">
|
||||||
<div class="row">
|
<div class="col text-center">
|
||||||
<div class="col text-center">
|
<label for="visibility" class="control-label">@Localizer["Visibility"]</label>
|
||||||
<label for="Container" class="control-label">@Localizer["Container"] </label>
|
<select class="form-select" @bind="@Visibility">
|
||||||
<select class="form-select" @bind="@ContainerType">
|
<option value="edit" selected>@Localizer["VisibilityEdit"]</option>
|
||||||
@foreach (var container in _containers)
|
<option value="view">@Localizer["VisibilityView"]</option>
|
||||||
{
|
</select>
|
||||||
<option value="@container.TypeName">@container.Name</option>
|
</div>
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<button type="button" class="btn btn-success col-12 mt-4" @onclick="@AddModule">@Localizer["Page.Module.Add"]</button>
|
||||||
<br />
|
@((MarkupString) Message)
|
||||||
<button type="button" class="btn btn-primary col-12" @onclick="@AddModule">@Localizer["Page.Module.Add"]</button>
|
|
||||||
@((MarkupString) Message)
|
|
||||||
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
|
||||||
{
|
|
||||||
<hr class="app-rule" />
|
|
||||||
<NavLink class="btn btn-info col-12" data-bs-dismiss="offcanvas" href="@NavigateUrl("admin/update")">@Localizer["System.Update"]</NavLink>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code{
|
@code{
|
||||||
|
|
||||||
private bool _deleteConfirmation = false;
|
private bool _deleteConfirmation = false;
|
||||||
private List<string> _categories = new List<string>();
|
private List<string> _categories = new List<string>();
|
||||||
private List<ModuleDefinition> _allModuleDefinitions;
|
private List<ModuleDefinition> _allModuleDefinitions;
|
||||||
|
@ -242,7 +242,7 @@
|
||||||
_category = value;
|
_category = value;
|
||||||
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(Category)).ToList();
|
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(Category)).ToList();
|
||||||
ModuleDefinitionName = "-";
|
ModuleDefinitionName = "-";
|
||||||
Description = "";
|
Message = "";
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
_ = UpdateSettingsAsync();
|
_ = UpdateSettingsAsync();
|
||||||
}
|
}
|
||||||
|
@ -262,11 +262,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected string Description { get; private set; } = "";
|
|
||||||
|
|
||||||
protected string Title { get; private set; } = "";
|
protected string Title { get; private set; } = "";
|
||||||
protected string ContainerType { get; private set; } = "";
|
protected string ContainerType { get; private set; } = "";
|
||||||
|
protected string Visibility { get; private set; } = "edit";
|
||||||
protected string Message { get; private set; } = "";
|
protected string Message { get; private set; } = "";
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
|
@ -320,13 +318,12 @@
|
||||||
if (ModuleDefinitionName != "-")
|
if (ModuleDefinitionName != "-")
|
||||||
{
|
{
|
||||||
var moduleDefinition = _moduleDefinitions.FirstOrDefault(item => item.ModuleDefinitionName == ModuleDefinitionName);
|
var moduleDefinition = _moduleDefinitions.FirstOrDefault(item => item.ModuleDefinitionName == ModuleDefinitionName);
|
||||||
Description = "<br /><div class=\"alert alert-info\" role=\"alert\">" + moduleDefinition.Description + "</div>";
|
Message = "<div class=\"alert alert-info mt-2 text-center\" role=\"alert\">" + moduleDefinition.Description + "</div>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Description = "";
|
Message = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,9 +356,17 @@
|
||||||
module.ModuleDefinitionName = ModuleDefinitionName;
|
module.ModuleDefinitionName = ModuleDefinitionName;
|
||||||
module.AllPages = false;
|
module.AllPages = false;
|
||||||
|
|
||||||
// set module view permissions to page edit permissions
|
|
||||||
List<PermissionString> permissions = UserSecurity.GetPermissionStrings(PageState.Page.Permissions);
|
List<PermissionString> permissions = UserSecurity.GetPermissionStrings(PageState.Page.Permissions);
|
||||||
permissions.Find(p => p.PermissionName == PermissionNames.View).Permissions = permissions.Find(p => p.PermissionName == PermissionNames.Edit).Permissions;
|
if (Visibility == "view")
|
||||||
|
{
|
||||||
|
// set module view permissions to page view permissions
|
||||||
|
permissions.Find(p => p.PermissionName == PermissionNames.View).Permissions = permissions.Find(p => p.PermissionName == PermissionNames.View).Permissions;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// set module view permissions to page edit permissions
|
||||||
|
permissions.Find(p => p.PermissionName == PermissionNames.View).Permissions = permissions.Find(p => p.PermissionName == PermissionNames.Edit).Permissions;
|
||||||
|
}
|
||||||
module.Permissions = UserSecurity.SetPermissionStrings(permissions);
|
module.Permissions = UserSecurity.SetPermissionStrings(permissions);
|
||||||
|
|
||||||
module = await ModuleService.AddModuleAsync(module);
|
module = await ModuleService.AddModuleAsync(module);
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Oqtane.Migrations.Master
|
||||||
//Add Column to Alias table
|
//Add Column to Alias table
|
||||||
var aliasEntityBuilder = new AliasEntityBuilder(migrationBuilder, ActiveDatabase);
|
var aliasEntityBuilder = new AliasEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||||
aliasEntityBuilder.AddBooleanColumn("IsDefault", true);
|
aliasEntityBuilder.AddBooleanColumn("IsDefault", true);
|
||||||
aliasEntityBuilder.UpdateColumn("IsDefault", "0", "bool", "");
|
aliasEntityBuilder.UpdateColumn("IsDefault", "1", "bool", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user