Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jenny-s51 committed Jun 6, 2024
1 parent e31e593 commit bc04399
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions frontend/src/concepts/topology/PipelineVisualizationSurface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -69,32 +69,42 @@ const PipelineVisualizationSurface: React.FC<PipelineVisualizationSurfaceProps>
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,
}));

// 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);
Expand Down

0 comments on commit bc04399

Please sign in to comment.