Re: Trouble with dynamically updating Jelly textbox

2023-03-30 Thread 'Daniel Beck' via Jenkins Developers
On Fri, Mar 31, 2023 at 5:43 AM Dane Wrye  wrote:

> Hey All,
>
> I am a new to Jenkins/Jelly and trying to pick it up as I add
> functionality to a new codebase. With that said, I am looking at
> dynamically updating a textbox on my form when the selected option of a
> select element changes. I think I am 90% of the way there, but need a
> little bit of help to push me to 100%. To do this, I am currently
>
> a.) Calling a javascript function, updateTextbox(stringToUpdateWith), that
> overwrites the textbox in question's current value with stringToUpdateWith.
> It is called onChange from the select element.
> b.) Calling a backend java function,
> getStringToUpdateWith(selectedOption), which takes in the current option
> from the HTML select element as a parameter and returns the string I want
> to update my textbox with
> c.) Getting the currently selected option in my HTML select element, with
> the following code: this.options[this.selectedIndex].text
>
> Now, it gets a little messy: all this code is squished together in the
> select element's onChange, as I want to update the textbox whenever the
> select element is changed.
>
> All together, the line of code looks like this:
>  onChange="updateTextbox('${instance.getStringToUpdateWith(this.options[this.selectedIndex].text)}')"/>
>
> The onChange function, which is what I am currently having trouble with,
> looks like this:
>
> onChange="updateTextbox('${instance.getStringToUpdateWith(this.options[this.selectedIndex].text)}')"
>
> Debugging, it seems that the "this.options[this.selectedIndex].text" shows
> up in the getStringToUpdateWith function as an empty string. If I could get
> the selected option into this function as a parameter, I will have solved
> my problem. Any idea why it could be an empty string instead? I would
> appreciate any and all leads!
>

You're mixing JS (code evaluated by the browser) and Jelly/JEXL (code
evaluated by the server) in a way that doesn't work.

JEXL variables in Jelly get evaluated as the page is rendered the first
time (sent from server to browser). They don't update afterwards. I expect
you'll notice in a debugger you'll call your instance method once per page
load (assuming `instance` is bound to the correct value, another potential
source of problems), if at all, with an unexpected parameter, because
Jelly/JEXL cannot access JS/DOM variables.

Look into JavaScriptProxy to call Java methods from JS, e.g.
https://weekly.ci.jenkins.io/design-library/JavaScriptProxy/ ; or use fetch
from JS to call web methods (usually named doWhatever), passing the current
value as argument that is received as @QueryParameter annotated parameter
of the method.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CAMo7Pt%2BX%3DShtecsMbuLoZ%2BmkN3iSmsJA6qsadikTFb8CxEsD7w%40mail.gmail.com.


Trouble with dynamically updating Jelly textbox

2023-03-30 Thread Dane Wrye
Hey All,

I am a new to Jenkins/Jelly and trying to pick it up as I add functionality 
to a new codebase. With that said, I am looking at dynamically updating a 
textbox on my form when the selected option of a select element changes. I 
think I am 90% of the way there, but need a little bit of help to push me 
to 100%. To do this, I am currently

a.) Calling a javascript function, updateTextbox(stringToUpdateWith), that 
overwrites the textbox in question's current value with stringToUpdateWith. 
It is called onChange from the select element.
b.) Calling a backend java function, getStringToUpdateWith(selectedOption), 
which takes in the current option from the HTML select element as a 
parameter and returns the string I want to update my textbox with
c.) Getting the currently selected option in my HTML select element, with 
the following code: this.options[this.selectedIndex].text

Now, it gets a little messy: all this code is squished together in the 
select element's onChange, as I want to update the textbox whenever the 
select element is changed.

All together, the line of code looks like this:


The onChange function, which is what I am currently having trouble with, 
looks like this: 
onChange="updateTextbox('${instance.getStringToUpdateWith(this.options[this.selectedIndex].text)}')"

Debugging, it seems that the "this.options[this.selectedIndex].text" shows 
up in the getStringToUpdateWith function as an empty string. If I could get 
the selected option into this function as a parameter, I will have solved 
my problem. Any idea why it could be an empty string instead? I would 
appreciate any and all leads! 

Thanks for your time,
Dane

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/90f7889e-0bb6-45f3-9ea8-e004a208016dn%40googlegroups.com.


Re: Updating Plugin Maintainer

2023-03-30 Thread Alexander Brandes
Hey Randall,

the information is based on the developers specified in the permission file 

 of 
your repository. You can fork the repository, modify the file and propose a 
PR to update the maintainers of your plugin.

Best regards,
Alex

On Thursday, 30 March 2023 at 16:04:08 UTC+2 rpet...@nowsecure.com wrote:

> Hi All,
>
> We would like to update the maintainer listed for our plugin at 
> https://plugins.jenkins.io/nowsecure-auto-security-test/ , it looks like 
> it is currently the last version generated from the now-defunct wiki. If we 
> were to update our information in Jira, would that update the name on the 
> page? Or will we need to update to using the Github documentation to make 
> changes?
>
> Thanks,
> Randall
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/24e18d78-4620-4b68-83a8-4ae6fd90ba77n%40googlegroups.com.


Updating Plugin Maintainer

2023-03-30 Thread Randall Peterson
Hi All,

