Skip to content

Commit

Permalink
SlaveOrLabelColumn: added links to slaves, added whitespace between
Browse files Browse the repository at this point in the history
label and description
  • Loading branch information
fredg02 committed Feb 24, 2015
1 parent 3ec36ff commit c6b0be1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
27 changes: 11 additions & 16 deletions src/main/java/jenkins/plugins/extracolumns/SlaveOrLabelColumn.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License
*
* Copyright (c) 2013, Stephan Krull
* Copyright (c) 2013, Stephan Krull, Frederic Gurr
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -47,27 +47,22 @@ public class SlaveOrLabelColumn extends ListViewColumn {
public SlaveOrLabelColumn() {
}

public String getInfo(Job<?, ?> job) {

public Label getLabel(Job<?, ?> job) {
if(!(job instanceof AbstractProject)){
LOGGER.finest("Not an instance of " + AbstractProject.class.getCanonicalName() + ". Cannot get info.");
return "";
return null;
}

AbstractProject<?, ?> project = AbstractProject.class.cast(job);
Label projectLabel = project.getAssignedLabel();
if (projectLabel == null || projectLabel.isEmpty()){
return "N/A";
}

if (projectLabel.isSelfLabel()){
return projectLabel.getName();
return project.getAssignedLabel();
}

public String getDescription(Label label) {
if (label == null) {
return "";
}

String desc = projectLabel.getDescription();
desc = (desc == null || desc.length() < 1) ? "" : "(" + desc + ")";

return projectLabel.getName()+ desc;
String desc = label.getDescription();
return (desc == null || desc.length() < 1) ? "" : "(" + desc + ")";
}

@Extension
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
The MIT License
Copyright (c) 2013, Stephan Krull
Copyright (c) 2013, Stephan Krull, Frederic Gurr
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -24,5 +24,14 @@

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core">
<td data="${it.getInfo(job)}">${it.getInfo(job)}</td>
<j:set var="label" value="${it.getLabel(job)}"/>
<j:set var="desc" value="${it.getDescription(label)}"/>
<td data="${label}">
<j:choose>
<j:when test="${label == null}">N/A</j:when>
<j:when test="${label.equals('')}">N/A</j:when>
<j:when test="${label.isSelfLabel()}"><a href="${rootURL}/computer/${label.getName()}">${label.getName()}</a></j:when>
<j:otherwise>${label.getName()} ${desc}</j:otherwise>
</j:choose>
</td>
</j:jelly>

0 comments on commit c6b0be1

Please sign in to comment.