From bce968000c0b74015c56ec162d712e22e27dcb39 Mon Sep 17 00:00:00 2001 From: Siyuan Date: Fri, 31 Oct 2025 17:56:03 +0000 Subject: [PATCH] feat: redirect to setup page after config reset --- internal/ota/ota.go | 5 ++- ui/localization/messages/en.json | 40 +++++++++---------- .../devices.$id.settings.general.update.tsx | 6 +-- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/internal/ota/ota.go b/internal/ota/ota.go index 194c8959..40ed3bba 100644 --- a/internal/ota/ota.go +++ b/internal/ota/ota.go @@ -177,16 +177,19 @@ func (s *State) doUpdate(ctx context.Context, params UpdateParams) error { if s.rebootNeeded { scopedLogger.Info().Msg("System Rebooting due to OTA update") + redirectUrl := fmt.Sprintf("/settings/general/update?version=%s", systemUpdate.version) + if params.ResetConfig { scopedLogger.Info().Msg("Resetting config") if err := s.resetConfig(); err != nil { return s.componentUpdateError("Error resetting config", err, &scopedLogger) } + redirectUrl = "/device/setup" } postRebootAction := &PostRebootAction{ HealthCheck: "/device/status", - RedirectUrl: fmt.Sprintf("/settings/general/update?version=%s", systemUpdate.version), + RedirectUrl: redirectUrl, } if err := s.reboot(true, postRebootAction, 10*time.Second); err != nil { diff --git a/ui/localization/messages/en.json b/ui/localization/messages/en.json index 52bcd26e..3a056372 100644 --- a/ui/localization/messages/en.json +++ b/ui/localization/messages/en.json @@ -74,7 +74,6 @@ "advanced_error_update_ssh_key": "Failed to update SSH key: {error}", "advanced_error_usb_emulation_disable": "Failed to disable USB emulation: {error}", "advanced_error_usb_emulation_enable": "Failed to enable USB emulation: {error}", - "advanced_error_version_update": "Failed to initiate version update: {error}", "advanced_loopback_only_description": "Restrict web interface access to localhost only (127.0.0.1)", "advanced_loopback_only_title": "Loopback-Only Mode", "advanced_loopback_warning_before": "Before enabling this feature, make sure you have either:", @@ -101,19 +100,6 @@ "advanced_update_ssh_key_button": "Update SSH Key", "advanced_usb_emulation_description": "Control the USB emulation state", "advanced_usb_emulation_title": "USB Emulation", - "advanced_version_update_app_label": "App Version", - "advanced_version_update_button": "Update to Version", - "advanced_version_update_description": "Install a specific version from GitHub releases", - "advanced_version_update_github_link": "JetKVM releases page", - "advanced_version_update_helper": "Find available versions on the", - "advanced_version_update_reset_config_description": "Reset configuration after the update", - "advanced_version_update_reset_config_label": "Reset configuration", - "advanced_version_update_system_label": "System Version", - "advanced_version_update_target_app": "App only", - "advanced_version_update_target_both": "Both App and System", - "advanced_version_update_target_label": "What to update", - "advanced_version_update_target_system": "System only", - "advanced_version_update_title": "Update to Specific Version", "already_adopted_new_owner": "If you're the new owner, please ask the previous owner to de-register the device from their account in the cloud dashboard. If you believe this is an error, contact our support team for assistance.", "already_adopted_other_user": "This device is currently registered to another user in our cloud dashboard.", "already_adopted_return_to_dashboard": "Return to Dashboard", @@ -255,8 +241,8 @@ "general_auto_update_description": "Automatically update the device to the latest version", "general_auto_update_error": "Failed to set auto-update: {error}", "general_auto_update_title": "Auto Update", - "general_check_for_stable_updates": "Downgrade", "general_check_for_updates": "Check for Updates", + "general_check_for_stable_updates": "Downgrade", "general_page_description": "Configure device settings and update preferences", "general_reboot_description": "Do you want to proceed with rebooting the system?", "general_reboot_device": "Reboot Device", @@ -276,13 +262,9 @@ "general_update_checking_title": "Checking for updates…", "general_update_completed_description": "Your device has been successfully updated to the latest version. Enjoy the new features and improvements!", "general_update_completed_title": "Update Completed Successfully", - "general_update_downgrade_available_description": "A downgrade is available to revert to a previous version.", - "general_update_downgrade_available_title": "Downgrade Available", - "general_update_downgrade_button": "Downgrade Now", "general_update_error_description": "An error occurred while updating your device. Please try again later.", "general_update_error_details": "Error details: {errorMessage}", "general_update_error_title": "Update Error", - "general_update_keep_current_button": "Keep Current Version", "general_update_later_button": "Do it later", "general_update_now_button": "Update Now", "general_update_rebooting": "Rebooting to complete the update…", @@ -910,5 +892,23 @@ "wake_on_lan_invalid_mac": "Invalid MAC address", "wake_on_lan_magic_sent_success": "Magic Packet sent successfully", "welcome_to_jetkvm": "Welcome to JetKVM", - "welcome_to_jetkvm_description": "Control any computer remotely" + "welcome_to_jetkvm_description": "Control any computer remotely", + "advanced_version_update_app_label": "App Version", + "advanced_version_update_button": "Update to Version", + "advanced_version_update_description": "Install a specific version from GitHub releases", + "advanced_version_update_github_link": "JetKVM releases page", + "advanced_version_update_helper": "Find available versions on the", + "advanced_version_update_system_label": "System Version", + "advanced_version_update_target_app": "App only", + "advanced_version_update_target_both": "Both App and System", + "advanced_version_update_target_label": "What to update", + "advanced_version_update_target_system": "System only", + "advanced_version_update_title": "Update to Specific Version", + "advanced_error_version_update": "Failed to initiate version update: {error}", + "general_update_downgrade_available_description": "A downgrade is available to revert to a previous version.", + "general_update_downgrade_available_title": "Downgrade Available", + "general_update_downgrade_button": "Downgrade Now", + "general_update_keep_current_button": "Keep Current Version", + "advanced_version_update_reset_config_description": "Reset configuration after the update", + "advanced_version_update_reset_config_label": "Reset configuration" } diff --git a/ui/src/routes/devices.$id.settings.general.update.tsx b/ui/src/routes/devices.$id.settings.general.update.tsx index 0633aec2..e9afa67e 100644 --- a/ui/src/routes/devices.$id.settings.general.update.tsx +++ b/ui/src/routes/devices.$id.settings.general.update.tsx @@ -23,6 +23,7 @@ export default function SettingsGeneralUpdateRoute() { const downgrade = useMemo(() => searchParams.get("downgrade") === "true", [searchParams]); const updateComponents = useMemo(() => searchParams.get("components") || "", [searchParams]); + const resetConfig = useMemo(() => searchParams.get("resetConfig") === "true", [searchParams]); const onConfirmUpdate = useCallback(() => { send("tryUpdate", {}); @@ -37,11 +38,10 @@ export default function SettingsGeneralUpdateRoute() { }, includePreRelease: true, checkOnly: false, - // TODO: implement this - resetConfig: false, + resetConfig: resetConfig, }); setModalView("updating"); - }, [send, setModalView, updateComponents]); + }, [send, setModalView, updateComponents, resetConfig]); useEffect(() => { if (otaState.updating) {