Skip to content

Commit 7eb6834

Browse files
committed
allow to delete RFE Workflow
Signed-off-by: sallyom <[email protected]>
1 parent afadcbe commit 7eb6834

File tree

1 file changed

+32
-17
lines changed
  • components/frontend/src/app/projects/[name]/rfe/[id]

1 file changed

+32
-17
lines changed

components/frontend/src/app/projects/[name]/rfe/[id]/page.tsx

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { formatDistanceToNow } from "date-fns";
1212
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
1313
import { AgenticSession, CreateAgenticSessionRequest, RFEWorkflow, WorkflowPhase } from "@/types/agentic-session";
1414
import { WORKFLOW_PHASE_LABELS } from "@/lib/agents";
15-
import { ArrowLeft, Play, Loader2, FolderTree, Plus, Square } from "lucide-react";
15+
import { ArrowLeft, Play, Loader2, FolderTree, Plus, Trash2 } from "lucide-react";
1616
import { Upload, CheckCircle2 } from "lucide-react";
1717
import { FileTree, type FileTreeNode } from "@/components/file-tree";
1818

@@ -37,6 +37,7 @@ export default function ProjectRFEDetailPage() {
3737

3838
const [specBaseRelPath, setSpecBaseRelPath] = useState<string>("specs");
3939
const [publishingPhase, setPublishingPhase] = useState<WorkflowPhase | null>(null);
40+
const [deleting, setDeleting] = useState<boolean>(false);
4041

4142
const [rfeDoc, setRfeDoc] = useState<{ exists: boolean; content: string }>({ exists: false, content: "" });
4243
const [firstFeaturePath, setFirstFeaturePath] = useState<string>("");
@@ -279,6 +280,24 @@ export default function ProjectRFEDetailPage() {
279280
}
280281
}, [project, id]);
281282

283+
const deleteWorkflow = useCallback(async () => {
284+
if (!confirm('Are you sure you want to delete this RFE workflow? This action cannot be undone.')) {
285+
return;
286+
}
287+
try {
288+
setDeleting(true);
289+
const resp = await fetch(`${getApiUrl()}/projects/${encodeURIComponent(project)}/rfe-workflows/${encodeURIComponent(id)}`, {
290+
method: 'DELETE',
291+
});
292+
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
293+
// Navigate back to RFE list after successful deletion
294+
window.location.href = `/projects/${encodeURIComponent(project)}/rfe`;
295+
} catch (e) {
296+
setError(e instanceof Error ? e.message : 'Failed to delete workflow');
297+
} finally {
298+
setDeleting(false);
299+
}
300+
}, [project, id]);
282301

283302
if (loading) return <div className="container mx-auto py-8">Loading…</div>;
284303
if (error || !workflow) return (
@@ -336,6 +355,18 @@ export default function ProjectRFEDetailPage() {
336355
<p className="text-muted-foreground mt-1">{workflow.description}</p>
337356
</div>
338357
</div>
358+
<Button
359+
variant="destructive"
360+
size="sm"
361+
onClick={deleteWorkflow}
362+
disabled={deleting}
363+
>
364+
{deleting ? (
365+
<><Loader2 className="mr-2 h-4 w-4 animate-spin" />Deleting…</>
366+
) : (
367+
<><Trash2 className="mr-2 h-4 w-4" />Delete Workflow</>
368+
)}
369+
</Button>
339370
</div>
340371

341372
<div className="grid gap-6 md:grid-cols-4">
@@ -524,21 +555,6 @@ export default function ProjectRFEDetailPage() {
524555
)
525556
)
526557
: (
527-
sessionForPhase?.status?.phase === "Running" ? (
528-
<Button size="sm" variant="destructive" onClick={async () => {
529-
try {
530-
const resp = await fetch(`/api/projects/${encodeURIComponent(project)}/agentic-sessions/${encodeURIComponent(sessionForPhase.metadata.name)}/stop`, {
531-
method: "POST"
532-
});
533-
if (!resp.ok) throw new Error(`Failed to stop session: HTTP ${resp.status}`);
534-
await loadSessions();
535-
} catch (e) {
536-
setError(e instanceof Error ? e.message : "Failed to stop session");
537-
}
538-
}}>
539-
<Square className="mr-2 h-4 w-4" />Stop
540-
</Button>
541-
) : (
542558
<Button size="sm" onClick={async () => {
543559
try {
544560
setStartingPhase(phase);
@@ -582,7 +598,6 @@ export default function ProjectRFEDetailPage() {
582598
}} disabled={startingPhase === phase || !prerequisitesMet}>
583599
{startingPhase === phase ? (<><Loader2 className="mr-2 h-4 w-4 animate-spin" />Starting…</>) : (<><Play className="mr-2 h-4 w-4" />Generate</>)}
584600
</Button>
585-
)
586601
)
587602
)}
588603
{exists && phase !== "ideate" && (

0 commit comments

Comments
 (0)