Skip to content
Permalink
Browse files
Merge pull request #8 from stephenc/jenkins-23609
[FIXED JENKINS-23609] "Successful" and "Failed" links do not work
  • Loading branch information
ikedam committed Apr 27, 2015
2 parents b516d49 + f5c1b0b commit 29dfcb053cb515fa20e5611a2ec638e49f0fc3cd
@@ -1,13 +1,10 @@
package hudson.plugins.matrix_configuration_parameter.matrixcombinationparameterDefinition

import hudson.matrix.AxisList
import hudson.matrix.Combination
import hudson.matrix.Layouter
import hudson.matrix.MatrixBuild
import hudson.matrix.MatrixProject
import hudson.matrix.*
import hudson.model.Result
import hudson.plugins.matrix_configuration_parameter.MatrixCombinationsParameterDefinition
import lib.LayoutTagLib
import org.kohsuke.stapler.jelly.groovy.Namespace
import hudson.plugins.matrix_configuration_parameter.MatrixCombinationsParameterDefinition;

l = namespace(LayoutTagLib)
t = namespace("/lib/hudson")
@@ -66,7 +63,7 @@ private void drawMainLinksJS(String nameIt) {
"var element = document.parameters.elements[i];\n" +
"if( element.type == 'checkbox' && element.id.lastIndexOf(\"checkbox" + nameIt + "-\", 0) == 0 )\n" +
"{\n" +
"if( element.value == status || status > 999 )\n" +
"if( (document.parameters.elements[i+1].getAttribute('data-status') == status) || status > 999 )\n" +

"{\n" +
"element.checked = true;\n" +
@@ -82,6 +79,16 @@ private void drawMainLinksJS(String nameIt) {
"</script>\n")
}

private int encodeRunResult(MatrixRun run) {
if (Result.SUCCESS.isWorseOrEqualTo(run.getResult())) {
return 0
};
if (Result.UNSTABLE.isWorseOrEqualTo(run.getResult())) {
return 1
};
return 2;
}

private void drawMainBall(MatrixCombinationsParameterDefinition paramDef, Combination combination,AxisList axes,String matrixName,MatrixProject project,Layouter layouter) {

lastBuild = project.getLastBuild();
@@ -96,7 +103,7 @@ private void drawMainBall(MatrixCombinationsParameterDefinition paramDef, Combin
}
checked = combination.evalGroovyExpression(axes, paramDef.defaultCombinationFilter?:project.combinationFilter)
f.checkbox(checked: checked, name: "values",id: String.format("checkbox%s-%s", matrixName, combination.toString('-' as char, '-' as char)))
input(type: "hidden", name: "confs", value: combination.toString())
input(type: "hidden", name: "confs", value: combination.toString(),'data-status':encodeRunResult(lastRun))

}

@@ -107,8 +114,8 @@ private void drawMainBall(MatrixCombinationsParameterDefinition paramDef, Combin
}

checked = combination.evalGroovyExpression(axes, paramDef.defaultCombinationFilter?:project.combinationFilter)
f.checkbox(checked: checked, name: "values",id: String.format("checkbox%s-%s", matrixName, combination.toString('-' as char, '-' as char)), value: combination.toIndex((AxisList) axes))
input(type: "hidden", name: "confs", value: combination.toString())
f.checkbox(checked: checked, name: "values",id: String.format("checkbox%s-%s", matrixName, combination.toString('-' as char, '-' as char)))
input(type: "hidden", name: "confs", value: combination.toString(), 'data-status': combination.toIndex((AxisList) axes) != -1 ? 0 : -1)
}

}
}
@@ -208,7 +208,6 @@ public void testBuildPageJsWithSingleAxis() throws Exception {
HtmlPage page = wc.getPage(p, "build");
HtmlForm form = page.getFormByName("parameters");

/** This does not work now (JENKINS-23609).
// Successful link
{
((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1")).setChecked(false);
@@ -222,9 +221,7 @@ public void testBuildPageJsWithSingleAxis() throws Exception {
assertTrue(((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value3")).isChecked());

}
*/

/** This does not work now (JENKINS-23609).

// Failed link
{
((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1")).setChecked(true);
@@ -238,7 +235,6 @@ public void testBuildPageJsWithSingleAxis() throws Exception {
assertFalse(((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value3")).isChecked());

}
*/

// All link
{
@@ -260,7 +256,7 @@ public void testBuildPageJsWithSingleAxis() throws Exception {
((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value2")).setChecked(true);
((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value3")).setChecked(false);

((HtmlAnchor)page.getElementById("shortcut-combinations-successful")).click();
((HtmlAnchor)page.getElementById("shortcut-combinations-none")).click();

assertFalse(((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1")).isChecked());
assertFalse(((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value2")).isChecked());
@@ -332,7 +328,6 @@ public void testBuildPageJsWithDoubleAxis() throws Exception {
HtmlPage page = wc.getPage(p, "build");
HtmlForm form = page.getFormByName("parameters");

/** This does not work now (JENKINS-23609).
// Successful link
{
((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1-1-axis2-value2-1")).setChecked(true);
@@ -347,9 +342,7 @@ public void testBuildPageJsWithDoubleAxis() throws Exception {
assertTrue(((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1-2-axis2-value2-1")).isChecked());
assertTrue(((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1-2-axis2-value2-2")).isChecked());
}
*/

/** This does not work now (JENKINS-23609).
// Failed link
{
((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1-1-axis2-value2-1")).setChecked(false);
@@ -364,7 +357,6 @@ public void testBuildPageJsWithDoubleAxis() throws Exception {
assertFalse(((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1-2-axis2-value2-1")).isChecked());
assertFalse(((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1-2-axis2-value2-2")).isChecked());
}
*/

// All link
{
@@ -388,7 +380,7 @@ public void testBuildPageJsWithDoubleAxis() throws Exception {
((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1-2-axis2-value2-1")).setChecked(false);
((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1-2-axis2-value2-2")).setChecked(true);

((HtmlAnchor)page.getElementById("shortcut-combinations-successful")).click();
((HtmlAnchor)page.getElementById("shortcut-combinations-none")).click();

assertFalse(((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1-1-axis2-value2-1")).isChecked());
assertFalse(((HtmlCheckBoxInput)form.getElementById("checkboxcombinations-axis1-value1-1-axis2-value2-2")).isChecked());

0 comments on commit 29dfcb0

Please sign in to comment.