Skip to content

Commit

Permalink
[FIXED JENKINS-14325] CCE & missing GUI when using jobs inside folders.
Browse files Browse the repository at this point in the history
Introduced AbstractProject.supportsMakeDisabled rather than using trick of checking for parent instanceof Jenkins.
Extracted common GUI into makeDisabled.jelly, with accompanying I18N refactoring.
Also moved all this into AbstractProject, where the relevant methods are defined, rather than Job where they are not.
  • Loading branch information
jglick committed Jul 5, 2012
1 parent 129e76b commit c91584f
Show file tree
Hide file tree
Showing 69 changed files with 197 additions and 180 deletions.
4 changes: 3 additions & 1 deletion changelog.html
Expand Up @@ -55,7 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=bug>
Enable/disable GUI for jobs either did not appear, or threw exceptions, for jobs inside folders
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-14325">issue 14325</a>)
</ul>
</div><!--=TRUNK-END=-->

Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/hudson/matrix/MatrixConfiguration.java
Expand Up @@ -344,4 +344,10 @@ public boolean scheduleBuild(ParametersAction parameters) {
public boolean scheduleBuild(ParametersAction parameters, Cause c) {
return Jenkins.getInstance().getQueue().schedule(this, getQuietPeriod(), parameters, new CauseAction(c))!=null;
}

@Override
public boolean supportsMakeDisabled() {
return false;
}

}
11 changes: 11 additions & 0 deletions core/src/main/java/hudson/model/AbstractProject.java
Expand Up @@ -620,6 +620,17 @@ public void makeDisabled(boolean b) throws IOException {
save();
}

/**
* Specifies whether this project may be disabled by the user.
* By default, it can, but specialized project types contained in another
* (such as Maven modules or matrix configurations) should return false.
* @return true if the GUI should allow {@link #doDisable} and the like
* @since 1.475
*/
public boolean supportsMakeDisabled() {
return true;
}

public void disable() throws IOException {
makeDisabled(true);
}
Expand Down
22 changes: 1 addition & 21 deletions core/src/main/resources/hudson/matrix/MatrixProject/index.jelly
Expand Up @@ -33,27 +33,7 @@ THE SOFTWARE.
</j:if>
<t:editableDescription permission="${it.CONFIGURE}"/>

<j:choose>
<j:when test="${it.disabled}">
<div class="warning">
<form method="post" action="enable">
${%This project is currently disabled}
<l:hasPermission permission="${it.CONFIGURE}">
<f:submit value="${%Enable}" />
</l:hasPermission>
</form>
</div>
</j:when>
<j:otherwise>
<div align="right">
<form method="post" action="disable">
<l:hasPermission permission="${it.CONFIGURE}">
<f:submit value="${%Disable Project}" />
</l:hasPermission>
</form>
</div>
</j:otherwise>
</j:choose>
<st:include page="makeDisabled.jelly" />

<st:include page="ajaxMatrix.jelly" />

Expand Down
Expand Up @@ -20,5 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

Disable\ Project=Vypnout projekt
Project=Projekt
Expand Up @@ -20,6 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

This\ project\ is\ currently\ disabled=Dette projekt er for nuv\u00e6rende sl\u00e5et fra
Enable=Sl\u00e5 til
Project=Projekt
Expand Up @@ -22,6 +22,3 @@

Latest\ Test\ Result=Aktuelle Testergebnisse
Project=Projekt
Enable=Aktivieren
This\ project\ is\ currently\ disabled=Dieses Projekt ist momentan deaktiviert.
Disable\ Project=Projekt deaktivieren
Expand Up @@ -21,8 +21,5 @@
# THE SOFTWARE.

Project=Proyecto
Disable\ Project=Desactivar el proyecto
This\ project\ is\ currently\ disabled=Este proyecto está desactivado
Enable=Activar
Latest\ Test\ Result=Último resultado de test
Latest\ Test\ Result=\u00daltimo resultado de test
Project\ name=Nombre de proyecto
Expand Up @@ -20,5 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

Disable\ Project=Poista k\u00E4yt\u00F6st\u00E4
Project=Projekti
Expand Up @@ -20,8 +20,5 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

Disable\ Project=D\u00E9sactiver le projet
Enable=Activer
Latest\ Test\ Result=Derniers r\u00E9sultats de test
Latest\ Test\ Result=Derniers r\u00e9sultats de test
Project=projet
This\ project\ is\ currently\ disabled=Ce projet est d\u00E9sactiv\u00E9
Expand Up @@ -20,5 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

Disable\ Project=Disabilita Progetto
Project=Progetto
Expand Up @@ -21,8 +21,5 @@
# THE SOFTWARE.

Project=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8
This\ project\ is\ currently\ disabled=\u73fe\u5728\u3001\u3053\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306f\u7121\u52b9\u3067\u3059\u3002
Enable=\u6709\u52b9\u5316
Disable\ Project=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u7121\u52b9\u5316
Project\ name=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d
Latest\ Test\ Result=\u6700\u65b0\u306e\u30c6\u30b9\u30c8\u7d50\u679c
Expand Up @@ -20,7 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

Disable\ Project=Wy\u0142\u0105cz projekt
Enable=Aktywuj
Project=Projekt
This\ project\ is\ currently\ disabled=Projekt jest nieaktywny
Expand Up @@ -20,7 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

Disable\ Project=\u041E\u0442\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u043F\u0440\u043E\u0435\u043A\u0442
Enable=\u0412\u043A\u043B\u044E\u0447\u0438\u0442\u044C
Project=\u041f\u0440\u043e\u0435\u043a\u0442
This\ project\ is\ currently\ disabled=\u042D\u0442\u043E\u0442 \u043F\u0440\u043E\u0435\u043A\u0442 \u0441\u0435\u0439\u0447\u0430\u0441 \u043E\u0442\u043A\u043B\u044E\u0447\u0435\u043D.
Expand Up @@ -20,5 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

