From 7315f81304362d4f3ffbe2de66c4d6b30c3f8bdb Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Tue, 14 Oct 2025 16:21:02 +0200 Subject: [PATCH] refactor: optimize UI button layout and fix dependency loop - Add Open UI button next to IP:Port in installed scripts table - Move Re-detect button to Actions dropdown for better space usage - Fix dependency array loop in fetchContainerStatuses useCallback - Hide buttons for stopped containers to prevent invalid actions - Enhance auto-detect success message with LXC ID and hostname - Improve font consistency by removing monospace from IP:Port text - Optimize screen real estate with cleaner, more scannable layout --- src/app/_components/InstalledScriptsTab.tsx | 31 ++++++++++++--------- src/server/api/routers/installedScripts.ts | 6 ++-- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/app/_components/InstalledScriptsTab.tsx b/src/app/_components/InstalledScriptsTab.tsx index 8aca574..f53e04f 100644 --- a/src/app/_components/InstalledScriptsTab.tsx +++ b/src/app/_components/InstalledScriptsTab.tsx @@ -377,7 +377,7 @@ export function InstalledScriptsTab() { containerStatusMutation.mutate({ serverIds }); } }, 500); - }, [containerStatusMutation]); + }, []); // Run cleanup when component mounts and scripts are loaded (only once) useEffect(() => { @@ -1365,21 +1365,17 @@ export function InstalledScriptsTab() { ) : ( script.web_ui_ip ? ( -
- - {script.container_id && script.execution_mode === 'ssh' && ( + + {containerStatuses.get(script.id) === 'running' && ( )}
@@ -1487,6 +1483,15 @@ export function InstalledScriptsTab() { Open UI )} + {script.container_id && script.execution_mode === 'ssh' && script.web_ui_ip && ( + handleAutoDetectWebUI(script)} + disabled={autoDetectWebUIMutation.isPending || containerStatuses.get(script.id) === 'stopped'} + className="text-blue-300 hover:text-blue-200 hover:bg-blue-900/20 focus:bg-blue-900/20" + > + {autoDetectWebUIMutation.isPending ? 'Re-detect...' : 'Re-detect IP/Port'} + + )} {script.container_id && script.execution_mode === 'ssh' && ( <> diff --git a/src/server/api/routers/installedScripts.ts b/src/server/api/routers/installedScripts.ts index 3a25704..15407b3 100644 --- a/src/server/api/routers/installedScripts.ts +++ b/src/server/api/routers/installedScripts.ts @@ -1137,9 +1137,11 @@ export const installedScriptsRouter = createTRPCRouter({ console.log('✅ Successfully updated database'); return { success: true, - message: `Successfully detected IP: ${detectedIp}:${detectedPort}`, + message: `Successfully detected IP: ${detectedIp}:${detectedPort} for LXC ${scriptData.container_id} on ${(server as any).name}`, detectedIp, - detectedPort: detectedPort + detectedPort: detectedPort, + containerId: scriptData.container_id, + serverName: (server as any).name }; } catch (error) { console.error('Error in autoDetectWebUI:', error);