Add ability to export/import settings configuration (#522)

This commit is contained in:
Jeffrey
2026-03-27 20:33:24 +01:00
committed by GitHub
parent e05af92acc
commit 774c8ecd92
15 changed files with 726 additions and 31 deletions

View File

@@ -27,6 +27,8 @@ function Show-MainWindow {
$menuReportBug = $window.FindName('MenuReportBug')
$menuLogs = $window.FindName('MenuLogs')
$menuAbout = $window.FindName('MenuAbout')
$importConfigBtn = $window.FindName('ImportConfigBtn')
$exportConfigBtn = $window.FindName('ExportConfigBtn')
# Title bar event handlers
$titleBar.Add_MouseLeftButtonDown({
@@ -67,6 +69,22 @@ function Show-MainWindow {
Show-AboutDialog -Owner $window
})
# --- Import/Export Configuration ---
$exportConfigBtn.Add_Click({
Export-Configuration -Owner $window -UsesDarkMode $usesDarkMode -AppsPanel $appsPanel -UiControlMappings $script:UiControlMappings -UserSelectionCombo $userSelectionCombo -OtherUsernameTextBox $otherUsernameTextBox
})
$importConfigBtn.Add_Click({
Import-Configuration -Owner $window -UsesDarkMode $usesDarkMode -AppsPanel $appsPanel -UiControlMappings $script:UiControlMappings -UserSelectionCombo $userSelectionCombo -OtherUsernameTextBox $otherUsernameTextBox -OnAppsImported { UpdateAppSelectionStatus; UpdatePresetStates } -OnImportCompleted {
$tabControl.SelectedIndex = 3
UpdateNavigationButtons
$window.Dispatcher.BeginInvoke([System.Windows.Threading.DispatcherPriority]::Loaded, [action]{
Show-Bubble -TargetControl $reviewChangesBtn -Message 'View the selected changes here'
}) | Out-Null
}
})
$closeBtn.Add_Click({
$window.Close()
})
@@ -254,6 +272,11 @@ function Show-MainWindow {
$script:PendingDefaultMode = $false
# Holds apps data preloaded before ShowDialog() so the first load skips the background job
$script:PreloadedAppData = $null
# Prevent app import until the apps list has finished initial population.
if ($importConfigBtn) {
$importConfigBtn.IsEnabled = $false
}
# Set script-level variable for GUI window reference
$script:GuiWindow = $window
@@ -738,6 +761,9 @@ function Show-MainWindow {
if ($appsToAdd.Count -eq 0) {
$window.FindName('DeploymentApplyBtn').IsEnabled = $true
if ($importConfigBtn) {
$importConfigBtn.IsEnabled = $true
}
return
}
@@ -830,6 +856,9 @@ function Show-MainWindow {
# Re-enable Apply button now that the full, correctly-checked app list is ready
$window.FindName('DeploymentApplyBtn').IsEnabled = $true
if ($importConfigBtn) {
$importConfigBtn.IsEnabled = $true
}
}
# Loads apps into the UI
@@ -838,6 +867,10 @@ function Show-MainWindow {
if ($script:IsLoadingApps) { return }
$script:IsLoadingApps = $true
if ($importConfigBtn) {
$importConfigBtn.IsEnabled = $false
}
# Show loading indicator and clear existing apps
$loadingAppsIndicator.Visibility = 'Visible'
$appsPanel.Children.Clear()