Added file editor to the api. Made the entire file manager available to the interfaces.
This commit is contained in:
@@ -11,7 +11,7 @@ public class CreateFileAction : IFileManagerCreateAction
|
|||||||
public string Icon => "bx-file";
|
public string Icon => "bx-file";
|
||||||
public string Color => "primary";
|
public string Color => "primary";
|
||||||
|
|
||||||
public async Task Execute(BaseFileAccess access, FileView view, IServiceProvider provider)
|
public async Task Execute(BaseFileAccess access, UI.NewFileManager.FileManager fileManager, IServiceProvider provider)
|
||||||
{
|
{
|
||||||
var alertService = provider.GetRequiredService<AlertService>();
|
var alertService = provider.GetRequiredService<AlertService>();
|
||||||
|
|
||||||
@@ -22,16 +22,14 @@ public class CreateFileAction : IFileManagerCreateAction
|
|||||||
|
|
||||||
await access.CreateFile(name);
|
await access.CreateFile(name);
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
// We build a virtual entry here so we dont need to fetch one
|
// We build a virtual entry here so we dont need to fetch one
|
||||||
await OpenEditor(new()
|
await fileManager.OpenEditor(new()
|
||||||
{
|
{
|
||||||
Name = name,
|
Name = name,
|
||||||
Size = 0,
|
Size = 0,
|
||||||
IsFile = true,
|
IsFile = true,
|
||||||
IsDirectory = false,
|
IsDirectory = false,
|
||||||
LastModifiedAt = DateTime.UtcNow
|
LastModifiedAt = DateTime.UtcNow
|
||||||
});*/
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ public class CreateFolderAction : IFileManagerCreateAction
|
|||||||
public string Icon => "bx-folder";
|
public string Icon => "bx-folder";
|
||||||
public string Color => "primary";
|
public string Color => "primary";
|
||||||
|
|
||||||
public async Task Execute(BaseFileAccess access, FileView view, IServiceProvider provider)
|
public async Task Execute(BaseFileAccess access, UI.NewFileManager.FileManager fileManager, IServiceProvider provider)
|
||||||
{
|
{
|
||||||
var alertService = provider.GetRequiredService<AlertService>();
|
var alertService = provider.GetRequiredService<AlertService>();
|
||||||
var toastService = provider.GetRequiredService<ToastService>();
|
var toastService = provider.GetRequiredService<ToastService>();
|
||||||
@@ -24,6 +24,6 @@ public class CreateFolderAction : IFileManagerCreateAction
|
|||||||
await access.CreateDirectory(name);
|
await access.CreateDirectory(name);
|
||||||
|
|
||||||
await toastService.Success("Successfully created directory");
|
await toastService.Success("Successfully created directory");
|
||||||
await view.Refresh();
|
await fileManager.View.Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,11 +12,11 @@ public class DeleteContextAction : IFileManagerContextAction
|
|||||||
public string Color => "danger";
|
public string Color => "danger";
|
||||||
public Func<FileEntry, bool> Filter => _ => true;
|
public Func<FileEntry, bool> Filter => _ => true;
|
||||||
|
|
||||||
public async Task Execute(BaseFileAccess access, FileView view, FileEntry entry, IServiceProvider serviceProvider)
|
public async Task Execute(BaseFileAccess access, UI.NewFileManager.FileManager fileManager, FileEntry entry, IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
await access.Delete(entry);
|
await access.Delete(entry);
|
||||||
|
|
||||||
await view.Refresh();
|
await fileManager.View.Refresh();
|
||||||
|
|
||||||
var toastService = serviceProvider.GetRequiredService<ToastService>();
|
var toastService = serviceProvider.GetRequiredService<ToastService>();
|
||||||
await toastService.Success("Successfully deleted item");
|
await toastService.Success("Successfully deleted item");
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class DeleteSelectionAction : IFileManagerSelectionAction
|
|||||||
public string Name => "Delete";
|
public string Name => "Delete";
|
||||||
public string Color => "danger";
|
public string Color => "danger";
|
||||||
|
|
||||||
public async Task Execute(BaseFileAccess access, FileView view, FileEntry[] entries, IServiceProvider provider)
|
public async Task Execute(BaseFileAccess access, UI.NewFileManager.FileManager fileManager, FileEntry[] entries, IServiceProvider provider)
|
||||||
{
|
{
|
||||||
var alertService = provider.GetRequiredService<AlertService>();
|
var alertService = provider.GetRequiredService<AlertService>();
|
||||||
var toastService = provider.GetRequiredService<ToastService>();
|
var toastService = provider.GetRequiredService<ToastService>();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class DownloadContextAction : IFileManagerContextAction
|
|||||||
public string Color => "primary";
|
public string Color => "primary";
|
||||||
public Func<FileEntry, bool> Filter => entry => entry.IsFile;
|
public Func<FileEntry, bool> Filter => entry => entry.IsFile;
|
||||||
|
|
||||||
public async Task Execute(BaseFileAccess access, FileView view, FileEntry entry, IServiceProvider serviceProvider)
|
public async Task Execute(BaseFileAccess access, UI.NewFileManager.FileManager fileManager, FileEntry entry, IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
var fileAccessService = serviceProvider.GetRequiredService<SharedFileAccessService>();
|
var fileAccessService = serviceProvider.GetRequiredService<SharedFileAccessService>();
|
||||||
var navigation = serviceProvider.GetRequiredService<NavigationManager>();
|
var navigation = serviceProvider.GetRequiredService<NavigationManager>();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class RenameContextAction : IFileManagerContextAction
|
|||||||
public string Color => "info";
|
public string Color => "info";
|
||||||
public Func<FileEntry, bool> Filter => _ => true;
|
public Func<FileEntry, bool> Filter => _ => true;
|
||||||
|
|
||||||
public async Task Execute(BaseFileAccess access, FileView view, FileEntry entry, IServiceProvider provider)
|
public async Task Execute(BaseFileAccess access, UI.NewFileManager.FileManager fileManager, FileEntry entry, IServiceProvider provider)
|
||||||
{
|
{
|
||||||
var alertService = provider.GetRequiredService<AlertService>();
|
var alertService = provider.GetRequiredService<AlertService>();
|
||||||
var toastService = provider.GetRequiredService<ToastService>();
|
var toastService = provider.GetRequiredService<ToastService>();
|
||||||
@@ -24,7 +24,7 @@ public class RenameContextAction : IFileManagerContextAction
|
|||||||
|
|
||||||
await access.Rename(entry.Name, newName);
|
await access.Rename(entry.Name, newName);
|
||||||
|
|
||||||
await view.Refresh();
|
await fileManager.View.Refresh();
|
||||||
await toastService.Success("Successfully renamed file");
|
await toastService.Success("Successfully renamed file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,5 +10,5 @@ public interface IFileManagerContextAction
|
|||||||
public string Color { get; }
|
public string Color { get; }
|
||||||
public Func<FileEntry, bool> Filter { get; }
|
public Func<FileEntry, bool> Filter { get; }
|
||||||
|
|
||||||
public Task Execute(BaseFileAccess access, FileView view, FileEntry entry, IServiceProvider provider);
|
public Task Execute(BaseFileAccess access, UI.NewFileManager.FileManager fileManager, FileEntry entry, IServiceProvider provider);
|
||||||
}
|
}
|
||||||
@@ -9,5 +9,5 @@ public interface IFileManagerCreateAction
|
|||||||
public string Icon { get; }
|
public string Icon { get; }
|
||||||
public string Color { get; }
|
public string Color { get; }
|
||||||
|
|
||||||
public Task Execute(BaseFileAccess access, FileView view, IServiceProvider provider);
|
public Task Execute(BaseFileAccess access, UI.NewFileManager.FileManager fileManager, IServiceProvider provider);
|
||||||
}
|
}
|
||||||
@@ -8,5 +8,5 @@ public interface IFileManagerSelectionAction
|
|||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
public string Color { get; }
|
public string Color { get; }
|
||||||
|
|
||||||
public Task Execute(BaseFileAccess access, FileView view, FileEntry[] entries, IServiceProvider provider);
|
public Task Execute(BaseFileAccess access, UI.NewFileManager.FileManager fileManager, FileEntry[] entries, IServiceProvider provider);
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ else
|
|||||||
{
|
{
|
||||||
[Parameter] public BaseFileAccess FileAccess { get; set; }
|
[Parameter] public BaseFileAccess FileAccess { get; set; }
|
||||||
|
|
||||||
private FileView View;
|
public FileView View { get; private set; }
|
||||||
private string Path = "/";
|
private string Path = "/";
|
||||||
|
|
||||||
private IFileManagerContextAction[] ContextActions;
|
private IFileManagerContextAction[] ContextActions;
|
||||||
@@ -244,12 +244,12 @@ else
|
|||||||
{
|
{
|
||||||
await View.HideContextMenu();
|
await View.HideContextMenu();
|
||||||
|
|
||||||
await contextAction.Execute(FileAccess, View, entry, ServiceProvider);
|
await contextAction.Execute(FileAccess, this, entry, ServiceProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task InvokeSelectionAction(IFileManagerSelectionAction action)
|
private async Task InvokeSelectionAction(IFileManagerSelectionAction action)
|
||||||
{
|
{
|
||||||
await action.Execute(FileAccess, View, View.Selection, ServiceProvider);
|
await action.Execute(FileAccess, this, View.Selection, ServiceProvider);
|
||||||
|
|
||||||
// Refresh resets the selection
|
// Refresh resets the selection
|
||||||
await View.Refresh();
|
await View.Refresh();
|
||||||
@@ -257,7 +257,7 @@ else
|
|||||||
|
|
||||||
private async Task InvokeCreateAction(IFileManagerCreateAction action)
|
private async Task InvokeCreateAction(IFileManagerCreateAction action)
|
||||||
{
|
{
|
||||||
await action.Execute(FileAccess, View, ServiceProvider);
|
await action.Execute(FileAccess, this, ServiceProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnSelectionChanged(FileEntry[] _) => await InvokeAsync(StateHasChanged);
|
private async Task OnSelectionChanged(FileEntry[] _) => await InvokeAsync(StateHasChanged);
|
||||||
@@ -309,7 +309,7 @@ else
|
|||||||
|
|
||||||
#region File Editor
|
#region File Editor
|
||||||
|
|
||||||
private async Task OpenEditor(FileEntry entry)
|
public async Task OpenEditor(FileEntry entry)
|
||||||
{
|
{
|
||||||
FileToEdit = entry;
|
FileToEdit = entry;
|
||||||
ShowEditor = true;
|
ShowEditor = true;
|
||||||
@@ -317,7 +317,7 @@ else
|
|||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CloseEditor()
|
public async Task CloseEditor()
|
||||||
{
|
{
|
||||||
ShowEditor = false;
|
ShowEditor = false;
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|||||||
Reference in New Issue
Block a user