fix: sub iteration would crash page

pull/12372/head
Joel 1 year ago
parent c23fe3b67f
commit 1f128729f4

@ -1,6 +1,16 @@
import { BlockEnum } from '@/app/components/workflow/types' import { BlockEnum } from '@/app/components/workflow/types'
import type { NodeTracing } from '@/types/workflow' import type { NodeTracing } from '@/types/workflow'
function printNodeStructure(node: NodeTracing, level: number) {
const indent = ' '.repeat(level)
console.log(`${indent}${node.title}`)
if (node.parallelDetail?.children) {
node.parallelDetail.children.forEach((child) => {
printNodeStructure(child, level + 1)
})
}
}
function addTitle({ function addTitle({
list, level, parallelNumRecord, list, level, parallelNumRecord,
}: { }: {
@ -52,6 +62,7 @@ function addTitle({
// list => group by parallel_id(parallel tree). // list => group by parallel_id(parallel tree).
const format = (list: NodeTracing[], t: any): NodeTracing[] => { const format = (list: NodeTracing[], t: any): NodeTracing[] => {
// console.log(list)
const result: NodeTracing[] = [...list] const result: NodeTracing[] = [...list]
const parallelFirstNodeMap: Record<string, string> = {} const parallelFirstNodeMap: Record<string, string> = {}
// list to tree by parent_parallel_start_node_id and parallel_start_node_id // list to tree by parent_parallel_start_node_id and parallel_start_node_id
@ -65,7 +76,7 @@ const format = (list: NodeTracing[], t: any): NodeTracing[] => {
const isParallelStartNode = !parallelFirstNodeMap[parallel_id] const isParallelStartNode = !parallelFirstNodeMap[parallel_id]
if (isParallelStartNode) { if (isParallelStartNode) {
const selfNode = { ...node } const selfNode = { ...node, parallelDetail: undefined }
node.parallelDetail = { node.parallelDetail = {
isParallelStartNode: true, isParallelStartNode: true,
children: [selfNode], children: [selfNode],
@ -86,6 +97,7 @@ const format = (list: NodeTracing[], t: any): NodeTracing[] => {
if (parentParallelStartNode!.parallelDetail.children) if (parentParallelStartNode!.parallelDetail.children)
parentParallelStartNode!.parallelDetail.children.push(node) parentParallelStartNode!.parallelDetail.children.push(node)
} }
return
} }
// append to parallel start node // append to parallel start node
@ -112,6 +124,11 @@ const format = (list: NodeTracing[], t: any): NodeTracing[] => {
return true return true
}) })
// print node structure for debug
filteredInParallelSubNodes.forEach((node) => {
printNodeStructure(node, 0)
})
const parallelNumRecord: Record<string, number> = { const parallelNumRecord: Record<string, number> = {
num: 0, num: 0,
} }

Loading…
Cancel
Save