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; namespace ModpackUpdater.Apps.Manager.Features.Workspaces.GitLabRepo; internal class GitLabRepoWorkspaceFeature : WorkspaceFeature, IPluginFeatureProvider { public static GitLabRepoWorkspaceFeature Instance { get; } = new(); public GitLabRepoWorkspaceFeature() : base("origin.gitlab", FeatureNamesLangRes.GitLabWorkspace) { Icon = AppGlobals.Symbols.GetImageSource(AppSymbols.gitlab); } 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); } protected override void OnCreate(out IWorkspace workspace, WorkspaceConfig config) { if (config is not GitLabRepoWorkspaceConfig gitlabConfig) throw new NotImplementedException($"Only configs of type {nameof(GitLabRepoWorkspaceConfig)} are allowed."); workspace = new GitLabRepoWorkspace(gitlabConfig); } }