diff --git a/ui/src/app/shared/components/graph/graph-panel.tsx b/ui/src/app/shared/components/graph/graph-panel.tsx index 32e6c56ef148..d22781244d84 100644 --- a/ui/src/app/shared/components/graph/graph-panel.tsx +++ b/ui/src/app/shared/components/graph/graph-panel.tsx @@ -247,7 +247,9 @@ export function GraphPanel(props: Props) { .filter(([n, label]) => label.x !== null && visible(n)) .map(([n, label]) => ( - {n} + + {n} ({label.label}) + + + props.onChange({ + ...workflowDagRenderOptions(), + showInvokingTemplateName: !workflowDagRenderOptions().showInvokingTemplateName + }) + } + className={workflowDagRenderOptions().showInvokingTemplateName ? 'active' : ''} + title='Show invoking template name'> + + + + props.onChange({ + ...workflowDagRenderOptions(), + showTemplateRefsGrouping: !workflowDagRenderOptions().showTemplateRefsGrouping + }) + } + className={workflowDagRenderOptions().showTemplateRefsGrouping ? 'active' : ''} + title='Group by templateRefs'> + + ); } diff --git a/ui/src/app/workflows/components/workflow-dag/workflow-dag.tsx b/ui/src/app/workflows/components/workflow-dag/workflow-dag.tsx index 8160ca34c79d..b5a9b1c18c54 100644 --- a/ui/src/app/workflows/components/workflow-dag/workflow-dag.tsx +++ b/ui/src/app/workflows/components/workflow-dag/workflow-dag.tsx @@ -13,6 +13,8 @@ import {WorkflowDagRenderOptionsPanel} from './workflow-dag-render-options-panel export interface WorkflowDagRenderOptions { expandNodes: Set; showArtifacts: boolean; + showInvokingTemplateName: boolean; + showTemplateRefsGrouping: boolean; } interface WorkflowDagProps { @@ -36,18 +38,6 @@ function getNodeLabelTemplateName(n: NodeStatus): string { return n.templateName || (n.templateRef && n.templateRef.template + '/' + n.templateRef.name) || 'no template'; } -function nodeLabel(n: NodeStatus) { - const phase = n.type === 'Suspend' && n.phase === 'Running' ? 'Suspended' : n.phase; - return { - label: shortNodeName(n), - genre: n.type, - icon: icons[phase] || icons.Pending, - progress: phase === 'Running' && progress(n), - classNames: phase, - tags: new Set([getNodeLabelTemplateName(n)]) - }; -} - const classNames = (() => { const v: {[label: string]: boolean} = { Artifact: true, @@ -65,7 +55,9 @@ export class WorkflowDag extends React.Component node.boundaryID === nodeId && genres[node.type]) + .map(node => node.id); + } + return allNodes[nodeId].children.filter(child => allNodes[child]); }; const pushChildren = (nodeId: string, isExpanded: boolean, queue: PrepareNode[]): void => { @@ -163,14 +182,22 @@ export class WorkflowDag extends React.Component - queue.push({ - nodeName: child, - parent: nodeId, + // Node will not be collapsed if no templateRefs are present + children.map(child => { + let parentNodeId = nodeId; + let nodeName = child; + + if (allNodes[nodeId].templateRef && this.state.showTemplateRefsGrouping) { + parentNodeId = allNodes[child].boundaryID; + nodeName = !isExpanded ? getCollapsedNodeName(nodeId, `template:${allNodes[nodeId].templateRef.name}`, allNodes[child].type) : child; + } + + return queue.push({ + nodeName, + parent: parentNodeId, children: getChildren(child) - }) - ); + }); + }); } }; @@ -201,7 +228,7 @@ export class WorkflowDag extends React.Component { const exitHandler = allNodes[onExitHandlerNodeId.id]; - nodes.set(onExitHandlerNodeId.id, nodeLabel(exitHandler)); + nodes.set(onExitHandlerNodeId.id, this.nodeLabel(exitHandler)); if (nodes.has(v)) { edges.set({v, w: onExitHandlerNodeId.id}, {}); }