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 {