Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display value selector #85

Merged
merged 9 commits into from
Oct 21, 2021
Merged

Conversation

rolaca11
Copy link
Contributor

@rolaca11 rolaca11 commented Aug 12, 2021

Description

implements #81

Changes

added a new field to Item class, replaced string list of options to Item list. In the end, the HTML Option tag has the value expression in its value property and the string displayed is the displayValue field.

Issues

Didn't test for xPath. Code's probably terrible, first time working with Jenkins plugins and their dependencies

…t display value to the one included in env variables
@rolaca11 rolaca11 requested a review from a team as a code owner August 12, 2021 20:09
@h1dden-da3m0n h1dden-da3m0n added feature This PR introduces a new feature breaking This PR introduces breaking changes labels Aug 12, 2021
Copy link
Contributor

@h1dden-da3m0n h1dden-da3m0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution here, much appreciated!
Left a few comments on the things that I would like to discuss before giving it a green check ;)

@@ -20,7 +20,7 @@
<select id="${id}-select" class="setting-input" name="value">
<j:forEach var="value" items="${it.values}" varStatus="loop">
<f:option value="${value}" selected="${value.equals(it.defaultValue)}">
${value}
${value.displayValue}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while something fancy like select element templating is a option with Select2 I guess this works for now

@rolaca11
Copy link
Contributor Author

lmk if I missed something, or if you have any more comments

@h1dden-da3m0n
Copy link
Contributor

Thank you for the update I will give this another review either today or tomorrow!

@h1dden-da3m0n h1dden-da3m0n self-requested a review August 15, 2021 16:43
Copy link
Contributor

@h1dden-da3m0n h1dden-da3m0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far so good, sorry for not noticing the re-run issue lat time around. But other than that I didn't notice any problem besides the other nitpick.

@rolaca11
Copy link
Contributor Author

rolaca11 commented Sep 4, 2021

Sorry for the late update, took a long vacation and it's hard to get back on the grind :D

@h1dden-da3m0n
Copy link
Contributor

h1dden-da3m0n commented Sep 4, 2021

Welcome back! No worries, I am currently fighting with the Jenkins Infra, cause it refuses to publish 1.4.2, but I will have a look over your changes once that is dealt with.

edit1: just found the reason why I cant release, but am non the wiser https://groups.google.com/g/jenkinsci-dev/c/1-46eS41y6I 😞

edit2: now I know why https://www.jenkins.io/blog/2021/09/04/wiki-attacked and until that situation has been dealt with I am stuck with my local copy waiting to release 1.4.2 to the Jenkins repo.

# Conflicts:
#	src/main/java/io/jenkins/plugins/restlistparam/RestListParameterDefinition.java
@rolaca11
Copy link
Contributor Author

rolaca11 commented Sep 5, 2021

edit2: now I know why https://www.jenkins.io/blog/2021/09/04/wiki-attacked and until that situation has been dealt with I am stuck with my local copy waiting to release 1.4.2 to the Jenkins repo.

That sounds terrible, hope they can figure it out soon.

PS.: In the meantime, I have a proposal for the server paging problem. It turns out to be kinda difficult, but I do have an immature version that works with nexus flawlessly. It can be found in my fork on the feature/82 branch. I didn't create a PR for it because that feature is built on this PR and also it does need to be enhanced a bit, and I wanted to get your input on the matter first.

@h1dden-da3m0n
Copy link
Contributor

PS.: In the meantime, I have a proposal for the server paging problem. It turns out to be kinda difficult, but I do have an immature version that works with nexus flawlessly. It can be found in my fork on the feature/82 branch. I didn't create a PR for it because that feature is built on this PR and also it does need to be enhanced a bit, and I wanted to get your input on the matter first.

NGL I spotted that yesterday, and thank you for exploring that feature!
Are you okay with waiting for my input until this PR is in? It would make things easier IMHO, as we could utilize the review process to exchange comments.

So far, from my glance over it I think your changes look like they follow a direction I wanted to explore with that feature, but I will refrain further comment as I really only glanced over the changes.

@rolaca11
Copy link
Contributor Author

rolaca11 commented Sep 5, 2021

Of course, I'm okay with that. I just wanted to bring this to your attention. It already does what I need it to do, but I'd like it to be something more than just a selfish endevour

@h1dden-da3m0n
Copy link
Contributor

was able to release 1.4.2 today. I will be reviewing this PR on the weekend 😉

@h1dden-da3m0n
Copy link
Contributor

Hey @rolaca11, I now managed to look at your changes here again. I ran into a couple of minor things that I would like to commit back to you here and discuss if you are alright with that?
Alongside, those minor things I might have stumbled onto something more problematic though, that I need some more time to pinpoint if we can fix. To be precise its related to how this changes the createValue functions and wether the values list is empty or not.

@rolaca11
Copy link
Contributor Author

Of course, hit me. It's your codebase, your calls :D

@h1dden-da3m0n
Copy link
Contributor

Of course, hit me. It's your codebase, your calls :D

I just prefer asking before writing to pls branches ;) this now 'works' from a to z (Re-Build included, sorry for focusing on that one xD)

