import { errorMessage } from "../api/client.js"; import { useDuplicateWorkflow } from "../api/hooks.js"; import { useNotifications } from "../notifications.jsx"; export function DuplicateWorkflowDialog({ source, warnUnsaved, onClose, onDuplicated }) { const { notify } = useNotifications(); const duplicate = useDuplicateWorkflow(); function onSubmit(e) { e.preventDefault(); if (duplicate.isPending) return; duplicate.mutate( { owner: source.owner, file: source.file, destOwner: source.owner, }, { onSuccess: (data) => { notify.success(`Duplicated to ${data.owner}/${data.file}`); onDuplicated?.(data); }, }, ); } return (

Duplicate {source.key}?

A new UUID filename is assigned automatically. The copy starts disabled. HTTP paths are rewritten so triggers do not collide.

{warnUnsaved ? (

The copy uses the last saved YAML, not unsaved edits.

) : null}
{duplicate.isError ? (

{errorMessage(duplicate.error)}

) : null}
); }