We would like to update the maintainer listed for our plugin 
at https://plugins.jenkins.io/nowsecure-auto-security-test/ , it looks like 
it is currently the last version generated from the now-defunct wiki. If we 
were to update our information in Jira, would that update the name on the 
page? Or will we need to update to using the Github documentation to make 
changes?

Thanks,
Randall

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/96833fa2-b28e-42e9-84ba-a60652caa418n%40googlegroups.com.


Re: Prototype.js replacing JSON.stringify

2023-03-30 Thread Tim Jacomb
There's a draft PR open at https://github.com/jenkinsci/jenkins/pull/7781
It does almost all of core.

There were one or two more complicated ones I left for later.

This search shows the rest of the jenkinsci hosted plugins as well:
https://github.com/search?q=org%3Ajenkinsci+Ajax.Request++NOT+repo%3Ajenkinsci%2Fjenkins+=code=1

If anyone wants to help they could either test the above pull request or
submit some pull requests to other plugins.

Thanks
Tim

On Tue, 14 Mar 2023 at 08:06, Tim Jacomb  wrote:

> I've made a start:
> https://github.com/jenkinsci/jenkins/pull/7727
>
> This PR is also removing some prototype as well:
> https://github.com/jenkinsci/jenkins/pull/7718
>
> On Mon, 13 Mar 2023 at 22:27, 'Gavin Mogan' via Jenkins Developers <
> jenkinsci-dev@googlegroups.com> wrote:
>
>> My knowledge of core is pretty out dated, but as far as I know, a lot of
>> the behaviors are defined using YUI and Prototypejs
>> I think the first steps would be to remove as many of those references
>> from core before detaching the plugin and making it optional
>>
>> For example, the Ajax.Request would need to be re-written
>>
>> https://github.com/jenkinsci/jenkins/blob/a4447db3d88fd883b99ff3925a5ea90864794367/core/src/main/resources/lib/form/link/link.js#L15
>>
>> https://github.com/jenkinsci/jenkins/blob/a4447db3d88fd883b99ff3925a5ea90864794367/core/src/main/resources/lib/layout/breadcrumbs.js#L168
>>
>> I'm sure there's lots of other legacy items left behind.
>>
>> Talking about it is good, but unless people actually make PRs, it'll
>> never actually get replaced.
>>
>> On Sat, Mar 11, 2023, 8:01 PM 'Rahul Somasunderam' via Jenkins Developers
>>  wrote:
>>
>>> Is it possible to turn it into its own plugin and treat it as an
>>> implicit dependency for plugins relying on older versions of Jenkins, but
>>> remove it later?
>>>
>>>
>>> On Mar 11, 2023, at 15:37, Ullrich Hafner 
>>> wrote:
>>>
>>> I think I also have some problems with this ugly dependency. Seems that
>>> other JS libraries that rely on JSON stringify (datatables, echarts) break
>>> in some places as well :-(
>>>
>>> But this JS code is so deeply nested in Jenkins UI code that I have no
>>> clue on how to fix that...
>>>
>>>
>>> Am 02.03.2023 um 23:15 schrieb 'Gavin Mogan' via Jenkins Developers <
>>> jenkinsci-dev@googlegroups.com>:
>>>
>>> I vaguely remember some javascript code somewhere deleting
>>> Object.prototype.toJSON() or something
>>>
>>> A quick search found
>>> https://github.com/jenkinsci/jenkins/blob/e41aeaacf434b9ff93c8848f8eddbfcbb27ed462/war/src/main/js/util/jenkins.js#L20-L54
>>> In theory that makes JSON.stringify work again, but would make the other
>>> prototype js fail, so would have to be done temporarily.
>>>
>>>
>>> On Thu, Mar 2, 2023 at 1:59 PM Ullrich Hafner 
>>> wrote:
>>>

 Hi!
 I was looking at some javascript that was behaving differently on
 Jenkins than it does on other apps. I boiled it down to the simplest
 reproducible test case.
 It turned out that serialization was behaving differently when calling
 JSON.stringify.

 This is the sample code you can run on the Chrome DevTools

 JSON.stringify({ a: [1, 2, 3] });

 On Jenkins, this is the behavior

 '{"a":"[1, 2, 3]"}'

 On other apps, this is the behavior

 '{"a":[1, 2, 3]}'

 When I attempt to debug the code, stepping into `JSON.stringify` on
 Jenkins takes me to prototype.js.

 I've seen some threads here attempting not to rely on prototype.js for
 functionality, but how far are we from removing it?


 Very far. A couple of years ago I even tried to upgrade prototype.js to
 the latest version but failed, since some plugins are depending on
 prototype.js as well. All UI stuff is tightly coupled to prototype.js, this
 will be very hard to remove.


 - Rahul

 --
 You received this message because you are subscribed to the Google
 Groups "Jenkins Developers" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to jenkinsci-dev+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/jenkinsci-dev/708c6498-e0d4-481e-9ad7-e0a8e5af65ffn%40googlegroups.com
 
 .



 --
 You received this message because you are subscribed to the Google
 Groups "Jenkins Developers" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to jenkinsci-dev+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/jenkinsci-dev/76FFAC15-B00C-4528-8AB1-68ED0E6D7055%40gmail.com