Added file editor to the api. Made the entire file manager available to the interfaces.
This commit is contained in:
parent
cdc2954d0b
commit
5d9c32a196
10 changed files with 20 additions and 22 deletions
|
@ -11,7 +11,7 @@ public class CreateFileAction : IFileManagerCreateAction
|
|||
public string Icon => "bx-file";
|
||||
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>();
|
||||
|
||||
|
@ -21,17 +21,15 @@ public class CreateFileAction : IFileManagerCreateAction
|
|||
return;
|
||||
|
||||
await access.CreateFile(name);
|
||||
|
||||
/*
|
||||
|
||||
// We build a virtual entry here so we dont need to fetch one
|
||||
await OpenEditor(new()
|
||||
await fileManager.OpenEditor(new()
|
||||
{
|
||||
Name = name,
|
||||
Size = 0,
|
||||
IsFile = true,
|
||||
IsDirectory = false,
|
||||
LastModifiedAt = DateTime.UtcNow
|
||||
});*/
|
||||
});
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ public class CreateFolderAction : IFileManagerCreateAction
|
|||
public string Icon => "bx-folder";
|
||||
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 toastService = provider.GetRequiredService<ToastService>();
|
||||
|
@ -24,6 +24,6 @@ public class CreateFolderAction : IFileManagerCreateAction
|
|||
await access.CreateDirectory(name);
|
||||
|
||||
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 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 view.Refresh();
|
||||
await fileManager.View.Refresh();
|
||||
|
||||
var toastService = serviceProvider.GetRequiredService<ToastService>();
|
||||
await toastService.Success("Successfully deleted item");
|
||||
|
|
|
@ -10,7 +10,7 @@ public class DeleteSelectionAction : IFileManagerSelectionAction
|
|||
public string Name => "Delete";
|
||||
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 toastService = provider.GetRequiredService<ToastService>();
|
||||
|
|
|
@ -15,7 +15,7 @@ public class DownloadContextAction : IFileManagerContextAction
|
|||
public string Color => "primary";
|
||||
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 navigation = serviceProvider.GetRequiredService<NavigationManager>();
|
||||
|
|
|
@ -12,7 +12,7 @@ public class RenameContextAction : IFileManagerContextAction
|
|||
public string Color => "info";
|
||||
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 toastService = provider.GetRequiredService<ToastService>();
|
||||
|
@ -24,7 +24,7 @@ public class RenameContextAction : IFileManagerContextAction
|
|||
|
||||
await access.Rename(entry.Name, newName);
|
||||
|
||||
await view.Refresh();
|
||||
await fileManager.View.Refresh();
|
||||
await toastService.Success("Successfully renamed file");
|
||||
}
|
||||
}
|
|
@ -10,5 +10,5 @@ public interface IFileManagerContextAction
|
|||
public string Color { 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 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 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; }
|
||||
|
||||
private FileView View;
|
||||
public FileView View { get; private set; }
|
||||
private string Path = "/";
|
||||
|
||||
private IFileManagerContextAction[] ContextActions;
|
||||
|
@ -244,12 +244,12 @@ else
|
|||
{
|
||||
await View.HideContextMenu();
|
||||
|
||||
await contextAction.Execute(FileAccess, View, entry, ServiceProvider);
|
||||
await contextAction.Execute(FileAccess, this, entry, ServiceProvider);
|
||||
}
|
||||
|
||||
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
|
||||
await View.Refresh();
|
||||
|
@ -257,7 +257,7 @@ else
|
|||
|
||||
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);
|
||||
|
@ -309,7 +309,7 @@ else
|
|||
|
||||
#region File Editor
|
||||
|
||||
private async Task OpenEditor(FileEntry entry)
|
||||
public async Task OpenEditor(FileEntry entry)
|
||||
{
|
||||
FileToEdit = entry;
|
||||
ShowEditor = true;
|
||||
|
@ -317,7 +317,7 @@ else
|
|||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task CloseEditor()
|
||||
public async Task CloseEditor()
|
||||
{
|
||||
ShowEditor = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
|
Loading…
Reference in a new issue