Skip to content

Commit

Permalink
Merge pull request #438 from GregFinzer/feature/protectedDirectories
Browse files Browse the repository at this point in the history
Protected Directories
  • Loading branch information
GregFinzer authored Jan 10, 2025
2 parents e037b53 + dac8dd8 commit a5e9467
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
25 changes: 17 additions & 8 deletions BedBrigade.Client/Components/MediaManager.razor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BedBrigade.Common.Models;
using BedBrigade.Data.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.JSInterop;
Expand All @@ -8,6 +9,7 @@ namespace BedBrigade.Client.Components
public partial class MediaManager : ComponentBase
{
[Inject] private IJSRuntime JS { get; set; }
[Inject] private ILocationDataService LocationDataService { get; set; }
private int _currentId = 1;

private List<FolderItem> Folders = new List<FolderItem>();
Expand All @@ -24,7 +26,7 @@ public partial class MediaManager : ComponentBase
private string CutSourceFolder = string.Empty;
private string CopySourceFolder = string.Empty;
private bool ShowCopyPasteButton => CutOrCopyFiles.Any() && CopySourceFolder != CurrentFolderPath && CutSourceFolder != CurrentFolderPath;

private List<string> _protectedFolders = new List<string>();

[Parameter]
public string RootFolder { get; set; } = string.Empty;
Expand Down Expand Up @@ -58,24 +60,31 @@ private string DisplayPath
get { return _mediaFolderPath + @CurrentFolderPath.Replace(RootFolder, ""); }
}

protected override void OnInitialized()
protected override async Task OnInitializedAsync()
{
CommonInit();
await CommonInit();
}

protected override void OnParametersSet()
protected override async Task OnParametersSetAsync()
{
CommonInit();
await CommonInit();
}

private void CommonInit()
private async Task CommonInit()
{
if (!String.IsNullOrEmpty(RootFolder))
{
CurrentFolderPath = RootFolder;
_mediaFolderPath = GetMediaFolderPath();
RefreshFolders();
RefreshFiles(RootFolder);
var locationResult = await LocationDataService.GetAllAsync();
if (locationResult.Success)
{
_protectedFolders = locationResult.Data.Select(l => l.Route.TrimStart('/')).ToList();
_protectedFolders.Add(MediaFolderName);
_protectedFolders.Add("pages");
}
}
}

Expand Down Expand Up @@ -264,10 +273,10 @@ private async Task DeleteFolder()
{
try
{
if (CurrentFolderPath == RootFolder)
if (_protectedFolders.Any(o => CurrentFolderPath.EndsWith("\\" + o)))
{
await MyModal.Show(Modal.ModalType.Alert, Modal.ModalIcon.Warning, ErrorTitle,
"The root folder cannot be deleted.");
"This is a protected folder and cannot be deleted.");
return;
}

Expand Down
Binary file modified Documentation/Design/Estimates.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion Documentation/Project Plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ One thing you will notice about the following project plan is the lack of due da
* Cache get files :heavy_check_mark:
* Remove Unused Components and Pages
* Add three image rotators to Bed Brigade Near Me :heavy_check_mark:
* FM Dependent Functionality
* Protected Directories
* Verify security for all pages
* Global Error Handler :heavy_check_mark:
* Refresh Header and Footer :heavy_check_mark:
Expand Down

0 comments on commit a5e9467

Please sign in to comment.