fix: workflow restore (#3711)

This commit is contained in:
zxhlyh
2024-04-23 17:02:23 +08:00
committed by GitHub
parent 96160837d2
commit 83caffe000
9 changed files with 654 additions and 318 deletions

View File

@@ -4,6 +4,7 @@ import {
getOutgoers,
} from 'reactflow'
import dagre from 'dagre'
import { v4 as uuid4 } from 'uuid'
import {
cloneDeep,
uniqBy,
@@ -331,3 +332,28 @@ export const getToolCheckParams = (
language,
}
}
export const changeNodesAndEdgesId = (nodes: Node[], edges: Edge[]) => {
const idMap = nodes.reduce((acc, node) => {
acc[node.id] = uuid4()
return acc
}, {} as Record<string, string>)
const newNodes = nodes.map((node) => {
return {
...node,
id: idMap[node.id],
}
})
const newEdges = edges.map((edge) => {
return {
...edge,
source: idMap[edge.source],
target: idMap[edge.target],
}
})
return [newNodes, newEdges] as [Node[], Edge[]]
}