Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-3549: misc. apply review comments
  • Loading branch information
dnozay committed Jul 6, 2015
1 parent a505215 commit b9e830c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 33 deletions.
Expand Up @@ -17,6 +17,8 @@
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
import org.kohsuke.stapler.interceptor.RequirePOST;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

/**
* For customizing project top-level GUI.
Expand Down Expand Up @@ -58,15 +60,20 @@ public AbstractBuild<?,?> getLatest(PromotionProcess p) {
return list.size() > 0 ? list.get(0) : null;
}

@Restricted(NoExternalUse.class)
public List<PromotionProcess> getPromotionProcesses() {
List<PromotionProcess> processes = null;
processes = getProcesses();
if (processes == null) {
// assert ?
// this case should not happen, the action should get deleted
// when there is no process; but we're now safe for the UI.
processes = new ArrayList<PromotionProcess>();
}
return processes;
}

@Restricted(NoExternalUse.class)
public Status getStatus(PromotionProcess process) {
List<Promotion> list = getPromotions( process );
Promotion latest = list.size() > 0 ? list.get(0) : null;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/hudson/plugins/promoted_builds/Status.java
Expand Up @@ -29,6 +29,8 @@
import jenkins.model.Jenkins;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

/**
* Promotion status of a build wrt a specific {@link PromotionProcess}.
Expand Down Expand Up @@ -271,6 +273,7 @@ public Promotion getLast() {
return null;
}

@Restricted(NoExternalUse.class)
public Boolean isLastAnError() {
Promotion l = getLast();
return (l != null && l.getResult() != Result.SUCCESS);
Expand Down
Expand Up @@ -5,38 +5,31 @@
<j:choose>
<j:when test="${ppa!=null}">
<j:set var="pp" value="${ppa.getPromotionProcesses()}"/>
<j:choose>
<j:when test="${pp!=null}">
<j:forEach var="process" items="${pp}">
<j:set var="status" value="${ppa.getStatus(process)}"/>
<j:set var="icon" value="${process.getIcon()}"/>
<j:set var="iconUrl" value="${resURL}/plugin/promoted-builds/icons/${iconSize}/${icon}.png"/>
<img width="${iconSize}" height="${iconSize}"
title="${%PromotionProcess} ${process.name}"
src="${iconUrl}"/>
<j:choose>
<j:when test="${status!=null}">
<j:if test="${status.isLastAnError()}">
<j:set var="iconUrl" value="${resURL}/images/${iconSize}/error.png"/>
<img width="${iconSize}" height="${iconSize}"
title="${%PromotionProcess} ${process.name} ${%PromotionProcess.failed}"
src="${iconUrl}"/>
</j:if>
<j:set var="target" value="${status.getTarget()}"/>
<a href="${jobBaseUrl}${job.shortUrl}${target.number}/" class="model-link inside">
${target.displayName}
</a>
</j:when>
<j:otherwise><!-- promotion has never happened / no builds -->
${%Otherwise.noBuild}
</j:otherwise>
</j:choose>
</j:forEach>
</j:when>
<j:otherwise><!-- job has no promotion process (despite project action) -->
${%Otherwise.noPromotionProcess}
</j:otherwise>
</j:choose>
<j:forEach var="process" items="${pp}">
<j:set var="status" value="${ppa.getStatus(process)}"/>
<j:set var="icon" value="${process.getIcon()}"/>
<j:set var="iconUrl" value="${resURL}/plugin/promoted-builds/icons/${iconSize}/${icon}.png"/>
<img width="${iconSize}" height="${iconSize}"
title="${%PromotionProcess} ${process.name}"
src="${iconUrl}"/>
<j:choose>
<j:when test="${status!=null}">
<j:if test="${status.isLastAnError()}">
<j:set var="iconUrl" value="${resURL}/images/${iconSize}/error.png"/>
<img width="${iconSize}" height="${iconSize}"
title="${%PromotionProcess} ${process.name} ${%PromotionProcess.failed}"
src="${iconUrl}"/>
</j:if>
<j:set var="target" value="${status.getTarget()}"/>
<a href="${jobBaseUrl}${job.shortUrl}${target.number}/" class="model-link inside">
${target.displayName}
</a>
</j:when>
<j:otherwise><!-- promotion has never happened / no builds -->
${%Otherwise.noBuild}
</j:otherwise>
</j:choose>
</j:forEach>
</j:when>
<j:otherwise><!-- job has no promotion process (no project action) -->
${%Otherwise.noPromotedProjectAction}
Expand Down
@@ -1,5 +1,4 @@
PromotionProcess = Promotion process
PromotionProcess.failed = failed
Otherwise.noBuild = N/A
Otherwise.noPromotionProcess = N/A
Otherwise.noPromotedProjectAction = N/A

0 comments on commit b9e830c

Please sign in to comment.