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.GitLabRepo; internal class GitLabRepoWorkspaceFeature() : WorkspaceFeature("origin.gitlab", FeatureNamesLangRes.GitLabWorkspace), IPluginFeatureProvider { public static GitLabRepoWorkspaceFeature Instance { get; } = new(); public override object? Icon => AppGlobals.Symbols.GetImage(AppSymbols.gitlab, SymbolSize.Small); protected override async Task OnConfigure(WorkspaceContext context) { var settings = context.Workspace?.Config as GitLabRepoWorkspaceConfig ?? new(); if ((await AvaloniaFlyoutBase.Show( new GitLabRepoWorkspaceConfigEditorView((GitLabRepoWorkspaceConfig)settings.Clone()), context.MainApi.MainWindow, TitlesLangRes.GitLabRepoWorkspaceEditor, AppGlobals.Symbols.GetImageSource(AppSymbols.gitlab))) .Result is GitLabRepoWorkspaceConfig settingsNew) context.Workspace = new GitLabRepoWorkspace(settingsNew); else context.Canceled = true; } protected override void OnCreate(out IWorkspace workspace, WorkspaceConfig config) { if (config is not GitLabRepoWorkspaceConfig gitlabConfig) throw new NotSupportedException($"Only configs of type {nameof(GitLabRepoWorkspaceConfig)} are allowed."); workspace = new GitLabRepoWorkspace(gitlabConfig); } }