| DescriptorVisibilityFilter is not used to filter properties that are displayed on the View edition. The same method View.getApplicablePropertyDescriptors() is used both to filter displayed properties on UI and to filter properties that are saved with the View. The only way to not show a property in UI is to use ViewPropertyDescriptor but then the property is not persisted and is removed when the users edit view and save it.
@Extension
public static final class DescriptorImpl extends ViewPropertyDescriptor {
@Override
public boolean isEnabledFor(View view) {
return false;
}
}
That means that it's not possible to have some hidden properties for View that are persisted. This method is used in jelly to filter properties: https://github.com/jenkinsci/jenkins/blob/d1502bffe8b5d530d31a4d697f064b79a5cab081/core/src/main/resources/hudson/model/View/configure.jelly#L55 And it's also used in View to filter properties that are persisted: https://github.com/jenkinsci/jenkins/blob/d1502bffe8b5d530d31a4d697f064b79a5cab081/core/src/main/java/hudson/model/View.java#L1012 I looked at Job configuration, a specific method based on DescriptorVisibilityFilter is used in jelly. https://github.com/jenkinsci/jenkins/blob/d1502bffe8b5d530d31a4d697f064b79a5cab081/core/src/main/resources/hudson/model/Job/configure.jelly#L51 So this code should work for View when a plugin need to have an invisible property:
@Extension
public static final class DescriptorVisibilityFilterImpl extends DescriptorVisibilityFilter {
@Override
public boolean filter(Object context, Descriptor descriptor) {
return false;
}
}
I already did a test that show this issue, I will link the PR to this JIRA. I propose to add a new method in View to filter properties that use DescriptorVisibilityFilter to filter properties visible on UI and use it in View/configure.jelly. I will do the code modification in the same PR. |