local folder workspace
This commit is contained in:
@@ -6,19 +6,14 @@ namespace ModpackUpdater.Apps.Manager.Features.Workspaces.GitLabRepo;
|
||||
|
||||
internal class GitLabRepoWorkspace(GitLabRepoWorkspaceConfig config) : IWorkspace
|
||||
{
|
||||
private string? rawInstallInfos = null;
|
||||
private string? rawUpdateInfos = null;
|
||||
private string? rawInstallInfos;
|
||||
private string? rawUpdateInfos;
|
||||
|
||||
public WorkspaceConfig Config => ConfigX;
|
||||
|
||||
public GitLabRepoWorkspaceConfig ConfigX { get; } = config;
|
||||
|
||||
public IGitLabClient Gitlab { get; } = new GitLabClient(config.InstanceUrl, config.ApiToken);
|
||||
|
||||
public ModpackConfig? ModpackConfig { get; private set; }
|
||||
|
||||
public InstallInfos? InstallInfos { get; private set; }
|
||||
|
||||
public UpdateInfos? UpdateInfos { get; private set; }
|
||||
|
||||
public async Task<bool> Load()
|
||||
@@ -39,13 +34,17 @@ internal class GitLabRepoWorkspace(GitLabRepoWorkspaceConfig config) : IWorkspac
|
||||
|
||||
public async Task<bool> Save()
|
||||
{
|
||||
var failed = true;
|
||||
|
||||
if (InstallInfos != null)
|
||||
{
|
||||
var newInstallInfos = InstallInfos.ToString();
|
||||
if (newInstallInfos != rawInstallInfos)
|
||||
{
|
||||
await SaveContent(ConfigX.FileLocationInstallJson, newInstallInfos);
|
||||
rawInstallInfos = newInstallInfos;
|
||||
if (await SaveContent(ConfigX.FileLocationInstallJson, newInstallInfos))
|
||||
rawInstallInfos = newInstallInfos;
|
||||
else
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,12 +53,14 @@ internal class GitLabRepoWorkspace(GitLabRepoWorkspaceConfig config) : IWorkspac
|
||||
var newUpdateInfos = UpdateInfos.ToString();
|
||||
if (newUpdateInfos != rawUpdateInfos)
|
||||
{
|
||||
await SaveContent(ConfigX.FileLocationUpdateJson, newUpdateInfos);
|
||||
rawUpdateInfos = newUpdateInfos;
|
||||
if (await SaveContent(ConfigX.FileLocationUpdateJson, newUpdateInfos))
|
||||
rawUpdateInfos = newUpdateInfos;
|
||||
else
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return failed;
|
||||
}
|
||||
|
||||
private async Task<string> GetContent(string path)
|
||||
|
||||
@@ -10,27 +10,28 @@
|
||||
d:DesignWidth="800"
|
||||
d:DesignHeight="450"
|
||||
Width="300"
|
||||
x:Class="ModpackUpdater.Apps.Manager.Features.Workspaces.GitLabRepo.GitLabRepoWorkspaceConfigEditorView">
|
||||
x:Class="ModpackUpdater.Apps.Manager.Features.Workspaces.GitLabRepo.GitLabRepoWorkspaceConfigEditorView"
|
||||
x:DataType="gitLabRepo:GitLabRepoWorkspaceConfig">
|
||||
|
||||
<dialogs:AvaloniaFlyoutBase.MainContent>
|
||||
<StackPanel Spacing="6">
|
||||
<TextBlock Text="{x:Static langRes:GeneralLangRes.GitLabInstanceUrl}"/>
|
||||
<TextBox Text="{Binding InstanceUrl, DataType=gitLabRepo:GitLabRepoWorkspaceConfig}"/>
|
||||
<Label Target="TextBoxInstanceUrl" Content="{x:Static langRes:GeneralLangRes.GitLabInstanceUrl}"/>
|
||||
<TextBox Name="TextBoxInstanceUrl" Text="{Binding InstanceUrl}"/>
|
||||
|
||||
<TextBlock Text="{x:Static langRes:GeneralLangRes.GitLabApiToken}"/>
|
||||
<TextBox Text="{Binding ApiToken, DataType=gitLabRepo:GitLabRepoWorkspaceConfig}"/>
|
||||
<Label Target="TextBoxApiToken" Content="{x:Static langRes:GeneralLangRes.GitLabApiToken}"/>
|
||||
<TextBox Name="TextBoxApiToken" Text="{Binding ApiToken}"/>
|
||||
|
||||
<TextBlock Text="{x:Static langRes:GeneralLangRes.RepositoryId}"/>
|
||||
<NumericUpDown Value="{Binding RepoId, DataType=gitLabRepo:GitLabRepoWorkspaceConfig}"/>
|
||||
<Label Target="NumericUpDownRepoId" Content="{x:Static langRes:GeneralLangRes.RepositoryId}"/>
|
||||
<NumericUpDown Name="NumericUpDownRepoId" Value="{Binding RepoId}"/>
|
||||
|
||||
<TextBlock Text="{x:Static langRes:GeneralLangRes.FileLocationOfInstallJson}"/>
|
||||
<TextBox Text="{Binding FileLocationInstallJson, DataType=gitLabRepo:GitLabRepoWorkspaceConfig}"/>
|
||||
<Label Target="TextBoxInstallJson" Content="{x:Static langRes:GeneralLangRes.FileLocationOfInstallJson}"/>
|
||||
<TextBox Name="TextBoxInstallJson" Text="{Binding FileLocationInstallJson}"/>
|
||||
|
||||
<TextBlock Text="{x:Static langRes:GeneralLangRes.FileLocationOfUpdateJson}"/>
|
||||
<TextBox Text="{Binding FileLocationUpdateJson, DataType=gitLabRepo:GitLabRepoWorkspaceConfig}"/>
|
||||
<Label Target="TextBoxUpdateJson" Content="{x:Static langRes:GeneralLangRes.FileLocationOfUpdateJson}"/>
|
||||
<TextBox Name="TextBoxUpdateJson" Text="{Binding FileLocationUpdateJson}"/>
|
||||
|
||||
<TextBlock Text="{x:Static langRes:GeneralLangRes.ModpackConfigUrl}"/>
|
||||
<TextBox Text="{Binding ModpackConfigUrl, DataType=gitLabRepo:GitLabRepoWorkspaceConfig}"/>
|
||||
<Label Target="TextBoxModpackConfigUrl" Content="{x:Static langRes:GeneralLangRes.ModpackConfigUrl}"/>
|
||||
<TextBox Name="TextBoxModpackConfigUrl" Text="{Binding ModpackConfigUrl}"/>
|
||||
</StackPanel>
|
||||
</dialogs:AvaloniaFlyoutBase.MainContent>
|
||||
</dialogs:AvaloniaFlyoutBase>
|
||||
|
||||
@@ -31,7 +31,7 @@ internal class GitLabRepoWorkspaceFeature() : WorkspaceFeature("origin.gitlab",
|
||||
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.");
|
||||
throw new NotSupportedException($"Only configs of type {nameof(GitLabRepoWorkspaceConfig)} are allowed.");
|
||||
workspace = new GitLabRepoWorkspace(gitlabConfig);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user