import { useState } from "react"; import { Link, useNavigate } from "react-router-dom"; import { LuArrowLeft, LuRotateCcw, LuTrash2 } from "react-icons/lu"; import { errorMessage } from "../api/client.js"; import { usePurgeWorkflowTrash, useRestoreWorkflowTrash, useWorkflowTrash, } from "../api/hooks.js"; import { ConfirmDialog } from "../components/ConfirmDialog.jsx"; import { formatTime } from "../lib/format.jsx"; import { useNotifications } from "../notifications.jsx"; function formatAge(ms) { if (ms == null || ms < 0) return "—"; const mins = Math.floor(ms / 60_000); if (mins < 60) return `${mins}m ago`; const hours = Math.floor(mins / 60); if (hours < 48) return `${hours}h ago`; const days = Math.floor(hours / 24); return `${days}d ago`; } export function WorkflowTrashPage() { const navigate = useNavigate(); const { notify } = useNotifications(); const { data: items = [], isLoading } = useWorkflowTrash(); const restore = useRestoreWorkflowTrash(); const purge = usePurgeWorkflowTrash(); const [confirmPurge, setConfirmPurge] = useState(null); return (

Workflow trash

Deleted workflows are kept for 7 days. Restore to bring them back, or delete permanently to remove the file and revision history.

{restore.isError ? (

{errorMessage(restore.error)}

) : null} {purge.isError ? (

{errorMessage(purge.error)}

) : null} {isLoading ? ( ) : !items.length ? (

Trash is empty.

) : (
{items.map((item) => ( ))}
Name File Owner Deleted Age Purge in
{item.name ?? "—"} {item.file} {item.owner} {formatTime(item.deleted_at)} {formatAge(item.age_ms)} {item.days_until_purge <= 0 ? ( soon ) : ( `${item.days_until_purge}d` )}
)} setConfirmPurge(null)} onConfirm={() => purge.mutate(confirmPurge.id, { onSuccess: () => { notify.success("Permanently deleted"); setConfirmPurge(null); }, }) } />
); }