From 05b7e1cf927f67c9b97c21843a0b530a3b76a5cb Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Fri, 10 Oct 2025 14:36:40 +0200 Subject: [PATCH] feat: Add confirmation modal for script installation and server sorting - Add confirmation modal when only one server is saved - Show script name and server details in confirmation view - Auto-select single server but require user confirmation - Preserve existing behavior for multiple servers (no pre-selection) - Sort servers alphabetically by name in all components - Fix ESLint issues with nullish coalescing operators Fixes: PROX2 now appears before PROX3 in server lists --- src/app/_components/ColorCodedDropdown.tsx | 4 +- src/app/_components/ExecutionModeModal.tsx | 171 +++++++++++++-------- src/app/_components/SettingsModal.tsx | 6 +- 3 files changed, 118 insertions(+), 63 deletions(-) diff --git a/src/app/_components/ColorCodedDropdown.tsx b/src/app/_components/ColorCodedDropdown.tsx index 39b9548..1f2eea3 100644 --- a/src/app/_components/ColorCodedDropdown.tsx +++ b/src/app/_components/ColorCodedDropdown.tsx @@ -94,7 +94,9 @@ export function ColorCodedDropdown({ {/* Server Options */} - {servers.map((server) => ( + {servers + .sort((a, b) => (a.name ?? '').localeCompare(b.name ?? '')) + .map((server) => ( + + ) : servers.length === 1 ? ( + /* Single Server Confirmation View */ +
+
+

+ Install Script Confirmation +

+

+ Do you want to install "{scriptName}" on the following server? +

+
+ +
+
+
+
+
+
+

+ {selectedServer?.name ?? 'Unnamed Server'} +

+

+ {selectedServer?.ip} +

+
+
+
+ + {/* Action Buttons */} +
+ + +
+
+ ) : ( + /* Multiple Servers Selection View */ +
+
+

+ Select server to execute "{scriptName}" +

+
+ + {/* Server Selection */} +
+ +
- ) : servers.length === 0 ? ( -
-

No servers configured

-

Add servers in Settings to execute scripts

+ + {/* Action Buttons */} +
+
- ) : ( - - )} -
- - {/* Action Buttons */} -
- - -
+
+ )} diff --git a/src/app/_components/SettingsModal.tsx b/src/app/_components/SettingsModal.tsx index f94a789..4afd746 100644 --- a/src/app/_components/SettingsModal.tsx +++ b/src/app/_components/SettingsModal.tsx @@ -31,7 +31,11 @@ export function SettingsModal({ isOpen, onClose }: SettingsModalProps) { throw new Error('Failed to fetch servers'); } const data = await response.json(); - setServers(data as Server[]); + // Sort servers by name alphabetically + const sortedServers = (data as Server[]).sort((a, b) => + (a.name ?? '').localeCompare(b.name ?? '') + ); + setServers(sortedServers); } catch (err) { setError(err instanceof Error ? err.message : 'An error occurred'); } finally {