From c3798eaca6a1bac0d8f5a19bbf8ac2a926d101d1 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Mon, 2 May 2022 08:25:50 -0700 Subject: [PATCH 1/2] fix: unable to view all the workflow versions Signed-off-by: Carina Ursu --- .../ReactFlow/transformDAGToReactFlowV2.tsx | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 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..76720ed97 100644 --- a/packages/zapp/console/src/components/flytegraph/ReactFlow/transformDAGToReactFlowV2.tsx +++ b/packages/zapp/console/src/components/flytegraph/ReactFlow/transformDAGToReactFlowV2.tsx @@ -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; } @@ -78,33 +78,33 @@ export const buildReactFlowDataProps = (props: BuildDataProps) => { const nodeExecutionStatus = mapNodeExecutionStatus(); 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, + parent: rootParentNode?.scopedId, + view: scopedId, }); }, onRemoveNestedView, }; for (const rootParentId in currentNestedView) { - if (node.scopedId === rootParentId) { + if (scopedId === rootParentId) { dataProps['currentNestedView'] = currentNestedView[rootParentId]; } } From ad9d9b48711807ba628be70c1cb15c5f3ec450d8 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Wed, 4 May 2022 11:48:24 -0700 Subject: [PATCH 2/2] chore: cleanup Signed-off-by: Carina Ursu --- .../ReactFlow/transformDAGToReactFlowV2.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/zapp/console/src/components/flytegraph/ReactFlow/transformDAGToReactFlowV2.tsx b/packages/zapp/console/src/components/flytegraph/ReactFlow/transformDAGToReactFlowV2.tsx index 76720ed97..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,12 +61,12 @@ export const buildReactFlowDataProps = (props: BuildDataProps) => { currentNestedView, } = props; - const { value: nodeValue, name: displayName, scopedId, type: nodeType } = node || {}; + const { value: nodeValue, name: displayName, scopedId, type: nodeType } = node; const taskType = nodeValue?.template?.type ?? null; const mapNodeExecutionStatus = () => { if (nodeExecutionsById) { - if (nodeExecutionsById?.[scopedId]) { + if (nodeExecutionsById[scopedId]) { return nodeExecutionsById[scopedId].closure.phase as NodeExecutionPhase; } else { return NodeExecutionPhase.SKIPPED; @@ -77,8 +77,9 @@ 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?.[scopedId]?.closure?.taskNodeMetadata?.cacheStatus ?? + nodeExecutionsById?.[scopedId]?.closure.taskNodeMetadata?.cacheStatus ?? CatalogCacheStatus.CACHE_DISABLED; const dataProps = { @@ -96,7 +97,7 @@ export const buildReactFlowDataProps = (props: BuildDataProps) => { }, onAddNestedView: () => { onAddNestedView({ - parent: rootParentNode?.scopedId, + parent: rootParentNode.scopedId, view: scopedId, }); }, @@ -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) {