Browse Source

Fix ConnectionHelp navigation to installer

pull/438/head
ionite34 11 months ago
parent
commit
ae9a9d3f61
No known key found for this signature in database
GPG Key ID: B3404C5F3827849B
  1. 10
      StabilityMatrix.Avalonia/Models/PackageManagerNavigationOptions.cs
  2. 17
      StabilityMatrix.Avalonia/ViewModels/Dialogs/InferenceConnectionHelpViewModel.cs
  3. 2
      StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs
  4. 4
      StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs
  5. 28
      StabilityMatrix.Avalonia/Views/NewPackageManagerPage.axaml.cs
  6. 8
      StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml.cs

10
StabilityMatrix.Avalonia/Models/PackageManagerNavigationOptions.cs

@ -0,0 +1,10 @@
using StabilityMatrix.Core.Models.Packages;
namespace StabilityMatrix.Avalonia.Models;
public record PackageManagerNavigationOptions
{
public bool OpenInstallerDialog { get; init; }
public BasePackage? InstallerSelectedPackage { get; init; }
}

17
StabilityMatrix.Avalonia/ViewModels/Dialogs/InferenceConnectionHelpViewModel.cs

@ -8,6 +8,7 @@ using CommunityToolkit.Mvvm.Input;
using FluentAvalonia.UI.Controls;
using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.Views;
@ -65,8 +66,9 @@ public partial class InferenceConnectionHelpViewModel : ContentDialogViewModelBa
this.packageFactory = packageFactory;
// Get comfy type installed packages
var comfyPackages = this.settingsManager.Settings.InstalledPackages
.Where(p => p.PackageName == "ComfyUI")
var comfyPackages = this.settingsManager.Settings.InstalledPackages.Where(
p => p.PackageName == "ComfyUI"
)
.ToImmutableArray();
InstalledPackages = comfyPackages;
@ -103,13 +105,14 @@ public partial class InferenceConnectionHelpViewModel : ContentDialogViewModelBa
{
Dispatcher.UIThread.Post(() =>
{
navigationService.NavigateTo<PackageManagerViewModel>(
param: new PackageManagerPage.PackageManagerNavigationOptions
navigationService.NavigateTo<NewPackageManagerViewModel>(
param: new PackageManagerNavigationOptions
{
OpenInstallerDialog = true,
InstallerSelectedPackage = packageFactory
.GetAllAvailablePackages()
.First(p => p is ComfyUI)
.OfType<ComfyUI>()
.First()
}
);
});
@ -138,9 +141,7 @@ public partial class InferenceConnectionHelpViewModel : ContentDialogViewModelBa
var dialog = new BetterContentDialog
{
Content = new InferenceConnectionHelpDialog { DataContext = this },
PrimaryButtonCommand = IsInstallMode
? NavigateToInstallCommand
: LaunchSelectedPackageCommand,
PrimaryButtonCommand = IsInstallMode ? NavigateToInstallCommand : LaunchSelectedPackageCommand,
PrimaryButtonText = IsInstallMode ? Resources.Action_Install : Resources.Action_Launch,
CloseButtonText = Resources.Action_Close,
DefaultButton = ContentDialogButton.Primary

2
StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs

@ -113,7 +113,7 @@ public partial class PackageInstallBrowserViewModel : PageViewModelBase
public override string Title => "Add Package";
public override IconSource IconSource => new SymbolIconSource { Symbol = Symbol.Add };
public void OnPackageSelected(BaseGitPackage? package)
public void OnPackageSelected(BasePackage? package)
{
if (package is null)
{

4
StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs

@ -31,7 +31,7 @@ namespace StabilityMatrix.Avalonia.ViewModels.PackageManager;
[View(typeof(PackageInstallDetailView))]
public partial class PackageInstallDetailViewModel(
BaseGitPackage package,
BasePackage package,
ISettingsManager settingsManager,
INotificationService notificationService,
ILogger<PackageInstallDetailViewModel> logger,
@ -40,7 +40,7 @@ public partial class PackageInstallDetailViewModel(
INavigationService<NewPackageManagerViewModel> packageNavigationService
) : PageViewModelBase
{
public BaseGitPackage SelectedPackage { get; } = package;
public BasePackage SelectedPackage { get; } = package;
public override string Title { get; } = package.DisplayName;
public override IconSource IconSource => new SymbolIconSource();

28
StabilityMatrix.Avalonia/Views/NewPackageManagerPage.axaml.cs

@ -13,6 +13,7 @@ using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.PackageManager;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Models;
@ -38,6 +39,8 @@ public partial class NewPackageManagerPage : UserControlBase, IHandleNavigation
InitializeComponent();
AddHandler(Frame.NavigatedToEvent, OnNavigatedTo, RoutingStrategies.Direct);
packageNavigationService.SetFrame(FrameView);
packageNavigationService.TypedNavigation += NavigationService_OnTypedNavigation;
FrameView.Navigated += FrameView_Navigated;
@ -64,6 +67,31 @@ public partial class NewPackageManagerPage : UserControlBase, IHandleNavigation
}
}
/// <summary>
/// Handle navigation events to this page
/// </summary>
private void OnNavigatedTo(object? sender, NavigationEventArgs args)
{
if (args.Parameter is PackageManagerNavigationOptions { OpenInstallerDialog: true } options)
{
var vm = (NewPackageManagerViewModel)DataContext!;
Dispatcher.UIThread.Post(
() =>
{
// Navigate to the installer page
packageNavigationService.NavigateTo<PackageInstallBrowserViewModel>();
// Select the package
vm.SubPages.OfType<PackageInstallBrowserViewModel>()
.First()
.OnPackageSelected(options.InstallerSelectedPackage);
},
DispatcherPriority.Send
);
}
}
private void NavigationService_OnTypedNavigation(object? sender, TypedNavigationEventArgs e)
{
ViewModel.CurrentPage =

8
StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml.cs

@ -4,6 +4,7 @@ using Avalonia.Threading;
using FluentAvalonia.UI.Controls;
using FluentAvalonia.UI.Navigation;
using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.ViewModels;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Models.Packages;
@ -39,11 +40,4 @@ public partial class PackageManagerPage : UserControlBase
});
}
}
public record PackageManagerNavigationOptions
{
public bool OpenInstallerDialog { get; init; }
public BasePackage? InstallerSelectedPackage { get; init; }
}
}

Loading…
Cancel
Save