feat(welcome): per-role app recipes in the first-boot wizard #17
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SilverOS.Welcome.Core.Apply;
|
||||
using SilverOS.Welcome.Core.Apps;
|
||||
using SilverOS.Welcome.Core.Flavours;
|
||||
using SilverOS.Welcome.App.Components;
|
||||
|
||||
@@ -34,6 +35,7 @@ public static class MauiProgram
|
||||
var hardeningDir = @"C:\Windows\Setup\Scripts\hardening";
|
||||
builder.Services.AddSingleton<IProcessRunner, ProcessRunner>();
|
||||
builder.Services.AddSingleton<IFlavourLoader, FlavourLoader>();
|
||||
builder.Services.AddSingleton<IAppCatalog, AppCatalog>();
|
||||
builder.Services.AddSingleton<IAccountService, AccountService>();
|
||||
builder.Services.AddSingleton<IBitLockerService, BitLockerService>();
|
||||
builder.Services.AddSingleton<IBootstrapService, BootstrapService>();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
@using SilverOS.Welcome.App.Components.Steps
|
||||
@using SilverOS.Welcome.Core.Flavours
|
||||
@using SilverOS.Welcome.Core.Apps
|
||||
@inject IFlavourLoader FlavourLoader
|
||||
@inject IAppCatalog AppCatalog
|
||||
@inject WizardState State
|
||||
|
||||
<div class="wizard">
|
||||
@@ -40,15 +42,18 @@
|
||||
<FlavourStep Flavours="_flavours" OnSelected="StateHasChanged" />
|
||||
break;
|
||||
case 2:
|
||||
<AccountStep OnValidityChanged="@(v => { _accountValid = v; StateHasChanged(); })" />
|
||||
<AppsStep Apps="_catalog.AppsForRole(State.Flavour?.Id ?? string.Empty)" />
|
||||
break;
|
||||
case 3:
|
||||
<PrefsStep />
|
||||
<AccountStep OnValidityChanged="@(v => { _accountValid = v; StateHasChanged(); })" />
|
||||
break;
|
||||
case 4:
|
||||
<ApplyStep OnComplete="AdvanceToDone" OnRunningChanged="@(v => { _applyRunning = v; StateHasChanged(); })" />
|
||||
<PrefsStep />
|
||||
break;
|
||||
case 5:
|
||||
<ApplyStep OnComplete="AdvanceToDone" OnRunningChanged="@(v => { _applyRunning = v; StateHasChanged(); })" />
|
||||
break;
|
||||
case 6:
|
||||
<DoneStep />
|
||||
break;
|
||||
}
|
||||
@@ -61,7 +66,7 @@
|
||||
@onclick="Back">
|
||||
Back
|
||||
</button>
|
||||
@if (_currentStep < _stepTitles.Length - 1 && _currentStep != 4)
|
||||
@if (_currentStep < _stepTitles.Length - 1 && _currentStep != 5)
|
||||
{
|
||||
<button class="btn-primary"
|
||||
disabled="@(!CanGoNext)"
|
||||
@@ -73,12 +78,18 @@
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private static readonly string[] _stepTitles = { "Welcome", "Flavour", "Account", "Prefs", "Apply", "Done" };
|
||||
private static readonly string[] _stepTitles = { "Welcome", "Flavour", "Apps", "Account", "Prefs", "Apply", "Done" };
|
||||
|
||||
// Flavours dir: baked alongside the exe at publish time.
|
||||
private static readonly string FlavoursDir = Path.Combine(
|
||||
AppContext.BaseDirectory, "flavours");
|
||||
|
||||
// Apps catalog dir: baked alongside the exe at publish time.
|
||||
private static readonly string AppsDir = Path.Combine(
|
||||
AppContext.BaseDirectory, "apps");
|
||||
|
||||
private LoadedCatalog _catalog = new(Array.Empty<AppCatalogEntry>());
|
||||
|
||||
private int _currentStep = 0;
|
||||
private bool _loading = true;
|
||||
private bool _applyRunning = false;
|
||||
@@ -89,7 +100,8 @@
|
||||
private bool CanGoNext => _currentStep switch
|
||||
{
|
||||
1 => State.Flavour is not null,
|
||||
2 => _accountValid,
|
||||
// 2 = Apps step is always valid (never blocks Next).
|
||||
3 => _accountValid,
|
||||
_ => true
|
||||
};
|
||||
|
||||
@@ -102,6 +114,7 @@
|
||||
try
|
||||
{
|
||||
_flavours = FlavourLoader.Load(FlavoursDir);
|
||||
_catalog = AppCatalog.Load(AppsDir);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -118,6 +131,11 @@
|
||||
{
|
||||
if (_currentStep < _stepTitles.Length - 1)
|
||||
_currentStep++;
|
||||
|
||||
// On entering the Apps step, seed the per-role default selection once.
|
||||
if (_currentStep == 2 && State.SelectedApps.Count == 0 && State.Flavour is not null)
|
||||
foreach (var id in _catalog.DefaultSelectionForRole(State.Flavour.Id))
|
||||
State.SelectedApps.Add(id);
|
||||
}
|
||||
|
||||
void Back()
|
||||
|
||||
Reference in New Issue
Block a user