Skip to content

Commit

Permalink
[FIXED JENKINS-20786] Switched radio buttons to dropdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikedam committed Apr 12, 2014
1 parent 2374674 commit cfbd4a0
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 3 deletions.
Expand Up @@ -23,9 +23,8 @@ 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:adjunct includes="org.jenkinsci.plugins.authorizeproject.nestedHelp"/>
<f:optionalBlock name="${descriptor.propertyName}" title="${descriptor.displayName}" checked="${instance != null}">
<f:entry title="${%Authorize Strategy}" field="strategy">
<f:hetero-radio field="strategy" descriptors="${descriptor.strategyList}" />
</f:entry>
<f:dropdownDescriptorSelector title="${%Authorize Strategy}" field="strategy" descriptors="${descriptor.strategyList}" />
</f:optionalBlock>
</j:jelly>
@@ -0,0 +1,65 @@
/*
* The MIT License
*
* Copyright (c) 2014 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.
*/

package org.jenkinsci.plugins.authorizeproject;

import jenkins.model.Jenkins;

st = namespace("jelly:stapler");

def descriptor = Jenkins.instance.getDescriptorOrDie(AuthorizeProjectProperty.class);

def myselfName = descriptor.plugin.shortName;

// help file for strategy itself.
def strategyRawHelpFile = descriptor.getHelpFile("strategyRaw");

if (strategyRawHelpFile != null) {
div(
class: "authorize-project-nested-help",
helpURL: String.format("%s%s", rootURL, strategyRawHelpFile),
myselfName: myselfName,
) {
text("Loading...");
}
}

dl() {
descriptor.strategyList.each() { d ->
def helpFile = d.getHelpFile();
dt(d.displayName);
if (helpFile != null) {
dd(
class: "authorize-project-nested-help",
helpURL: String.format("%s%s", rootURL, helpFile),
myselfName: myselfName,
) {
text("Loading...");
}
} else {
dd("No help available.");
}
}
}

@@ -0,0 +1,3 @@
<div>
Select one of following strategies:
</div>
@@ -0,0 +1,3 @@
<div>
以下の設定方法が利用可能です。
</div>
@@ -0,0 +1,53 @@
/*
* The MIT License
*
* Copyright (c) 2014 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.
*/
Behaviour.register({".authorize-project-nested-help": function(e) {
// ensure Behavior is applied only once.
$(e).removeClassName("authorize-project-nested-help");
new Ajax.Request(e.getAttribute("helpURL"), {
method : 'get',
onSuccess : function(x) {
e.innerHTML = x.responseText;
var myselfName = e.getAttribute("myselfName");
var pluginName = x.getResponseHeader("X-Plugin-Short-Name");
if (myselfName != pluginName) {
var from = x.getResponseHeader("X-Plugin-From");
if (from) {
e.innerHTML += "<div class='from-plugin'>"+from+"</div>";
}
}
layoutUpdateCallback.call();
},
onFailure : function(x) {
e.innerHTML = "<b>ERROR</b>: Failed to load help file: " + x.statusText;
}
});
}});

/**
* Allows run Behavior when help is loaded.
*/
layoutUpdateCallback.add(function() {
$$(".authorize-project-nested-help").each(function(e){Behaviour.applySubtree(e, true)});
});

0 comments on commit cfbd4a0

Please sign in to comment.