Skip to content

Commit

Permalink
[JENKINS-8276] Moved method that tests for job filter extenstions fro…
Browse files Browse the repository at this point in the history
…m SectionedViewSection to SectionedViewSectionDescriptor.

The config.jelly file was previously attempting to invoke this method in SectionedViewSection via the 'instance'
reference.  However the 'instance' does not exist until the new section is saved.  Because of this the
'Add Job Filter' button could never appear until after the view was saved and re-opened for editing.

By moving the method to the SectionedViewSectionDescriptor class it is available before the section is created by the first save.
  • Loading branch information
Richard Thomas authored and Timothy Bingaman committed Oct 5, 2015
1 parent 3769737 commit 7a9f98f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
Expand Up @@ -104,8 +104,12 @@ public Iterable<ViewJobFilter> getJobFilters() {
return jobFilters;
}

/**
* @deprecated use {@link SectionedViewSectionDescriptor#hasJobFilterExtensions()} instead
*/
@Deprecated
public boolean hasJobFilterExtensions() {
return !ViewJobFilter.all().isEmpty();
return getDescriptor().hasJobFilterExtensions();
}

public Width getWidth() {
Expand Down
Expand Up @@ -55,6 +55,10 @@ protected SectionedViewSectionDescriptor(Class<? extends SectionedViewSection> c
protected SectionedViewSectionDescriptor() {
}

public boolean hasJobFilterExtensions() {
return !ViewJobFilter.all().isEmpty();
}

@Override
public SectionedViewSection newInstance(StaplerRequest req, JSONObject formData) throws FormException {
SectionedViewSection section = (SectionedViewSection)req.bindJSON(getClass().getDeclaringClass(), formData);
Expand Down
Expand Up @@ -49,7 +49,7 @@ THE SOFTWARE.
</f:entry>
</f:optionalBlock>

<j:if test="${instance.hasJobFilterExtensions()}">
<j:if test="${descriptor.hasJobFilterExtensions()}">
<j:invokeStatic var="allJobFilters" className="hudson.views.ViewJobFilter" method="all"/>
<f:block>
<f:hetero-list name="jobFilters" hasHeader="true"
Expand Down
Expand Up @@ -43,7 +43,7 @@ THE SOFTWARE.
</j:forEach>
</f:entry>

<j:if test="${instance.hasJobFilterExtensions()}">
<j:if test="${descriptor.hasJobFilterExtensions()}">
<j:invokeStatic var="allJobFilters" className="hudson.views.ViewJobFilter" method="all"/>
<f:block>
<f:hetero-list name="jobFilters" hasHeader="true"
Expand Down

0 comments on commit 7a9f98f

Please sign in to comment.