using ModpackUpdater.Apps.Manager.Api.Model; using ModpackUpdater.Apps.Manager.Api.Plugins.Features; using ModpackUpdater.Apps.Manager.LangRes; using Pilz.Plugins.Advanced; using Pilz.UI.Symbols; using Pilz.UI.WinForms.Extensions; using Pilz.UI.WinForms.Telerik.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.GetSvgImage(AppSymbols.gitlab, SymbolSize.Small); } protected override bool OnConfigure(ref IWorkspace? workspace) { var settings = workspace?.Config as GitLabRepoWorkspaceConfig ?? new(); if (RadDialogBase.ShowDialog(new GitLabRepoWorkspaceConfigEditor(settings), TitlesLangRes.GitLabRepoWorkspaceEditor, AppGlobals.Symbols.GetSvgImage(AppSymbols.gitlab, SymbolSize.Small)).Result.IsNotOk()) return false; workspace = new GitLabRepoWorkspace(settings); return true; } protected override void OnCreate(out IWorkspace workspace, WorkspaceConfig config) { if (config is not GitLabRepoWorkspaceConfig gitlabConfig) throw new NotImplementedException($"Only configs of type {typeof(GitLabRepoWorkspaceConfig).Name} are allowed."); workspace = new GitLabRepoWorkspace(gitlabConfig); } }