some work for loading a workspace

This commit is contained in:
2024-09-06 16:55:04 +02:00
parent f0f63a1895
commit 5e678db077
7 changed files with 114 additions and 14 deletions

View File

@@ -21,6 +21,7 @@ internal class GitLabRepoWorkspace(GitLabRepoWorkspaceConfig config) : IWorkspac
{
InstallInfos = InstallInfos.Parse(await GetContent(ConfigX.FileLocationInstallJson));
UpdateInfos = UpdateInfos.Parse(await GetContent(ConfigX.FileLocationUpdateJson));
ConfigX.InstanceUrl = (await Gitlab.Projects.GetByIdAsync((int)ConfigX.RepoId, new())).NameWithNamespace;
return InstallInfos != null && UpdateInfos != null;
}

View File

@@ -5,10 +5,19 @@ namespace ModpackUpdater.Apps.Manager.Features.Workspaces.GitLabRepo;
internal class GitLabRepoWorkspaceConfig : WorkspaceConfig
{
public override string DisplayText => $"{RepoName ?? "?"} at {RepoBranche} on {InstanceUrl}";
public string? RepoName { get; set; }
public string InstanceUrl { get; set; } = "https://gitlab.com";
public string? ApiToken { get; set; }
public long RepoId { get; set; } = -1L;
public string RepoBranche { get; set; } = "master";
public string FileLocationInstallJson { get; set; } = "install.json";
public string FileLocationUpdateJson { get; set; } = "update.json";
}

View File

@@ -17,7 +17,7 @@ internal class GitLabRepoWorkspaceFeature : WorkspaceFeature, IPluginFeatureProv
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.gitlab, SymbolSize.Small);
}
protected override bool OnConfigure(ref IWorkspace workspace)
protected override bool OnConfigure(ref IWorkspace? workspace)
{
var settings = workspace?.Config as GitLabRepoWorkspaceConfig ?? new();
@@ -25,6 +25,15 @@ internal class GitLabRepoWorkspaceFeature : WorkspaceFeature, IPluginFeatureProv
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);
}
}