Disable\ Project=\u7981\u7528\u9879\u76EE
Project=\u9879\u76EE
Project=\u9879\u76ee
Expand Up @@ -27,6 +27,10 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<p:projectActionFloatingBox />

<j:if test="${it.supportsMakeDisabled()}">
<st:include page="makeDisabled.jelly" />
</j:if>

<table style="margin-top: 1em; margin-left:1em;">

<j:forEach var="act" items="${it.prominentActions}">
Expand Down
@@ -0,0 +1,48 @@
<!--
The MIT License
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt, Tom Huybrechts, id:cactusman
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.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<j:choose>
<j:when test="${it.disabled}">
<div class="warning">
<form method="post" action="enable">
${%This project is currently disabled}
<l:hasPermission permission="${it.CONFIGURE}">
<f:submit value="${%Enable}" />
</l:hasPermission>
</form>
</div>
</j:when>
<j:otherwise>
<div align="right">
<form method="post" action="disable">
<l:hasPermission permission="${it.CONFIGURE}">
<f:submit value="${%Disable Project}" />
</l:hasPermission>
</form>
</div>
</j:otherwise>
</j:choose>
</j:jelly>
Expand Up @@ -20,4 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

Disable\ Project=Onemogo\u010Di Projekt
This\ project\ is\ currently\ disabled=Este projecto est\u00e1 desactivado actualmente
Enable=Activar
Disable\ Project=Desactivar el Proyecto
@@ -0,0 +1,25 @@
# The MIT License
#
# Copyright (c) 2004-2012, Sun Microsystems, Inc., Kohsuke Kawaguchi, Seiji Sogabe, id:cactusman
#
# 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.

This\ project\ is\ currently\ disabled=\u73fe\u5728\u3001\u3053\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306f\u7121\u52b9\u3067\u3059\u3002
Enable=\u6709\u52b9\u5316
Disable\ Project=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u7121\u52b9\u5316
@@ -1,17 +1,17 @@
# The MIT License
#
# Copyright (c) 2004-2010, Sun Microsystems, Inc.
#
#
# Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, id:sorokh
#
# 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
Expand All @@ -20,6 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

Disable\ Project=\u95DC\u9589\u5C08\u6848
Enable=\u555F\u7528
This\ project\ is\ currently\ disabled=\u672C\u5C08\u6848\u76EE\u524D\u662F\u505C\u7528\u7684\u3002
Disable\ Project=Deactiveer project
Enable=Activeren
This\ project\ is\ currently\ disabled=Dit project is gedeactiveerd
@@ -0,0 +1,25 @@
# The MIT License
#
# Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Mike Salnikov
#
# 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.

Disable\ Project=\u0412\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442
Enable=\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c
This\ project\ is\ currently\ disabled=\u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d
@@ -0,0 +1,24 @@
# The MIT License
#
# Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Oguz Dag
#
# 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.

Disable\ Project=Projeyi devre d\u0131\u015f\u0131 b\u0131rak
This\ project\ is\ currently\ disabled=Bu proje \u015fimdilik devre d\u0131\u015f\u0131
24 changes: 0 additions & 24 deletions core/src/main/resources/hudson/model/Job/index.jelly
Expand Up @@ -33,30 +33,6 @@ THE SOFTWARE.
</j:if>
<t:editableDescription permission="${it.CONFIGURE}"/>

<j:if test="${it.parent == app}">
<j:choose>
<j:when test="${it.disabled}">
<div class="warning">
<form method="post" action="enable">
${%This project is currently disabled}
<l:hasPermission permission="${it.CONFIGURE}">
<f:submit value="${%Enable}" />
</l:hasPermission>
</form>
</div>
</j:when>
<j:otherwise>
<div align="right">
<form method="post" action="disable">
<l:hasPermission permission="${it.CONFIGURE}">
<f:submit value="${%Disable Project}" />
</l:hasPermission>
</form>
</div>
</j:otherwise>
</j:choose>
</j:if>

<st:include page="jobpropertysummaries.jelly" />
<!-- inject main part here -->
<st:include page="main.jelly" />
Expand Down
3 changes: 0 additions & 3 deletions core/src/main/resources/hudson/model/Job/index_es.properties
Expand Up @@ -20,7 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

This\ project\ is\ currently\ disabled=Este projecto está desactivado actualmente
Enable=Activar
Disable\ Project=Desactivar el Proyecto
Project\ name=Nombre del Proyecto
3 changes: 0 additions & 3 deletions core/src/main/resources/hudson/model/Job/index_ja.properties
Expand Up @@ -20,7 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

This\ project\ is\ currently\ disabled=\u73fe\u5728\u3001\u3053\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306f\u7121\u52b9\u3067\u3059\u3002
Enable=\u6709\u52b9\u5316
Disable\ Project=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u7121\u52b9\u5316
Project\ name=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d
3 changes: 0 additions & 3 deletions core/src/main/resources/hudson/model/Job/index_nl.properties
Expand Up @@ -21,10 +21,7 @@
# THE SOFTWARE.

Permalinks=Permanente referenties
Disable\ Project=Deactiveer project
Enable=Activeren
Last\ build=Laatste bouwpoging
Last\ stable\ build=Laatste stabiele bouwpoging
Last\ successful\ build=Laatste succesvolle bouwpoging
Last\ failed\ build=Laatst gefaalde bouwpoging
This\ project\ is\ currently\ disabled=Dit project is gedeactiveerd

0 comments on commit c91584f

Please sign in to comment.