Skip to content

Commit

Permalink
[JENKINS-40876] Fixes to display of object metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenc committed Jan 11, 2017
1 parent d55f2b4 commit 982d7e1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
24 changes: 16 additions & 8 deletions src/main/java/jenkins/branch/ItemColumn.java
Expand Up @@ -25,8 +25,6 @@
package jenkins.branch;

import hudson.Extension;
import hudson.Util;
import hudson.markup.MarkupFormatter;
import hudson.model.Actionable;
import hudson.model.Descriptor;
import hudson.model.DescriptorVisibilityFilter;
Expand All @@ -35,6 +33,7 @@
import hudson.views.ListViewColumnDescriptor;
import jenkins.scm.api.metadata.ObjectMetadataAction;
import jenkins.scm.api.metadata.PrimaryInstanceMetadataAction;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.DataBoundConstructor;
Expand Down Expand Up @@ -65,17 +64,26 @@ public boolean isPrimary(Object job) {
}

/**
* Gets the description of a job.
* Gets the tool-tip title of a job.
*
* @param job the job.
* @return the description.
* @return the tool-tip title unescaped for use in an attribute.
*/
@SuppressWarnings("unused") // used via Jelly EL binding
public String getDescription(Object job) {
public String getTitle(Object job) {
// Jelly will take care of quote and ampersand escaping for us
if (job instanceof Actionable) {
ObjectMetadataAction action = ((Actionable)job).getAction(ObjectMetadataAction.class);
String description = action != null ? action.getObjectDescription() : null;
return description != null ? Util.escape(description) : null;
Actionable actionable = (Actionable) job;
ObjectMetadataAction action = actionable.getAction(ObjectMetadataAction.class);
if (action != null) {
String dispayName = action.getObjectDisplayName();
if (StringUtils.isBlank(dispayName) || dispayName.equals(actionable.getDisplayName())) {
// if the display name is the same, then the description is more useful
String description = action.getObjectDescription();
return description != null ? description : dispayName;
}
return dispayName;
}
}
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/jenkins/branch/ItemColumn/column.jelly
Expand Up @@ -29,13 +29,13 @@ THE SOFTWARE.
<j:choose>
<j:when test="${it.isPrimary(job)}">
<strong>
<a href="${jobBaseUrl}${job.shortUrl}" class='model-link inside' title="${it.getDescription(job)}">
<a href="${jobBaseUrl}${job.shortUrl}" class='model-link inside' title="${it.getTitle(job)}">
<l:breakable value="${h.getRelativeDisplayNameFrom(job, itemGroup)}"/>
</a>
</strong>
</j:when>
<j:otherwise>
<a href="${jobBaseUrl}${job.shortUrl}" class='model-link inside' title="${it.getDescription(job)}">
<a href="${jobBaseUrl}${job.shortUrl}" class='model-link inside' title="${it.getTitle(job)}">
<l:breakable value="${h.getRelativeDisplayNameFrom(job, itemGroup)}"/>
</a>
</j:otherwise>
Expand Down

0 comments on commit 982d7e1

Please sign in to comment.