From bc04399a3e498c1381eb351e874f2da79d0cbc97 Mon Sep 17 00:00:00 2001 From: Jenny <32821331+jenny-s51@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:32:33 -0400 Subject: [PATCH] fix linting issues --- .../topology/PipelineVisualizationSurface.tsx | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/frontend/src/concepts/topology/PipelineVisualizationSurface.tsx b/frontend/src/concepts/topology/PipelineVisualizationSurface.tsx index 638c52c10e..f05528ecbc 100644 --- a/frontend/src/concepts/topology/PipelineVisualizationSurface.tsx +++ b/frontend/src/concepts/topology/PipelineVisualizationSurface.tsx @@ -20,7 +20,7 @@ import { EmptyStateHeader, } from '@patternfly/react-core'; import { ExclamationCircleIcon } from '@patternfly/react-icons'; -import { NODE_HEIGHT, NODE_WIDTH } from "./const"; +import { NODE_HEIGHT, NODE_WIDTH } from './const'; type PipelineVisualizationSurfaceProps = { nodes: PipelineNodeModel[]; @@ -69,13 +69,17 @@ const PipelineVisualizationSurface: React.FC const collapseAllCallback = React.useCallback( (collapseAll: boolean) => { // First, expand/collapse all nodes - collapseAll ? controller.getGraph().collapseAll() : controller.getGraph().expandAll(); + if (collapseAll) { + controller.getGraph().collapseAll(); + } else { + controller.getGraph().expandAll(); + } // We must recreate the model based on what is visible const model = controller.toModel(); // Get all the non-spacer nodes, mark them all visible again - const nodes = model.nodes! - .filter((n) => n.type !== DEFAULT_SPACER_NODE_TYPE) + const nonSpacerNodes = model + .nodes!.filter((n) => n.type !== DEFAULT_SPACER_NODE_TYPE) .map((n) => ({ ...n, visible: true, @@ -83,18 +87,24 @@ const PipelineVisualizationSurface: React.FC // If collapsing, set the size of the collapsed group nodes if (collapseAll) { - nodes.forEach((node) => { + nonSpacerNodes.forEach((node) => { + const newNode = node; if (node.group && node.collapsed) { - node.width = NODE_WIDTH; - node.height = NODE_HEIGHT; + newNode.width = NODE_WIDTH; + newNode.height = NODE_HEIGHT; } }); } // Determine the new set of nodes, including the spacer nodes - const pipelineNodes = addSpacerNodes(nodes); + const pipelineNodes = addSpacerNodes(nonSpacerNodes); // Determine the new edges - const edges = getEdgesFromNodes(pipelineNodes, DEFAULT_SPACER_NODE_TYPE, DEFAULT_EDGE_TYPE, DEFAULT_EDGE_TYPE); + const edges = getEdgesFromNodes( + pipelineNodes, + DEFAULT_SPACER_NODE_TYPE, + DEFAULT_EDGE_TYPE, + DEFAULT_EDGE_TYPE, + ); // Apply the new model and run the layout controller.fromModel({ nodes: pipelineNodes, edges }, true);