Skip to content
New issue

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

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

Already on GitHub? # to your account

[JENKINS-74868] Use new build status symbols in multi branch projects #10106

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
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
67 changes: 38 additions & 29 deletions core/src/main/resources/lib/hudson/ballColorTd.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<st:documentation>
Display the ball in a TD.
<st:attribute name="it" type="hudson.model.BallColor">
Color of the ball or null to skip drawing.
Display the build status icon in a table cell.
<st:attribute name="it" type="hudson.model.StatusIcon">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in reality what is passed is not a ballcolor in many cases but actually a status icon

Icon to be displayed.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

balls are not displayed anymore, small cleanup

</st:attribute>
<st:attribute name="iconSizeClass">
Specifies the size of the icon. If unspecified, it inherits from
Expand Down Expand Up @@ -56,33 +56,42 @@ THE SOFTWARE.
</j:choose>
</j:if>

<j:choose>
<j:when test="${iconClassName != null}">
<l:icon class="${iconClassName} ${subIconSizeClass}" alt="${it.description}" tooltip="${it.description}" />
</j:when>
<j:otherwise>
<!-- "it" is not a hudson.model.BallColor. Let's try figure out the icon from its URL. -->
<j:set var="iconUrl" value="${it.getImageOf(iconSize)}"/>
<j:if test="${iconUrl.startsWith(imagesURL)}">
<!-- Normalize the icon URL -->
<j:set var="iconUrl" value="${iconUrl.substring(imagesURL.length() + 1)}"/>
</j:if>
<!-- if its actually a BallColor then use the appropriate build symbol -->
<j:if test="${attrs.it.baseColor != null}">
<l:icon src="symbol-status-${attrs.it.iconName}" class="${subIconSizeClass}" alt="${it.description}" tooltip="${it.description}" />
</j:if>

<j:if test="${attrs.it.baseColor == null}">
<j:choose>
<j:when test="${iconClassName != null}">
<l:icon class="${iconClassName} ${subIconSizeClass}" alt="${it.description}" tooltip="${it.description}"/>
</j:when>
<j:otherwise>
<!-- "it" is not a hudson.model.BallColor. Let's try figure out the icon from its URL. -->
<j:set var="iconUrl" value="${it.getImageOf(iconSize)}"/>
<j:if test="${iconUrl.startsWith(imagesURL)}">
<!-- Normalize the icon URL -->
<j:set var="iconUrl" value="${iconUrl.substring(imagesURL.length() + 1)}"/>
</j:if>

<!-- See if we can get an Icon def from the URL -->
<j:set var="icon" value="${icons.getIconByUrl(iconUrl)}"/>
<j:choose>
<j:when test="${icon != null}">
<!-- We found the Icon def -->
<l:icon class="${icon.classSpec}" alt="${it.description}" tooltip="${it.description}" style="${attrs.style}" />
</j:when>
<j:otherwise>
<!-- We don't seem to have this icon in the IconSet... fallback again... -->
<j:set var="iconUrl" value="${it.getImageOf(iconSize)}"/>
<l:icon src="${iconUrl}" class="${iconSizeClass}" alt="${it.description}" tooltip="${it.description}" style="${attrs.style}" />
</j:otherwise>
</j:choose>
</j:otherwise>
</j:choose>
<!-- See if we can get an Icon def from the URL -->
<j:set var="icon" value="${icons.getIconByUrl(iconUrl)}"/>
<j:choose>
<j:when test="${icon != null}">
<!-- We found the Icon def -->
<l:icon class="${icon.classSpec}" alt="${it.description}" tooltip="${it.description}"
style="${attrs.style}"/>
</j:when>
<j:otherwise>
<!-- We don't seem to have this icon in the IconSet... fallback again... -->
<j:set var="iconUrl" value="${it.getImageOf(iconSize)}"/>
<l:icon src="${iconUrl}" class="${iconSizeClass}" alt="${it.description}" tooltip="${it.description}"
style="${attrs.style}"/>
</j:otherwise>
</j:choose>
</j:otherwise>
</j:choose>
</j:if>
</j:if>
</div>
</td>
Expand Down
16 changes: 6 additions & 10 deletions test/src/test/java/lib/layout/IconTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,14 @@ public void testBallColorTd() throws Exception {
HtmlPage p = j.createWebClient().goTo("testBallColorTd");

DomElement ballColorAborted = p.getElementById("ballColorAborted");
List<DomElement> ballIcons = StreamSupport.stream(ballColorAborted.getChildElements().spliterator(), false).collect(Collectors.toList());
assertIconToSvgIconOkay(ballIcons.get(0).getFirstElementChild(), "icon-aborted icon-md");
assertThat("Aborted", is(ballColorAborted.getTextContent()));
HtmlElement symbol = ballColorAborted.getElementsByTagName("svg").get(0);
assertThat("icon-md", is(symbol.getAttribute("class")));

assertIconToSymbolOkay(symbol);

DomElement statusIcons = p.getElementById("statusIcons");
List<DomElement> statusIconsList = StreamSupport.stream(statusIcons.getChildElements().spliterator(), false).collect(Collectors.toList());
List<DomElement> statusIconsList = StreamSupport.stream(statusIcons.getChildElements().spliterator(), false).toList();

assertIconToSvgOkay(statusIconsList.get(0).getFirstElementChild().getNextElementSibling(), "icon-user icon-xlg");

Expand Down Expand Up @@ -182,13 +185,6 @@ private void assertIconToSvgOkay(DomElement icon, String classSpec) {
}
}

private void assertIconToSvgIconOkay(DomElement icon, String classSpec) {
assertThat(icon.getTagName(), is("span"));
if (classSpec != null) {
assertThat(icon.getAttribute("class"), endsWith(classSpec));
}
}

private void assertIconToSymbolOkay(DomElement icon) {
assertThat("svg", is(icon.getTagName()));
}
Expand Down
Loading