diff --git a/BedBrigade.Client/Components/MediaManager.razor.cs b/BedBrigade.Client/Components/MediaManager.razor.cs index f41051e6..b00052cd 100644 --- a/BedBrigade.Client/Components/MediaManager.razor.cs +++ b/BedBrigade.Client/Components/MediaManager.razor.cs @@ -1,4 +1,5 @@ using BedBrigade.Common.Models; +using BedBrigade.Data.Services; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; using Microsoft.JSInterop; @@ -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 Folders = new List(); @@ -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 _protectedFolders = new List(); [Parameter] public string RootFolder { get; set; } = string.Empty; @@ -58,17 +60,17 @@ 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)) { @@ -76,6 +78,13 @@ private void CommonInit() _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"); + } } } @@ -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; } diff --git a/Documentation/Design/Estimates.xlsx b/Documentation/Design/Estimates.xlsx index f3e613aa..57d512d4 100644 Binary files a/Documentation/Design/Estimates.xlsx and b/Documentation/Design/Estimates.xlsx differ diff --git a/Documentation/Project Plan.md b/Documentation/Project Plan.md index bd57047b..e1be435f 100644 --- a/Documentation/Project Plan.md +++ b/Documentation/Project Plan.md @@ -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: