Skip to content

Commit

Permalink
Merge pull request #183 from jglick/FlowGraphTable
Browse files Browse the repository at this point in the history
Improved appearance of Pipeline Steps
  • Loading branch information
jglick authored Jul 8, 2022
2 parents dcf4190 + 209087f commit 7ef666c
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
package org.jenkinsci.plugins.workflow.support.visualization.table;

import hudson.Util;
import org.jenkinsci.plugins.workflow.actions.TimingAction;
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.BlockEndNode;
import org.jenkinsci.plugins.workflow.graph.BlockStartNode;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.actions.NotExecutedNodeAction;
import org.jenkinsci.plugins.workflow.graphanalysis.DepthFirstScanner;
import org.jenkinsci.plugins.workflow.visualization.table.FlowNodeViewColumn;
import org.jenkinsci.plugins.workflow.visualization.table.FlowNodeViewColumnDescriptor;

import edu.umd.cs.findbugs.annotations.Nullable;
import hudson.Util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.IdentityHashMap;
Expand All @@ -20,6 +10,19 @@
import java.util.Map;
import java.util.Stack;
import java.util.function.Function;
import org.jenkinsci.plugins.workflow.actions.BodyInvocationAction;
import org.jenkinsci.plugins.workflow.actions.LabelAction;
import org.jenkinsci.plugins.workflow.actions.NotExecutedNodeAction;
import org.jenkinsci.plugins.workflow.actions.TimingAction;
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.AtomNode;
import org.jenkinsci.plugins.workflow.graph.BlockEndNode;
import org.jenkinsci.plugins.workflow.graph.BlockStartNode;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graph.StepNode;
import org.jenkinsci.plugins.workflow.graphanalysis.DepthFirstScanner;
import org.jenkinsci.plugins.workflow.visualization.table.FlowNodeViewColumn;
import org.jenkinsci.plugins.workflow.visualization.table.FlowNodeViewColumnDescriptor;

/**
* Data model behind the tree list view of a flow graph
Expand Down Expand Up @@ -281,7 +284,27 @@ public int getTreeDepth() {
}

public String getDisplayName() {
return node.getDisplayName();
if (node instanceof StepNode && node instanceof AtomNode) {
// TODO make StepAtomNode.effectiveFunctionName into an API
return node.getDisplayFunctionName();
} else if (node instanceof StepNode && node instanceof BlockStartNode) {
if (node.getAction(BodyInvocationAction.class) != null) {
// TODO cannot access StepAtomNode.effectiveFunctionName from here
List<FlowNode> parents = node.getParents();
if (parents.size() == 1) {
FlowNode start = parents.get(0);
if (start instanceof StepNode && start instanceof BlockStartNode && start.getPersistentAction(BodyInvocationAction.class) == null) {
String base = start.getDisplayFunctionName() + " block";
LabelAction a = node.getPersistentAction(LabelAction.class);
return a != null ? base + " (" + a.getDisplayName() + ")" : base;
}
}
} else {
return node.getDisplayFunctionName();
}
}
// Fallback, e.g. FlowStartNode:
return node.getDisplayFunctionName();
}

public boolean isHasStartTime() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<?jelly escape-by-default='true'?>
<!--
~ The MIT License
~
~ Copyright (c) 2013-2014, CloudBees, Inc.
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in
~ all copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
~ THE SOFTWARE.
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:i="jelly:fmt">
<th width="40%">
${column.columnCaption}
</th>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<j:set var="columns" value="${it.columns}"/>
<thead>
<tr>
<th>${%Step}</th>
<th width="50%">${%Step}</th>
<j:forEach var="column" items="${columns}">
<st:include from="${column}" page="columnHeader"/>
</j:forEach>
Expand Down

0 comments on commit 7ef666c

Please sign in to comment.