[JIRA] (JENKINS-60579) Impossible to have an invisible property on View that is persisted on save

9 views
Skip to first unread message

ajard@cloudbees.com (JIRA)

unread,
Dec 24, 2019, 5:33:05 AM12/24/19
to jenkinsc...@googlegroups.com
A. Jard created an issue
 
Jenkins / Bug JENKINS-60579
Impossible to have an invisible property on View that is persisted on save
Issue Type: Bug Bug
Assignee: Unassigned
Components: core
Created: 2019-12-24 10:32
Priority: Minor Minor
Reporter: A. Jard

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.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

ajard@cloudbees.com (JIRA)

unread,
Dec 24, 2019, 5:35:03 AM12/24/19
to jenkinsc...@googlegroups.com

ajard@cloudbees.com (JIRA)

unread,
Dec 24, 2019, 5:41:03 AM12/24/19
to jenkinsc...@googlegroups.com
A. Jard updated an issue
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.
{code:java}

@Extension
public static final class DescriptorImpl extends ViewPropertyDescriptor {

    @Override
    public boolean isEnabledFor(View view) {
        return false;
    }
}
{code}
*That means that it's not possible to have some hidden properties for View that are persisted.*
So this code should work for View when a plugin need to have an invisible property:
{code:java}

@Extension
public static final class DescriptorVisibilityFilterImpl extends DescriptorVisibilityFilter {

    @Override
    public boolean filter(Object context, Descriptor descriptor) {
        return false;
    }
}{code}
I already did a test that show this issue
, I will link the it's on that PR to this JIRA : https://github . com/jenkinsci/jenkins/pull/4404

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.

ajard@cloudbees.com (JIRA)

unread,
Jan 3, 2020, 3:04:03 AM1/3/20
to jenkinsc...@googlegroups.com
I already did a test that show this issue it's on that PR: https://github.com/jenkinsci/jenkins/pull/4404

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 Rule test to reproduce the code modification issue and the proposed correction are done in the same PR : [https://github . com/jenkinsci/jenkins/pull/4404]

o.v.nenashev@gmail.com (JIRA)

unread,
Jan 15, 2020, 7:10:19 AM1/15/20
to jenkinsc...@googlegroups.com
Oleg Nenashev resolved as Fixed
Change By: Oleg Nenashev
Status: Open Resolved
Resolution: Fixed
Released As: Jenkins 2.214

o.v.nenashev@gmail.com (JIRA)

unread,
Jan 15, 2020, 7:10:24 AM1/15/20
to jenkinsc...@googlegroups.com
Oleg Nenashev commented on Bug JENKINS-60579
 
Re: Impossible to have an invisible property on View that is persisted on save

A. Jard if you would like ti get it backported to LTS, please mark it as an LTS candidate

Reply all
Reply to author
Forward
0 new messages