Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix children is not defined error #3950

Merged
merged 1 commit into from
Sep 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions ui/src/app/workflows/components/workflow-dag/workflow-dag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@ export class WorkflowDag extends React.Component<WorkflowDagProps, WorkflowDagRe
}

const allNodes = this.props.nodes;
const getChildren = (nodeId: string): string[] => {
if (!allNodes[nodeId] || !allNodes[nodeId].children) {
return [];
}
return allNodes[nodeId].children;
};
const pushChildren = (nodeId: string, children: string[], isExpanded: boolean): void => {
if (!children) {
return;
Expand All @@ -306,7 +312,7 @@ export class WorkflowDag extends React.Component<WorkflowDagProps, WorkflowDagRe
queue.push({
nodeName: children[0],
parent: nodeId,
children: allNodes[children[0]].children
children: getChildren(children[0])
});
const newChildren: string[] = children
.slice(1, children.length - 1)
Expand All @@ -320,15 +326,15 @@ export class WorkflowDag extends React.Component<WorkflowDagProps, WorkflowDagRe
queue.push({
nodeName: children[children.length - 1],
parent: nodeId,
children: allNodes[children[children.length - 1]].children
children: getChildren(children[children.length - 1])
});
} else {
// Node will not be collapsed
children.map(child =>
queue.push({
nodeName: child,
parent: nodeId,
children: allNodes[child].children
children: getChildren(child)
})
);
}
Expand All @@ -337,7 +343,7 @@ export class WorkflowDag extends React.Component<WorkflowDagProps, WorkflowDagRe
const root: PrepareNode = {
nodeName: this.props.workflowName,
parent: '',
children: this.props.nodes[this.props.workflowName].children
children: getChildren(this.props.workflowName)
};

const queue: PrepareNode[] = [root];
Expand Down