local folder workspace

This commit is contained in:
2025-11-17 16:35:02 +01:00
parent 5df8019cfb
commit e04e5f0b13
17 changed files with 347 additions and 151 deletions

View File

@@ -0,0 +1,37 @@
using ModpackUpdater.Apps.Manager.Api.Model;
using ModpackUpdater.Apps.Manager.Api.Plugins.Features;
using ModpackUpdater.Apps.Manager.LangRes;
using Pilz.Features;
using Pilz.UI.AvaloniaUI.Dialogs;
using Pilz.UI.Symbols;
namespace ModpackUpdater.Apps.Manager.Features.Workspaces.LocalFolder;
internal class LocalFolderWorkspaceFeature() : WorkspaceFeature("origin.localfolder", FeatureNamesLangRes.LocalFolderWorkspace), IPluginFeatureProvider<LocalFolderWorkspaceFeature>
{
public static LocalFolderWorkspaceFeature Instance { get; } = new();
public override object? Icon => AppGlobals.Symbols.GetImage(AppSymbols.opened_folder, SymbolSize.Small);
protected override async Task OnConfigure(WorkspaceContext context)
{
var settings = context.Workspace?.Config as LocalFolderWorkspaceConfig ?? new();
if ((await AvaloniaFlyoutBase.Show(
new LocalFolderWorkspaceConfigEditorView((LocalFolderWorkspaceConfig)settings.Clone()),
context.MainApi.MainWindow,
TitlesLangRes.LocalFolderWorkspaceEditor,
AppGlobals.Symbols.GetImageSource(AppSymbols.gitlab)))
.Result is LocalFolderWorkspaceConfig settingsNew)
context.Workspace = new LocalFolderWorkspace(settingsNew);
else
context.Canceled = true;
}
protected override void OnCreate(out IWorkspace workspace, WorkspaceConfig config)
{
if (config is not LocalFolderWorkspaceConfig gitlabConfig)
throw new NotSupportedException($"Only configs of type {nameof(LocalFolderWorkspaceConfig)} are allowed.");
workspace = new LocalFolderWorkspace(gitlabConfig);
}
}