Multiple Profiles can now be selected

This commit is contained in:
Peer Hogeterp committed 2026-09-07 16:09:00 +02:00
1 parent d043fbc8f0
commit cefc5464d5
89 files changed
+1360 -503

No files matched your search

@@ -10,13 +10,13 @@ namespace AIStudio.Components;
public partial class ProfileFormSelection : MSGComponentBase
{
[Parameter]
public Profile Profile { get; set; } = Profile.NO_PROFILE;
public HashSet<string> ProfileIds { get; set; } = [];
[Parameter]
public EventCallback<Profile> ProfileChanged { get; set; }
public EventCallback<HashSet<string>> ProfileIdsChanged { get; set; }
[Parameter]
public Func<Profile, string?> Validation { get; set; } = _ => null;
public Func<HashSet<string>, string?> Validation { get; set; } = _ => null;
[Parameter]
public bool Disabled { get; set; }
@@ -24,10 +24,29 @@ public partial class ProfileFormSelection : MSGComponentBase
[Inject]
public IDialogService DialogService { get; init; } = null!;
private async Task SelectionChanged(Profile profile)
private async Task SelectionChanged(IEnumerable<string?>? profileIds)
{
this.Profile = profile;
await this.ProfileChanged.InvokeAsync(profile);
var selection = profileIds is null
? []
: profileIds.Where(profileId => !string.IsNullOrWhiteSpace(profileId)).Select(profileId => profileId!).ToHashSet(StringComparer.OrdinalIgnoreCase);
this.ProfileIds = selection;
await this.ProfileIdsChanged.InvokeAsync(selection);
}
private string? ValidateSelection(IEnumerable<string?>? profileIds) => this.Validation(
profileIds is null
? []
: profileIds.Where(profileId => !string.IsNullOrWhiteSpace(profileId)).Select(profileId => profileId!).ToHashSet(StringComparer.OrdinalIgnoreCase));
private string GetSelectionText(List<string?>? profileIds)
{
var profiles = this.SettingsManager.ResolveProfiles(profileIds?.Where(profileId => profileId is not null).Select(profileId => profileId!));
return profiles.Count switch
{
0 => T("No profiles selected"),
1 => profiles[0].GetSafeName(),
_ => string.Format(T("{0} profiles"), profiles.Count),
};
}
private async Task OpenSettingsDialog()
@@ -35,4 +54,4 @@ public partial class ProfileFormSelection : MSGComponentBase
var dialogParameters = new DialogParameters();
await this.DialogService.ShowAsync<SettingsDialogProfiles>(T("Open Profile Options"), dialogParameters, DialogOptions.FULLSCREEN);
}
}
}