Flow delete offers to delete its runs, history included
DELETE /runs?flow= removes every Run row of the flow but left its flow_run rows, so a deleted flow kept appearing in the history. history=true now drops those too, and the flow delete dialogs (editor and bulk) send it when "Also delete its runs" is ticked.
This commit is contained in:
@@ -31,6 +31,7 @@ import {
|
||||
FlowsService,
|
||||
type MessageSpec,
|
||||
type NodeDef_Input,
|
||||
RunsService,
|
||||
} from "@/client"
|
||||
import { DiscardDraftDialog } from "@/components/Common/Dock"
|
||||
import { useTheme } from "@/components/theme-provider"
|
||||
@@ -790,7 +791,13 @@ function FlowEditorInner({
|
||||
})
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: () => FlowsService.deleteFlow({ name: flowName }),
|
||||
mutationFn: async (withRuns: boolean) => {
|
||||
await FlowsService.deleteFlow({ name: flowName })
|
||||
// After the flow, which is refused while a run is live, so a refusal
|
||||
// leaves both standing.
|
||||
if (withRuns)
|
||||
await RunsService.deleteRuns({ flow: flowName, history: true })
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: flowKeys.all })
|
||||
setFlowPanelOpen(false)
|
||||
@@ -1327,7 +1334,7 @@ function FlowEditorInner({
|
||||
nodeCount={definitions.length}
|
||||
// Confirmed, so it is a finished edit rather than a run of keystrokes.
|
||||
onChange={(next) => commitDoc({ ...next, nodes: definitions }, true)}
|
||||
onDelete={() => deleteMutation.mutate()}
|
||||
onDelete={(withRuns) => deleteMutation.mutate(withRuns)}
|
||||
enabled={detail.enabled ?? true}
|
||||
toggling={enableMutation.isPending}
|
||||
onToggleEnabled={(next) => enableMutation.mutate(next)}
|
||||
|
||||
Reference in New Issue
Block a user