Ensure folder does not contain files during deletion and remove directory during deletion, fix validation issue in add page which would allow a user to create a page without selecting a layout, modify action dialog to use its own CSS class name so it can be styled independently from the Admin Modal, rollback "container" CSS class assigment on panes

This commit is contained in:
Shaun Walker 2020-08-26 15:00:07 -04:00
parent 6cc144d733
commit 760fc3b8d4
8 changed files with 50 additions and 11 deletions

View File

@ -1,6 +1,7 @@
@namespace Oqtane.Modules.Admin.Files @namespace Oqtane.Modules.Admin.Files
@inherits ModuleBase @inherits ModuleBase
@inject IFolderService FolderService @inject IFolderService FolderService
@inject IFileService FileService
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@if (_folders != null) @if (_folders != null)
@ -45,7 +46,7 @@
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@if (!_isSystem && PageState.QueryString.ContainsKey("id")) @if (!_isSystem && PageState.QueryString.ContainsKey("id"))
{ {
<button type="button" class="btn btn-danger" @onclick="DeleteFolder">Delete</button> <ActionDialog Header="Delete Folder" Message="@("Are You Sure You Wish To Delete This Folder?")" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteFolder())" />
} }
<br /> <br />
<br /> <br />
@ -193,13 +194,21 @@
} }
if (!isparent) if (!isparent)
{ {
await FolderService.DeleteFolderAsync(_folderId); var files = await FileService.GetFilesAsync(_folderId);
await logger.LogInformation("Folder Deleted {Folder}", _folderId); if (files.Count == 0)
NavigationManager.NavigateTo(NavigateUrl()); {
await FolderService.DeleteFolderAsync(_folderId);
await logger.LogInformation("Folder Deleted {Folder}", _folderId);
NavigationManager.NavigateTo(NavigateUrl());
}
else
{
AddModuleMessage("Folder Has Files And Cannot Be Deleted", MessageType.Warning);
}
} }
else else
{ {
AddModuleMessage("Folder Has Child Folders And Cannot Be Deleted", MessageType.Warning); AddModuleMessage("Folder Has Subfolders And Cannot Be Deleted", MessageType.Warning);
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -299,7 +299,7 @@
Page page = null; Page page = null;
try try
{ {
if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && (_layouts.Count == 0 || !string.IsNullOrEmpty(_layouttype))) if (_name != string.Empty && !string.IsNullOrEmpty(_themetype) && (_layouts.Count == 0 || _layouttype != "-"))
{ {
page = new Page(); page = new Page();
page.SiteId = PageState.Page.SiteId; page.SiteId = PageState.Page.SiteId;
@ -389,7 +389,7 @@
} }
else else
{ {
AddModuleMessage("You Must Provide Page Name And Theme", MessageType.Warning); AddModuleMessage("You Must Provide Page Name And Theme/Layout", MessageType.Warning);
} }
} }

View File

@ -448,7 +448,7 @@
} }
else else
{ {
AddModuleMessage("You Must Provide A Site Name, Alias, And Default Theme/Container", MessageType.Warning); AddModuleMessage("You Must Provide A Site Name, Alias, And Default Theme/Layout/Container", MessageType.Warning);
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -402,7 +402,7 @@ else
} }
else else
{ {
AddModuleMessage("You Must Provide A Tenant, Site Name, Alias, Default Theme/Container, And Site Template", MessageType.Warning); AddModuleMessage("You Must Provide A Tenant, Site Name, Alias, Default Theme/Layout/Container, And Site Template", MessageType.Warning);
} }
} }
} }

View File

@ -3,7 +3,7 @@
@if (_visible) @if (_visible)
{ {
<div class="app-admin-modal"> <div class="app-actiondialog">
<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">

View File

@ -33,7 +33,7 @@
} }
else else
{ {
_paneadminborder = "container"; _paneadminborder = "";
_panetitle = ""; _panetitle = "";
} }

View File

@ -214,6 +214,11 @@ namespace Oqtane.Controllers
{ {
if (_userPermissions.IsAuthorized(User, EntityNames.Folder, id, PermissionNames.Edit)) if (_userPermissions.IsAuthorized(User, EntityNames.Folder, id, PermissionNames.Edit))
{ {
Models.Folder _folder = _folders.GetFolder(id, false);
if (Directory.Exists(GetFolderPath(_folder)))
{
Directory.Delete(GetFolderPath(_folder));
}
_folders.DeleteFolder(id); _folders.DeleteFolder(id);
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Folder Deleted {FolderId}", id); _logger.Log(LogLevel.Information, this, LogFunction.Delete, "Folder Deleted {FolderId}", id);
} }

View File

@ -52,6 +52,31 @@ app {
width: 80%; /* Could be more or less, depending on screen size */ width: 80%; /* Could be more or less, depending on screen size */
} }
/* Action Dialog */
.app-actiondialog .modal {
position: fixed; /* Stay in place */
z-index: 9999; /* Sit on top */
left: 0;
top: 0;
display: block;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background: rgba(0,0,0,0.3); /* Dim background */
}
.app-actiondialog .modal-dialog {
width: 100%; /* Full width */
height: 100%; /* Full height */
max-width: none; /* Override default of 500px */
}
.app-actiondialog .modal-content {
margin: 15% auto; /* 15% from the top and centered */
width: 40%; /* Could be more or less, depending on screen size */
}
/* Admin Pane */
.app-pane-admin-border { .app-pane-admin-border {
width: 100%; width: 100%;
border-width: 1px; border-width: 1px;