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 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 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

          Jesse Glick added a comment -

          Jesse Glick added a comment - https://github.com/jenkinsci/jenkins/pull/1033 specifically.

          Jesse Glick added a comment -

          Seems like hetero lists are now using; adjusting to request hetero dropdowns.

          Jesse Glick added a comment - Seems like hetero lists are now using; adjusting to request hetero dropdowns .

          Code changed in jenkins
          User: Jesse Glick
          Path:
          job/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java
          http://jenkins-ci.org/commit/workflow-plugin/b5082ba5b09c410762573da76c3da30c4e78de90
          Log:
          JENKINS-20020 Noting a use case.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: job/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java http://jenkins-ci.org/commit/workflow-plugin/b5082ba5b09c410762573da76c3da30c4e78de90 Log: JENKINS-20020 Noting a use case.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          job/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java
          http://jenkins-ci.org/commit/workflow-job-plugin/aae2b216549cc38247e64afb2571ad72c1bfbeda
          Log:
          JENKINS-20020 Noting a use case.

          Originally-Committed-As: b5082ba5b09c410762573da76c3da30c4e78de90

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: job/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java http://jenkins-ci.org/commit/workflow-job-plugin/aae2b216549cc38247e64afb2571ad72c1bfbeda Log: JENKINS-20020 Noting a use case. Originally-Committed-As: b5082ba5b09c410762573da76c3da30c4e78de90

          Jesse Glick added a comment -

          Jesse Glick added a comment - Noted in https://github.com/jenkinsci/jenkins/pull/5417 .

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

              Created:
              Updated: