This commit is contained in:
2025-11-17 15:59:49 +01:00
parent d68df750a6
commit fb36f897d6
5 changed files with 11 additions and 6 deletions

View File

@@ -4,4 +4,5 @@ public class WorkspaceContext(IMainApi mainApi, IWorkspace? workspace)
{ {
public IMainApi MainApi => mainApi; public IMainApi MainApi => mainApi;
public IWorkspace? Workspace { get; set; } = workspace; public IWorkspace? Workspace { get; set; } = workspace;
public bool Canceled { get; set; }
} }

View File

@@ -14,7 +14,7 @@ public abstract class WorkspaceFeature(string identifier, string name) : PluginF
{ {
await OnConfigure(context); await OnConfigure(context);
if (context?.Workspace?.Config is not null) if (!context.Canceled && context.Workspace?.Config is not null)
context.Workspace.Config.ProviderId = Identifier; context.Workspace.Config.ProviderId = Identifier;
} }

View File

@@ -24,6 +24,8 @@ internal class GitLabRepoWorkspaceFeature() : WorkspaceFeature("origin.gitlab",
AppGlobals.Symbols.GetImageSource(AppSymbols.gitlab))) AppGlobals.Symbols.GetImageSource(AppSymbols.gitlab)))
.Result is GitLabRepoWorkspaceConfig settingsNew) .Result is GitLabRepoWorkspaceConfig settingsNew)
context.Workspace = new GitLabRepoWorkspace(settingsNew); context.Workspace = new GitLabRepoWorkspace(settingsNew);
else
context.Canceled = true;
} }
protected override void OnCreate(out IWorkspace workspace, WorkspaceConfig config) protected override void OnCreate(out IWorkspace workspace, WorkspaceConfig config)

View File

@@ -10,7 +10,6 @@
xmlns:langRes="clr-namespace:ModpackUpdater.Apps.Manager.LangRes" xmlns:langRes="clr-namespace:ModpackUpdater.Apps.Manager.LangRes"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ModpackUpdater.Apps.Manager.Ui.MainWindow" x:Class="ModpackUpdater.Apps.Manager.Ui.MainWindow"
x:DataType="mainWindow:MainWindowViewModel"
Title="Minecraft Modpack Manager" Title="Minecraft Modpack Manager"
WindowState="Maximized" WindowState="Maximized"
Loaded="Window_OnLoaded" Loaded="Window_OnLoaded"
@@ -18,6 +17,7 @@
<Grid <Grid
x:Name="GridMain" x:Name="GridMain"
x:DataType="mainWindow:MainWindowViewModel"
RowDefinitions="Auto,*" RowDefinitions="Auto,*"
ColumnDefinitions="Auto,*,500" ColumnDefinitions="Auto,*,500"
RowSpacing="6" RowSpacing="6"

View File

@@ -27,10 +27,10 @@ public partial class MainWindow : Window, IMainApi
public MainWindow() public MainWindow()
{ {
DataContext = Model;
InitializeComponent(); InitializeComponent();
GridMain.DataContext = Model;
ButtonWorkspace.ImageSource = AppGlobals.Symbols.GetImageSource(AppSymbols.workspace); ButtonWorkspace.ImageSource = AppGlobals.Symbols.GetImageSource(AppSymbols.workspace);
MenuItemWorkspacePreferences.Icon = AppGlobals.Symbols.GetImage(AppSymbols.settings, SymbolSize.Small); MenuItemWorkspacePreferences.Icon = AppGlobals.Symbols.GetImage(AppSymbols.settings, SymbolSize.Small);
MenuItemSaveWorkspace.Icon = AppGlobals.Symbols.GetImage(AppSymbols.save, SymbolSize.Small); MenuItemSaveWorkspace.Icon = AppGlobals.Symbols.GetImage(AppSymbols.save, SymbolSize.Small);
@@ -124,6 +124,7 @@ public partial class MainWindow : Window, IMainApi
var context = new WorkspaceContext(MainApi, null); var context = new WorkspaceContext(MainApi, null);
await feature.Configure(context); await feature.Configure(context);
if (!context.Canceled)
await LoadNewWorkspace(context.Workspace, feature); await LoadNewWorkspace(context.Workspace, feature);
} }
@@ -134,6 +135,7 @@ public partial class MainWindow : Window, IMainApi
var context = new WorkspaceContext(MainApi, Model.CurrentWorkspace); var context = new WorkspaceContext(MainApi, Model.CurrentWorkspace);
await curWs.Configure(context); await curWs.Configure(context);
if (!context.Canceled)
await LoadNewWorkspace(context.Workspace, curWs); await LoadNewWorkspace(context.Workspace, curWs);
} }