fix: workflow restore (#3711)
This commit is contained in:
@@ -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[]]
|
||||
}
|
||||
|
Reference in New Issue
Block a user