Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-20020

DescriptorVisibilityFilter not considered by f:dropdownDescriptorSelector

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • core

      DescriptorVisibilityFilter is intended to be used to decide which descriptors get shown to the user. Yet repeatableHeteroProperty.jelly fails to consult it, so it is not possible to suppress certain descriptors in a hetero list according to context.

          [JENKINS-20020] DescriptorVisibilityFilter not considered by f:dropdownDescriptorSelector

          Jesse Glick created issue -

          Jesse Glick added a comment -

          So far unsuccessful in writing a test for this behavior; hetero-list.js manages to hide everything of interest behind layers of JavaScript.

          Jesse Glick added a comment - So far unsuccessful in writing a test for this behavior; hetero-list.js manages to hide everything of interest behind layers of JavaScript.
          Jesse Glick made changes -
          Attachment New: x.diff [ 24506 ]

          Jesse Glick added a comment -

          Same for config-builders.jelly and others.

          Jesse Glick added a comment - Same for config-builders.jelly and others.

          Jesse Glick added a comment -

          To be tested:

          diff --git a/core/src/main/resources/lib/form/repeatableHeteroProperty.jelly b/core/src/main/resources/lib/form/repeatableHeteroProperty.jelly
          index b1ab6b7..f753691 100644
          --- a/core/src/main/resources/lib/form/repeatableHeteroProperty.jelly
          +++ b/core/src/main/resources/lib/form/repeatableHeteroProperty.jelly
          @@ -66,7 +66,7 @@ THE SOFTWARE.
                 first try getFooBarDescriptors() then fall back to automatic inference by type
             -->
             <f:hetero-list name="${attrs.field}" items="${instance[attrs.field]}"
          -                 descriptors="${descriptor[attrs.field+'Descriptors'] ?: descriptor.getPropertyType(instance,attrs.field).getApplicableItemDescriptors()}"
          +                 descriptors="${descriptor[attrs.field+'Descriptors'] ?: f.filterDescriptors(it, descriptor.getPropertyType(instance,attrs.field).getApplicableItemDescriptors())}"
                            addCaption="${attrs.addCaption}" deleteCaption="${attrs.deleteCaption}"
                            hasHeader="${attrs.hasHeader}" honorOrder="${attrs.honorOrder}"
                            menuAlign="${attrs.menuAlign}" oneEach="${attrs.oneEach}"
          

          Jesse Glick added a comment - To be tested: diff --git a/core/src/main/resources/lib/form/repeatableHeteroProperty.jelly b/core/src/main/resources/lib/form/repeatableHeteroProperty.jelly index b1ab6b7..f753691 100644 --- a/core/src/main/resources/lib/form/repeatableHeteroProperty.jelly +++ b/core/src/main/resources/lib/form/repeatableHeteroProperty.jelly @@ -66,7 +66,7 @@ THE SOFTWARE. first try getFooBarDescriptors() then fall back to automatic inference by type --> <f:hetero-list name= "${attrs.field}" items= "${instance[attrs.field]}" - descriptors= "${descriptor[attrs.field+ 'Descriptors' ] ?: descriptor.getPropertyType(instance,attrs.field).getApplicableItemDescriptors()}" + descriptors= "${descriptor[attrs.field+ 'Descriptors' ] ?: f.filterDescriptors(it, descriptor.getPropertyType(instance,attrs.field).getApplicableItemDescriptors())}" addCaption= "${attrs.addCaption}" deleteCaption= "${attrs.deleteCaption}" hasHeader= "${attrs.hasHeader}" honorOrder= "${attrs.honorOrder}" menuAlign= "${attrs.menuAlign}" oneEach= "${attrs.oneEach}"

          Jesse Glick added a comment -

          Note that BuildStepDescriptor.isApplicable is not really a substitute, since even if you control the descriptor, this is only passed the type of project, not the actual instance.

          Jesse Glick added a comment - Note that BuildStepDescriptor.isApplicable is not really a substitute, since even if you control the descriptor, this is only passed the type of project, not the actual instance.
          Jesse Glick made changes -
          Summary Original: DescriptorVisibilityFilter not considered by f:repeatableHeteroProperty New: DescriptorVisibilityFilter not considered by f:repeatableHeteroProperty or common calls to f:hetero-list

          Jesse Glick added a comment -

          Workaround: override isApplicable to call !DescriptorVisibilityFilter.apply(Stapler.getCurrentRequest().findAncestorObject(AbstractProject.class), Collections.singleton(this)).isEmpty() (plus null checks).

          Jesse Glick added a comment - Workaround: override isApplicable to call !DescriptorVisibilityFilter.apply(Stapler.getCurrentRequest().findAncestorObject(AbstractProject.class), Collections.singleton(this)).isEmpty() (plus null checks).

          Oleg Nenashev added a comment -

          Daniel Beck has created a PR for hetero-list in another JIRA issue

          Oleg Nenashev added a comment - Daniel Beck has created a PR for hetero-list in another JIRA issue
          Oleg Nenashev made changes -
          Link New: This issue is related to JENKINS-20739 [ JENKINS-20739 ]

            jglick Jesse Glick
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: