mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 05:52:26 +00:00
Merge pull request #1443 from mattmoor/master
Change Jenkins to use a single consistent data-binding field.
This commit is contained in:
commit
4e0af4319c
8 files changed
+62
-23
No files matched your search
@@ -909,7 +909,11 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
|
||||
if (formData!=null) {
|
||||
for (Object o : JSONArray.fromObject(formData)) {
|
||||
JSONObject jo = (JSONObject)o;
|
||||
String kind = jo.getString("kind");
|
||||
String kind = jo.optString("$class", null);
|
||||
if (kind == null) {
|
||||
// Legacy: Remove once plugins have been staged onto $class
|
||||
kind = jo.getString("kind");
|
||||
}
|
||||
Descriptor<T> d = find(descriptors, kind);
|
||||
if (d != null) {
|
||||
items.add(d.newInstance(req, jo));
|
||||
|
||||
@@ -44,7 +44,7 @@ public class GlobalProjectNamingStrategyConfiguration extends GlobalConfiguratio
|
||||
final JSONObject optJSONObject = json.optJSONObject("useProjectNamingStrategy");
|
||||
if (optJSONObject != null) {
|
||||
final JSONObject strategyObject = optJSONObject.getJSONObject("namingStrategy");
|
||||
final String className = strategyObject.getString("stapler-class");
|
||||
final String className = strategyObject.getString("$class");
|
||||
try {
|
||||
Class clazz = Class.forName(className, true, Jenkins.getInstance().getPluginManager().uberClassLoader);
|
||||
final ProjectNamingStrategy strategy = (ProjectNamingStrategy) req.bindJSON(clazz, strategyObject);
|
||||
|
||||
@@ -56,9 +56,7 @@ THE SOFTWARE.
|
||||
<j:set var="descriptor" value="${d}"/>
|
||||
<j:set var="instance"
|
||||
value="${it.launcher.descriptor==d ? it.launcher : null}"/>
|
||||
<f:invisibleEntry>
|
||||
<input type="hidden" name="stapler-class" value="${d.clazz.name}" />
|
||||
</f:invisibleEntry>
|
||||
<f:class-entry descriptor="${d}" />
|
||||
<st:include from="${d}" page="${d.configPage}" optional="true"/>
|
||||
</f:dropdownListBlock>
|
||||
</j:forEach>
|
||||
@@ -76,9 +74,7 @@ THE SOFTWARE.
|
||||
<j:set var="descriptor" value="${d}"/>
|
||||
<j:set var="instance"
|
||||
value="${it.retentionStrategy.descriptor==d ? it.retentionStrategy : null}"/>
|
||||
<tr><td>
|
||||
<input type="hidden" name="stapler-class" value="${d.clazz.name}" />
|
||||
</td></tr>
|
||||
<f:class-entry descriptor="${d}" />
|
||||
<st:include from="${d}" page="${d.configPage}" optional="true"/>
|
||||
</f:dropdownListBlock>
|
||||
</j:if>
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2014, Google, Inc.
|
||||
|
||||
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>
|
||||
Invisible <f:entry> type for embedding a descriptor's $class field.
|
||||
<st:attribute name="clazz">
|
||||
The describable class that we are instantiating via structured form submission.
|
||||
</st:attribute>
|
||||
<st:attribute name="descriptor">
|
||||
The descriptor of the describable that we are instantiating via
|
||||
structured form submission. Mutually exclusive with clazz.
|
||||
</st:attribute>
|
||||
</st:documentation>
|
||||
<j:set var="clazz" value="${attrs.clazz ?: attrs.descriptor.clazz.name}" />
|
||||
<f:invisibleEntry>
|
||||
<!-- Legacy: Remove once plugins have been staged onto $class -->
|
||||
<input type="hidden" name="stapler-class" value="${clazz}" />
|
||||
<!-- Legacy: Remove once plugins have been staged onto $class -->
|
||||
<j:if test="${attrs.descriptor != null}">
|
||||
<input type="hidden" name="kind" value="${attrs.descriptor.id}" />
|
||||
</j:if>
|
||||
<input type="hidden" name="$class" value="${clazz}" />
|
||||
</f:invisibleEntry>
|
||||
</j:jelly>
|
||||
@@ -53,9 +53,7 @@ THE SOFTWARE.
|
||||
title="${d.displayName}" checked="${instance.descriptor==d}">
|
||||
<j:set var="descriptor" value="${d}" />
|
||||
<j:set var="instance" value="${instance.descriptor==d?instance:null}" />
|
||||
<f:invisibleEntry>
|
||||
<input type="hidden" name="stapler-class" value="${descriptor.clazz.name}"/>
|
||||
</f:invisibleEntry>
|
||||
<f:class-entry descriptor="${descriptor}" />
|
||||
<st:include from="${d}" page="${d.configPage}" optional="true" />
|
||||
</f:radioBlock>
|
||||
</j:forEach>
|
||||
|
||||
@@ -50,11 +50,7 @@ THE SOFTWARE.
|
||||
</j:when>
|
||||
<j:when test="${dropdownListMode=='generateEntries'}">
|
||||
<!-- sandwich them by markers so that we know what to show/hide -->
|
||||
<tr class="dropdownList-start rowvg-start">
|
||||
<j:if test="${!empty(attrs.staplerClass)}">
|
||||
<td style="display:none"><input type="hidden" name="stapler-class" value="${attrs.staplerClass}"/></td>
|
||||
</j:if>
|
||||
</tr>
|
||||
<tr class="dropdownList-start rowvg-start" />
|
||||
<j:choose>
|
||||
<j:when test="${attrs.lazy!=null and !attrs.selected}">
|
||||
<l:renderOnDemand capture="${attrs.lazy}" tag="tr">
|
||||
@@ -65,6 +61,9 @@ THE SOFTWARE.
|
||||
<d:invokeBody />
|
||||
</j:otherwise>
|
||||
</j:choose>
|
||||
<j:if test="${!empty(attrs.staplerClass)}">
|
||||
<f:class-entry clazz="${attrs.staplerClass}" />
|
||||
</j:if>
|
||||
<tr class="dropdownList-end rowvg-end" />
|
||||
</j:when>
|
||||
</j:choose>
|
||||
|
||||
@@ -91,14 +91,13 @@ THE SOFTWARE.
|
||||
|
||||
<d:invokeBody/>
|
||||
|
||||
<f:class-entry descriptor="${descriptor}" />
|
||||
<f:block>
|
||||
<div align="right">
|
||||
<input type="hidden" name="stapler-class" value="${descriptor.clazz.name}" />
|
||||
<f:repeatableDeleteButton value="${attrs.deleteCaption}" />
|
||||
</div>
|
||||
</f:block>
|
||||
</table>
|
||||
<input type="hidden" name="kind" value="${descriptor.id}" />
|
||||
</d:tag>
|
||||
</d:taglib>
|
||||
|
||||
|
||||
@@ -47,11 +47,7 @@ THE SOFTWARE.
|
||||
<j:set var="descriptor" value="${d}" />
|
||||
<j:set var="instance" value="${currentDescriptor==d?currentInstance:null}" />
|
||||
<st:include from="${d}" page="${d.configPage}" optional="true" />
|
||||
|
||||
<f:invisibleEntry><!-- this tells Stapler which block is for which class -->
|
||||
<input type="hidden" name="stapler-class" value="${d.clazz.name}" />
|
||||
<input type="hidden" name="kind" value="${descriptor.id}"/>
|
||||
</f:invisibleEntry>
|
||||
<f:class-entry descriptor="${d}" />
|
||||
</f:radioBlock>
|
||||
</j:forEach>
|
||||
</table>
|
||||
|
||||
Reference in new issue
Block a user