However, I ran into an interesting side effect of the change to rely on the values list being set within the createValue functions, that can lead to a IndexOutOfBounds. Still trying to tracking that down, but seems for now to be only for 'legacy' runs to give of the behaviour 🤔

@rolaca11
Copy link
Contributor Author

However, I ran into an interesting side effect of the change to rely on the values list being set within the createValue functions, that can lead to a IndexOutOfBounds. Still trying to tracking that down, but seems for now to be only for 'legacy' runs to give of the behaviour thinking

I don't think I get what you're saying, does it cause problems when upgrading to the new version of this plugin, or some legacy Jenkins versions?

@h1dden-da3m0n
Copy link
Contributor

Sorry, I hoped to have properly tested this over the past week but life got in my way. Anyway, I was referring to upgrading from prior version of this plugin. I will continue to be busy for the next couple of days unfortunately, but I will try to get back to this as soon as possible

@h1dden-da3m0n
Copy link
Contributor

Okay, sorry again for taking ages with your PR. I now have figured out what it is that breaks, but have not yet found a suitable fix for it. (at least not one I am comfortable with)

It is save to say that my originally proposed idea of referencing just the index in the values list is not a good idea when trying to rebuild a job. so the value has to be passed directly, however, I really have a problem with dumping that json directly into the value property of the select element 🤔

@h1dden-da3m0n
Copy link
Contributor

h1dden-da3m0n commented Oct 17, 2021

Found some time this weekend to look a bit further into this and here my findings:

  • The odd behaviour with Re-Runs I described in an earlier comment is an up till now unnoticed bug irrelevant to your PR
  • I think there might be a better solution for how to store the display value, but I am currently just testing what I have thought up
  • once I have that tested out and decided I will push some final changes and then merge your PR

Thank you for your contribution and patience with me!

edit: while diving into this a bit more I came very close ripping out XML entirely from the plugin cause WHO IN THEIR RIGHT MIND STILL USES XML AS THEIR REST RETURN VALUE IN 2021!? (it is save to assume I got a bit tilted testing for XML)

@rolaca11
Copy link
Contributor Author

Nice, thanks for your time and help and all that.

I'm happy to help you with something in connection with the PR if you have anything

@h1dden-da3m0n h1dden-da3m0n mentioned this pull request Oct 18, 2021
@h1dden-da3m0n h1dden-da3m0n added the minor Merging this PR leads to a minor version increment label Oct 18, 2021
@h1dden-da3m0n
Copy link
Contributor

h1dden-da3m0n commented Oct 18, 2021

@rolaca11 I just pushed my 'refactor' for the display value logic. If you could take one further look over the changes and give me feedback or fix any glaring issue you may find, I would really appreciate it!

You may also notice that I added a notice that XML is not supported, as neither your nor my code is able to handle it. It drove me crazy yesterday and lead to decision that lead to #99.

edit

I should mention that your solution would have allowed for the sub expression to work, in a way, however the output of a XML sub object with or without a display expression would look something like this:

'Input'

<row>
  <name>v10.6.4</name>
  <zipball_url>https://api.github.com/repos/jellyfin/jellyfin/zipball/v10.6.4</zipball_url>
  <tarball_url>https://api.github.com/repos/jellyfin/jellyfin/tarball/v10.6.4</tarball_url>
  <commit>
    <sha>b49cd1d3017f23fc75703829ac2ea1d45d8a4881</sha>
    <url>https://api.github.com/repos/jellyfin/jellyfin/commits/b49cd1d3017f23fc75703829ac2ea1d45d8a4881</url>
  </commit>
  <node_id>MDM6UmVmMTYxMDEyMDE5OnJlZnMvdGFncy92MTAuNi40</node_id>
</row>

in a pipeline the parameter value would look like this:

  v10.6.4
  https://api.github.com/repos/jellyfin/jellyfin/zipball/v10.6.4
  https://api.github.com/repos/jellyfin/jellyfin/tarball/v10.6.4
    b49cd1d3017f23fc75703829ac2ea1d45d8a4881
    https://api.github.com/repos/jellyfin/jellyfin/commits/b49cd1d3017f23fc75703829ac2ea1d45d8a4881
  MDM6UmVmMTYxMDEyMDE5OnJlZnMvdGFncy92MTAuNi40

(because of the behaviour that getTextContent() has and the lack of an alternative)

@rolaca11
Copy link
Contributor Author

oo, now I see why this isn't compatible at all with XML stuff... nice catch. I see no obvious issues with your latest commits, so if you think it can go in, I think it can go in as well.

Copy link
Contributor

@h1dden-da3m0n h1dden-da3m0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM now. Thank you again for your contribution rolaca!

@h1dden-da3m0n h1dden-da3m0n merged commit 64dac20 into jenkinsci:main Oct 21, 2021
@h1dden-da3m0n h1dden-da3m0n changed the title #81 add a displayExpression property, that allows a different display value to the one included in env variables feat: display value selector Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This PR introduces breaking changes feature This PR introduces a new feature minor Merging this PR leads to a minor version increment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants