Skip to content

Commit 5b11a6b

Browse files
refactor: optimize UI button layout and fix dependency loop (#149)
- 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
1 parent 67ac02e commit 5b11a6b

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

src/app/_components/InstalledScriptsTab.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ export function InstalledScriptsTab() {
377377
containerStatusMutation.mutate({ serverIds });
378378
}
379379
}, 500);
380-
}, [containerStatusMutation]);
380+
}, []);
381381

382382
// Run cleanup when component mounts and scripts are loaded (only once)
383383
useEffect(() => {
@@ -1365,21 +1365,17 @@ export function InstalledScriptsTab() {
13651365
</div>
13661366
) : (
13671367
script.web_ui_ip ? (
1368-
<div className="flex items-center justify-between w-full">
1369-
<button
1370-
onClick={() => handleOpenWebUI(script)}
1371-
className="text-sm font-mono text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300 hover:underline flex-shrink-0"
1372-
>
1368+
<div className="flex items-center space-x-3">
1369+
<span className="text-sm text-foreground">
13731370
{script.web_ui_ip}:{script.web_ui_port ?? 80}
1374-
</button>
1375-
{script.container_id && script.execution_mode === 'ssh' && (
1371+
</span>
1372+
{containerStatuses.get(script.id) === 'running' && (
13761373
<button
1377-
onClick={() => handleAutoDetectWebUI(script)}
1378-
disabled={autoDetectWebUIMutation.isPending}
1379-
className="text-xs px-2 py-1 bg-blue-900 hover:bg-blue-800 text-blue-300 border border-blue-700 rounded disabled:opacity-50 transition-colors flex-shrink-0 ml-2"
1380-
title="Re-detect IP and port"
1374+
onClick={() => handleOpenWebUI(script)}
1375+
className="text-xs px-2 py-1 bg-blue-900/20 hover:bg-blue-900/30 border border-blue-700/50 text-blue-300 hover:text-blue-200 hover:border-blue-600/60 transition-all duration-200 hover:scale-105 hover:shadow-md rounded disabled:opacity-50 flex-shrink-0"
1376+
title="Open Web UI"
13811377
>
1382-
{autoDetectWebUIMutation.isPending ? '...' : 'Re-detect'}
1378+
Open UI
13831379
</button>
13841380
)}
13851381
</div>
@@ -1487,6 +1483,15 @@ export function InstalledScriptsTab() {
14871483
Open UI
14881484
</DropdownMenuItem>
14891485
)}
1486+
{script.container_id && script.execution_mode === 'ssh' && script.web_ui_ip && (
1487+
<DropdownMenuItem
1488+
onClick={() => handleAutoDetectWebUI(script)}
1489+
disabled={autoDetectWebUIMutation.isPending || containerStatuses.get(script.id) === 'stopped'}
1490+
className="text-blue-300 hover:text-blue-200 hover:bg-blue-900/20 focus:bg-blue-900/20"
1491+
>
1492+
{autoDetectWebUIMutation.isPending ? 'Re-detect...' : 'Re-detect IP/Port'}
1493+
</DropdownMenuItem>
1494+
)}
14901495
{script.container_id && script.execution_mode === 'ssh' && (
14911496
<>
14921497
<DropdownMenuSeparator className="bg-gray-700" />

src/server/api/routers/installedScripts.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,9 +1137,11 @@ export const installedScriptsRouter = createTRPCRouter({
11371137
console.log('✅ Successfully updated database');
11381138
return {
11391139
success: true,
1140-
message: `Successfully detected IP: ${detectedIp}:${detectedPort}`,
1140+
message: `Successfully detected IP: ${detectedIp}:${detectedPort} for LXC ${scriptData.container_id} on ${(server as any).name}`,
11411141
detectedIp,
1142-
detectedPort: detectedPort
1142+
detectedPort: detectedPort,
1143+
containerId: scriptData.container_id,
1144+
serverName: (server as any).name
11431145
};
11441146
} catch (error) {
11451147
console.error('Error in autoDetectWebUI:', error);

0 commit comments

Comments
 (0)