feat(ui): add action buttons to Docker, Git, systemd, and Caddy modules

- Docker table: Restart and Stop buttons per container row (docker_compose_restart / docker_compose_stop)
- Git repos list: Fetch and Pull buttons per repo; Pull disabled when working tree is dirty
- systemd units list: Restart button per unit (systemctl_restart)
- Caddy: Edit link on /caddy page, new /caddy/edit page with textarea + 3-step Validate → Save+Reload flow
- All buttons open ConfirmDialog with exact agent-call preview, then stream output via StreamingTerminal
- Add docker_compose_stop to ops-agent/commands.yml.example

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scrum4Me Agent 2026-05-13 19:14:49 +02:00
parent b74cf3d75f
commit 3781fce1e2
8 changed files with 1019 additions and 2 deletions

View file

@ -3,6 +3,9 @@
import { useCallback, useEffect, useState } from 'react'
import Link from 'next/link'
import { type RepoStatus, parseGitStatus } from '@/lib/parse-git'
import { useFlowRun } from '@/hooks/useFlowRun'
import ConfirmDialog from '@/components/ConfirmDialog'
import StreamingTerminal from '@/components/StreamingTerminal'
interface RepoEntry {
path: string
@ -78,6 +81,13 @@ function statusBadge(status: RepoStatus) {
)
}
type ActionDef = {
commandKey: string
args: string[]
preview: string
title: string
}
type Props = {
initialRepos: RepoEntry[]
}
@ -86,6 +96,8 @@ export default function GitReposList({ initialRepos }: Props) {
const [repos, setRepos] = useState<RepoEntry[]>(initialRepos)
const [refreshing, setRefreshing] = useState(false)
const [lastUpdated, setLastUpdated] = useState<Date>(new Date())
const [pendingAction, setPendingAction] = useState<ActionDef | null>(null)
const flowRun = useFlowRun()
const refresh = useCallback(async () => {
setRefreshing(true)
@ -112,6 +124,12 @@ export default function GitReposList({ initialRepos }: Props) {
return () => clearInterval(id)
}, [refresh])
const handleConfirm = useCallback(() => {
if (!pendingAction) return
flowRun.start(pendingAction.commandKey, pendingAction.args)
setPendingAction(null)
}, [pendingAction, flowRun.start])
return (
<div className="space-y-4">
<div className="flex items-center justify-between">
@ -137,6 +155,7 @@ export default function GitReposList({ initialRepos }: Props) {
<th className="px-4 py-3 text-left font-medium text-muted-foreground">Status</th>
<th className="px-4 py-3 text-left font-medium text-muted-foreground">Ahead</th>
<th className="px-4 py-3 text-left font-medium text-muted-foreground">Path</th>
<th className="px-4 py-3 text-left font-medium text-muted-foreground">Actions</th>
</tr>
</thead>
<tbody>
@ -173,11 +192,69 @@ export default function GitReposList({ initialRepos }: Props) {
)}
</td>
<td className="px-4 py-3 font-mono text-xs text-muted-foreground">{r.path}</td>
<td className="px-4 py-3">
<div className="flex items-center gap-2">
<button
onClick={() =>
setPendingAction({
commandKey: 'git_fetch',
args: [r.path],
preview: `git fetch --quiet\n(in ${r.path})`,
title: `Fetch ${r.name}`,
})
}
disabled={flowRun.status === 'running'}
className="rounded-md border border-border px-2 py-1 text-xs hover:bg-muted/50 disabled:opacity-50 transition-colors"
>
Fetch
</button>
<button
onClick={() =>
setPendingAction({
commandKey: 'git_pull',
args: [r.path],
preview: `git pull --ff-only\n(in ${r.path})`,
title: `Pull ${r.name}`,
})
}
disabled={flowRun.status === 'running' || r.status?.dirty === true}
title={r.status?.dirty ? 'Working tree is dirty — commit or stash changes first' : undefined}
className="rounded-md border border-border px-2 py-1 text-xs hover:bg-muted/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
>
Pull
</button>
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
{flowRun.status !== 'idle' && (
<div className="space-y-2">
<div className="flex items-center justify-between">
<span className="text-sm font-medium text-foreground">Output</span>
{flowRun.status !== 'running' && (
<button
onClick={flowRun.reset}
className="text-xs text-muted-foreground hover:text-foreground transition-colors"
>
Close
</button>
)}
</div>
<StreamingTerminal lines={flowRun.lines} status={flowRun.status} error={flowRun.error} />
</div>
)}
<ConfirmDialog
open={pendingAction !== null}
title={pendingAction?.title ?? ''}
commandPreview={pendingAction?.preview ?? ''}
onConfirm={handleConfirm}
onCancel={() => setPendingAction(null)}
/>
</div>
)
}