Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-36894] Apply shortcuts also for rebuild pages.
  • Loading branch information
ikedam committed Aug 7, 2016
1 parent 2ff272b commit 0028b9f
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 24 deletions.
Expand Up @@ -17,10 +17,6 @@ st = namespace("jelly:stapler")
f = namespace("lib/form")
nsProject = namespace("/hudson/plugins/matrix_configuration_parameter/taglib")

st.once {
st.adjunct(includes: "hudson.plugins.matrix_configuration_parameter.MatrixCombinationsParameterDefinition.shortcut");
}


def paramDef = it;
String nameIt = it.getName();
Expand Down Expand Up @@ -60,16 +56,7 @@ private void drawMainBody(MatrixCombinationsParameterDefinition paramDef, Namesp
nsProject.matrix(it: project, layouter: layouter) {
drawMainBall(paramDef, p, project.axes, nameIt, project, layouter);
}
span(style: "font-weight: bold;") { text("Select: "); }
paramDef.shortcutList.each { shortcut ->
a(class: "shortcut shortcut-" + shortcut.id, href: "#", "data-shortcut-id": shortcut.id, "data-combinations": shortcut.getCombinationsData(project, build)) {
text(shortcut.name);
}
if (shortcut != paramDef.shortcutList.last()) {
// TODO: replace with appropreate CSS.
text(" - ");
}
}
nsProject.shortcut(parameter: paramDef, project: project, build: build);
}//div
}
}
Expand Down
Expand Up @@ -6,6 +6,8 @@ import hudson.matrix.Combination
import hudson.matrix.Layouter
import hudson.matrix.MatrixBuild
import hudson.matrix.MatrixProject
import hudson.model.ParametersDefinitionProperty
import hudson.plugins.matrix_configuration_parameter.MatrixCombinationsParameterDefinition
import lib.LayoutTagLib
import org.kohsuke.stapler.jelly.groovy.Namespace

Expand Down Expand Up @@ -37,17 +39,25 @@ Layouter layouter = new Layouter<Combination>(axes) {
}
};

drawParameterBody(f, valueIt, axes, project, build, layouter);
def parameterDefinition = project.getProperty(ParametersDefinitionProperty.class).getParameterDefinition(valueIt.name);
if (!(parameterDefinition instanceof MatrixCombinationsParameterDefinition)) {
parameterDefinition = null;
}

drawParameterBody(parameterDefinition, f, valueIt, axes, project, build, layouter);



private void drawParameterBody(Namespace f,valueIt,AxisList axes,MatrixProject project,MatrixBuild build,Layouter layouter) {
private void drawParameterBody(MatrixCombinationsParameterDefinition paramDef, Namespace f,valueIt,AxisList axes,MatrixProject project,MatrixBuild build,Layouter layouter) {
f.entry(title: valueIt.getName(), description: it.getDescription()) {
div(name: "parameter") {
div(name: "parameter", class: "matrix-combinations-parameter") {
input(type: "hidden", name: "name", value: valueIt.getName())
nsProject.matrix(it: build, layouter: layouter) {
drawTableBall(p, project.axes, valueIt, project, build, layouter);
}
if (paramDef != null) {
nsProject.shortcut(parameter: paramDef, project: project, build: build);
}
}//div
}
}
Expand All @@ -63,15 +73,19 @@ private void drawTableBall(Combination combination,AxisList axes,matrixValue,Mat
text(combination.toString(layouter.z))
}
}
f.checkbox(checked: "true", name: "values",id: String.format("checkbox%s-%s", matrixValue.getName(), combination.toString('-' as char, '-' as char)));
input(type: "hidden", name: "confs", value: combination.toString());
span(class: "combination", "data-combination": combination.toIndex(axes)) {
f.checkbox(checked: true, name: "values");
input(type: "hidden", name: "confs", value: combination.toString());
}

} else {
img(src: "${imagesURL}/24x24/grey.gif");
if (!layouter.x || !layouter.y) {
text(combination.toString(layouter.z))
}
f.checkbox(checked: "false", name: "values",id: String.format("checkbox%s-%s", matrixValue.getName(), combination.toString('-' as char, '-' as char)));
input(type: "hidden", name: "confs", value: combination.toString());
span(class: "combination", "data-combination": combination.toIndex(axes)) {
f.checkbox(checked: "false", name: "values")
input(type: "hidden", name: "confs", value: combination.toString())
}
}
}
Expand Up @@ -43,7 +43,7 @@ THE SOFTWARE.

<j:set var="layouter" value="${layouter?:it.layouter}"/>
<j:set var="o" value="${layouter}"/>
<div id='matrix'>
<div class='matrix'>
<j:choose>
<!-- Optimized case when there's only one dimension to the axis (or zero dimension) -->
<j:when test="${empty(o.x) and empty(o.y)}">
Expand All @@ -53,13 +53,13 @@ THE SOFTWARE.
</j:forEach>
</j:when>
<j:otherwise>
<table id="configuration-matrix">
<table class="configuration-matrix">
<!-- X-axis -->
<j:forEach var="x" items="${o.x}" varStatus="loop">
<tr class="matrix-row">
<!-- space for Y-axis -->
<j:if test="${!empty(o.y)}">
<td id="matrix-title" colspan="${size(o.y)}"><st:nbsp /></td>
<td class="matrix-title" colspan="${size(o.y)}"><st:nbsp /></td>
</j:if>
<j:forEach begin="1" end="${o.repeatX(loop.index)}">
<j:forEach var="v" items="${x.values}">
Expand Down
@@ -0,0 +1,59 @@
<!--
The MIT License
Copyright (c) 2016 IKEDA Yasuyuki
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">
<st:documentation>
Displays shortcut links for matrix combinations

<st:attribute name="parameter">
an instance of MatrixCombinationsParameterDefinition.
</st:attribute>
<st:attribute name="project">
an instance of MatrixProject.
</st:attribute>
<st:attribute name="build">
an instance of MatrixBuild.
</st:attribute>
</st:documentation>

<st:once>
<st:adjunct includes="hudson.plugins.matrix_configuration_parameter.taglib.shortcut.shortcut" />
</st:once>

<div class="matrix-combinations-parameter-shortcut">
<span class="head">Select: </span>
<ul class="shortcuts">
<j:forEach var="shortcut" items="${parameter.shortcutList}">
<li>
<a
class="shortcut shortcut-${shortcut.id}"
href="#"
data-shortcut-id="${shortcut.id}"
data-combinations="${shortcut.getCombinationsData(project, build)}"
>${shortcut.name}</a>
</li>
</j:forEach>
</ul>
</div>
</j:jelly>
@@ -0,0 +1,20 @@
.matrix-combinations-parameter-shortcut .head {
font-weight: bold;
}

.matrix-combinations-parameter-shortcut ul.shortcuts {
display: inline-block;
margin: 0;
padding: 0;
list-style-type: none;
}

.matrix-combinations-parameter-shortcut ul.shortcuts li {
display: inline-block;
}

.matrix-combinations-parameter-shortcut ul.shortcuts li + li:before {
content: "-";
margin-left: 1ex;
margin-right: 1ex;
}

0 comments on commit 0028b9f

Please sign in to comment.