From f1837578a826e77cc3e0a0645e6e319f2a5f3372 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Wed, 4 May 2022 12:02:36 -0700 Subject: [PATCH] minor: unable to view all the workflow versions (#446) * fix: unable to view all the workflow versions Signed-off-by: Carina Ursu * chore: cleanup Signed-off-by: Carina Ursu Co-authored-by: Carina Ursu --- .../ReactFlow/transformDAGToReactFlowV2.tsx | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/zapp/console/src/components/flytegraph/ReactFlow/transformDAGToReactFlowV2.tsx b/packages/zapp/console/src/components/flytegraph/ReactFlow/transformDAGToReactFlowV2.tsx index 1da17bdc7..d3b11a33b 100644 --- a/packages/zapp/console/src/components/flytegraph/ReactFlow/transformDAGToReactFlowV2.tsx +++ b/packages/zapp/console/src/components/flytegraph/ReactFlow/transformDAGToReactFlowV2.tsx @@ -50,7 +50,7 @@ interface BuildDataProps { rootParentNode: dNode; currentNestedView: string[]; } -export const buildReactFlowDataProps = (props: BuildDataProps) => { +const buildReactFlowDataProps = (props: BuildDataProps) => { const { node, nodeExecutionsById, @@ -61,13 +61,13 @@ export const buildReactFlowDataProps = (props: BuildDataProps) => { currentNestedView, } = props; - const taskType = node.value?.template ? node.value.template.type : null; - const displayName = node.name; + const { value: nodeValue, name: displayName, scopedId, type: nodeType } = node; + const taskType = nodeValue?.template?.type ?? null; const mapNodeExecutionStatus = () => { if (nodeExecutionsById) { - if (nodeExecutionsById[node.scopedId]) { - return nodeExecutionsById[node.scopedId].closure.phase as NodeExecutionPhase; + if (nodeExecutionsById[scopedId]) { + return nodeExecutionsById[scopedId].closure.phase as NodeExecutionPhase; } else { return NodeExecutionPhase.SKIPPED; } @@ -77,34 +77,35 @@ export const buildReactFlowDataProps = (props: BuildDataProps) => { }; const nodeExecutionStatus = mapNodeExecutionStatus(); + // nodeExecutionsById null check is required as on first render it can be undefined const cacheStatus: CatalogCacheStatus = - nodeExecutionsById[node.scopedId]?.closure.taskNodeMetadata?.cacheStatus ?? + nodeExecutionsById?.[scopedId]?.closure.taskNodeMetadata?.cacheStatus ?? CatalogCacheStatus.CACHE_DISABLED; const dataProps = { nodeExecutionStatus, text: displayName, handles: [], - nodeType: node.type, - scopedId: node.scopedId, + nodeType, + scopedId, taskType, cacheStatus, onNodeSelectionChanged: () => { if (onNodeSelectionChanged) { - onNodeSelectionChanged([node.scopedId]); + onNodeSelectionChanged([scopedId]); } }, onAddNestedView: () => { onAddNestedView({ parent: rootParentNode.scopedId, - view: node.scopedId, + view: scopedId, }); }, onRemoveNestedView, }; for (const rootParentId in currentNestedView) { - if (node.scopedId === rootParentId) { + if (scopedId === rootParentId) { dataProps['currentNestedView'] = currentNestedView[rootParentId]; } } @@ -119,7 +120,7 @@ interface BuildNodeProps { parentNode?: dNode; typeOverride?: dTypes; } -export const buildReactFlowNode = ({ +const buildReactFlowNode = ({ node, dataProps, rootParentNode, @@ -214,7 +215,7 @@ export const buildGraphMapping = (props): ReactFlowGraphMapping => { const parse = (props: ParseProps) => { const { contextNode, contextParent, rootParentNode, nodeDataProps } = props; let context: ReactFlowGraph | null = null; - contextNode.nodes.map((node: dNode) => { + contextNode.nodes.filter(n => !!n).map((node: dNode) => { /* Case: node has children => recurse */ if (nodeHasChildren(node)) { if (rootParentNode) {