Skip to content
Permalink
Browse files

[JENKINS-43507] Fix the <scm:traits> taglib

  • Loading branch information...
stephenc committed May 4, 2017
1 parent 4ff2c17 commit f255f88bb8c8bf8e02fbfcb471813c46acc032a0
@@ -25,22 +25,14 @@ 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:f="/lib/form" xmlns:local="local">
<!-- TODO switch to hetero-list or repoeatableHeteroProperty once the dd-handle class can be removed -->
<st:documentation>
Outer most tag for creating a heterogeneous list, where the user can choose arbitrary number of
arbitrary items from the given list of descriptors, and configure them independently.

The submission can be data-bound into List&lt;T&gt; where T is the common base type for the describable instances.

For databinding use, please use &lt;f:repeatableHeteroProperty /&gt;

<st:attribute name="name" use="required">
form name that receives an array for all the items in the heterogeneous list.
</st:attribute>
<st:attribute name="items" use="required" type="java.util.Collection">
existing items to be displayed. Something iterable, such as array or collection.
Data-bound only version of &lt;f:hetero-list&gt; specialized for traits.
<st:attribute name="field" use="required">
Used for the data binding.
</st:attribute>
<st:attribute name="descriptors" use="required">
all types that the user can add.
<st:attribute name="default">
default configuration to use (if descriptor does not have a getFieldDefaults() method).
</st:attribute>
<st:attribute name="addCaption">
caption of the 'add' button.
@@ -51,20 +43,9 @@ THE SOFTWARE.
<st:attribute name="targetType">
the type for which descriptors will be configured. Defaults to ${it.class} (optional)
</st:attribute>
<st:attribute name="hasHeader">
For each item, add a caption from descriptor.getDisplayName().
This also activates drag&amp;drop (where the header is a grip), and help text support.
</st:attribute>
<st:attribute name="oneEach">
If true, only allow up to one instance per descriptor.
</st:attribute>
<st:attribute name="menuAlign">
Menu alignment against the button. Defaults to tl-bl
</st:attribute>
<st:attribute name="honorOrder">
If true, insert new addition by default to their 'desired' location, which
is the order induced by the descriptors.
</st:attribute>
<st:attribute name="capture">
Config fragments from descriptors are rendered lazily by default, which means
variables seen in the caller aren't visible to them. This attribute allows you
@@ -75,10 +56,9 @@ THE SOFTWARE.
<d:tag name="body">
<table style="width:100%">
<j:set var="help" value="${descriptor.helpFile}"/>
<j:if test="${hasHeader}">
<tr>
<td colspan="3">
<div class="dd-handle">
<div>
<b>${descriptor.displayName}</b>
</div>
</td>
@@ -88,7 +68,6 @@ THE SOFTWARE.
<j:if test="${help!=null}">
<f:helpArea/>
</j:if>
</j:if>

<d:invokeBody/>

@@ -105,12 +84,15 @@ THE SOFTWARE.
<st:adjunct includes="lib.form.hetero-list.hetero-list"/>

<j:set var="targetType" value="${attrs.targetType?:it.class}"/>
<div class="hetero-list-container ${hasHeader?'with-drag-drop':''} ${attrs.oneEach?'one-each':''} ${attrs.honorOrder?'honor-order':''}">
<j:set var="descriptors"
value="${descriptor[attrs.field+'Descriptors'] ?: descriptor.getPropertyType(instance,attrs.field).getApplicableItemDescriptors()}"/>
<div class="hetero-list-container with-drag-drop one-each honor-order">
<!-- display existing items -->
<j:forEach var="i" items="${attrs.items}">
<j:forEach var="i"
items="${instance != null ? instance[attrs.field] : (attrs.default ?: descriptor[attrs.field+'Defaults'])}">
<j:set var="descriptor" value="${i.descriptor}"/>
<j:set var="instance" value="${i}"/>
<div name="${attrs.name}" class="repeated-chunk" descriptorId="${descriptor.id}">
<div name="${attrs.field}" class="repeated-chunk" descriptorId="${descriptor.id}">
<local:body deleteCaption="${attrs.deleteCaption}">
<st:include from="${descriptor}" page="${descriptor.configPage}" optional="true"/>
</local:body>
@@ -122,9 +104,9 @@ THE SOFTWARE.
<div class="prototypes to-be-removed">
<!-- render one prototype for each type -->
<j:set var="instance" value="${null}"/>
<j:set var="descriptors" value="${h.filterDescriptors(it,attrs.descriptors)}"/>
<j:set var="descriptors" value="${h.filterDescriptors(it,descriptors)}"/>
<j:forEach var="descriptor" items="${descriptors}" varStatus="loop">
<div name="${attrs.name}" title="${descriptor.displayName}" tooltip="${descriptor.tooltip}"
<div name="${attrs.field}" title="${descriptor.displayName}" tooltip="${descriptor.tooltip}"
descriptorId="${descriptor.id}">
<j:set var="capture" value="${attrs.capture?:''}"/>
<local:body deleteCaption="${attrs.deleteCaption}">
@@ -140,7 +122,7 @@ THE SOFTWARE.

<div>
<input type="button" value="${attrs.addCaption?:'%Add'}" class="hetero-list-add" menualign="${attrs.menuAlign}"
suffix="${attrs.name}"/>
suffix="${attrs.field}"/>
</div>
</div>
</j:jelly>
@@ -179,7 +179,7 @@ public ListBoxModel doFillControllerIdItems() {
return descriptors;
}

public List<SCMTrait<?>> getDefaultTraits() {
public List<SCMTrait<?>> getTraitDefaults() {
return Collections.<SCMTrait<?>>singletonList(new MockSCMDiscoverBranches());
}
}
@@ -356,7 +356,7 @@ public ListBoxModel doFillRepositoryItems(@QueryParameter String controllerId) t
return SCMSourceTrait._for(this, MockSCMSourceContext.class, MockSCMBuilder.class);
}

public List<SCMSourceTrait> getDefaultTraits() {
public List<SCMSourceTrait> getTraitDefaults() {
return Collections.<SCMSourceTrait>singletonList(new MockSCMDiscoverBranches());
}
}
@@ -23,13 +23,12 @@
~ 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">
<j:jelly xmlns:j="jelly:core"
xmlns:f="/lib/form" xmlns:scm="/jenkins/scm/api/form">
<f:entry title="${%Controller ID}" field="controllerId">
<f:select/>
</f:entry>
<f:entry title="${%Behaviours}">
<f:hetero-list name="traits" descriptors="${descriptor.getTraitDescriptors()}"
items="${instance!=null?instance.traits:descriptor.defaultTraits}"/>
<scm:traits field="traits"/>
</f:entry>
</j:jelly>
@@ -23,16 +23,15 @@
~ 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">
<j:jelly xmlns:j="jelly:core"
xmlns:f="/lib/form" xmlns:scm="/jenkins/scm/api/form">
<f:entry title="${%Controller ID}" field="controllerId">
<f:select/>
</f:entry>
<f:entry title="${%Repository}" field="repository">
<f:select/>
</f:entry>
<f:entry title="${%Behaviours}">
<f:hetero-list name="traits" descriptors="${descriptor.traitDescriptors}"
items="${instance!=null?instance.traits:descriptor.defaultTraits}"/>
<scm:traits field="traits"/>
</f:entry>
</j:jelly>

0 comments on commit f255f88

Please sign in to comment.
You can’t perform that action at this time.