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

Move (most) javascript out of jelly files #76

Merged
merged 1 commit into from
Jul 4, 2023

Conversation

rahulsom
Copy link

We're limited in what we can do in jelly files.
There are tests that use HtmlUnit and it does not support enough modern JS features.

This change will allow us to use modern JS to write code, and transpile it to something that all the older browsers support and HtmlUnit does not error out.

This is built on top of #75

Testing done

This is a pure refactor. No new functionality is added. All existing tests pass.
The code that was moved from jelly to js has a lot of dependencies.
We'll need more refactoring before we can test it independently.

Submitter checklist

Preview Give feedback

pom.xml Outdated
Comment on lines 200 to 202
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.12.1</version>
Copy link
Member

Choose a reason for hiding this comment

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

This configuration is already provided in the parent POM if you check in a blank .mvn_exec_node file:

https://github.com/jenkinsci/plugin-pom/blob/a60e3494e8447aefed562deace5d222e4777413a/pom.xml#L1128-L1198

@basil
Copy link
Member

basil commented Jun 23, 2023

You don't have to switch to NPM, either: the plugin parent POM has a corresponding .mvn_exec_yarn feature.

@rahulsom
Copy link
Author

You don't have to switch to NPM, either: the plugin parent POM has a corresponding .mvn_exec_yarn feature.

I don't have strong feelings one way or the other. I'll leave it at NPM for now unless @basil or @kinow feel strongly about either tool.

@basil
Copy link
Member

basil commented Jun 23, 2023

Core uses Yarn, but for individual plugins it is up to the maintainer.

@kinow
Copy link
Member

kinow commented Jun 25, 2023

(sorry, other merges caused some conflicts here)

@rahulsom
Copy link
Author

NP. I'll clean this up after #75 is merged.

We're limited in what we can do in jelly files.
There are tests that use HtmlUnit and it does not support enough modern JS features.

This change will allow us to use modern JS to write code, and transpile it to something that all the older browsers support and HtmlUnit does not error out.
@rahulsom rahulsom force-pushed the move-js-out-of-jelly branch from 66862ae to fe12cfd Compare July 3, 2023 23:07
@rahulsom
Copy link
Author

rahulsom commented Jul 4, 2023

@kinow This is now ready for review. Thanks!

@@ -363,7 +363,7 @@ var UnoChoice = UnoChoice || ($ => {
$(".behavior-loading").show();
// start updating in separate async function so browser will be able to repaint and show 'loading' animation , see JENKINS-34487
setTimeout(() => {
_self.cascadeParameter.update();
_self.cascadeParameter.update(false);
Copy link
Member

Choose a reason for hiding this comment

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

The other changes were easier to review. This one is the only one I didn't understand straight away. Could you explain why the false added here?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry about that. The default value was undefined which was interpreted as false. This makes it explicit.

Copy link
Member

Choose a reason for hiding this comment

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

No need to apologize! I suspected you would have a reason for doing that. Thanks for the explanation. LGTM! 💥

@@ -363,7 +363,7 @@ var UnoChoice = UnoChoice || ($ => {
$(".behavior-loading").show();
// start updating in separate async function so browser will be able to repaint and show 'loading' animation , see JENKINS-34487
setTimeout(() => {
_self.cascadeParameter.update();
_self.cascadeParameter.update(false);
Copy link
Member

Choose a reason for hiding this comment

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

No need to apologize! I suspected you would have a reason for doing that. Thanks for the explanation. LGTM! 💥

@kinow kinow merged commit 85324da into jenkinsci:master Jul 4, 2023
kinow added a commit that referenced this pull request Jul 4, 2023
Changes for #76
@kinow
Copy link
Member

kinow commented Jul 4, 2023

@rahulsom thank you for your recent contributions. I think we got all your pull requests reviewed and merged, right? Shall I cut a new release with all the current changes in master? Or do you have anything you'd like to include?

@rahulsom
Copy link
Author

rahulsom commented Jul 4, 2023

Thanks @kinow ! I'm working on one last PR to remove the dependency on prototype. That should get this plugin ready for the next LTS.

@kinow
Copy link
Member

kinow commented Jul 4, 2023

Brilliant! Thanks heaps, I have a meeting with @imoutsatsos tomorrow to chat about Jenkins and about this plug-in -- he's the person who had the idea and initial design of how this plug-in should work, as well as designer of most of the functionality that he uses at his $job. Great timing for a new release soon before summer starts over here. The next PR's are a lot easier to review now that we have a lot more (and better) tests. Bruno.

@rahulsom rahulsom deleted the move-js-out-of-jelly branch July 4, 2023 20:45
@eplodn
Copy link

eplodn commented Jul 31, 2023

@rahulsom @kinow Could it be that this change has introduced JENKINS-71706 and JENKINS-71724?

Experiencing

[Log] Values retrieved from Referenced Parameters:  (UnoChoice.js, line 1)
[Error] SyntaxError: Unexpected token ','
	(anonymous function) (build:1067)
[Error] Failed to load resource: the server responded with a status of 403 (Forbidden) (UnoChoice.js.map, line 0)

Function:

                        <script type="text/javascript">
                        // source, references table
                        var referencedParameters = Array();


>>>                        UnoChoice.renderDynamicRenderParameter('#choice-parameter-12948928667198118', 'HEADING_FRONTEND_HIDDEN', 'choice-parameter-12948928667198118', referencedParameters, dynamicReferenceParameter);
                        </script>

@kinow
Copy link
Member

kinow commented Jul 31, 2023

@eplodn possibly, this SyntaxError could be because of this one, I think it was the only major change in JS, and the #79 , but that one wouldn't result in a SyntaxError, I think.

@rahulsom
Copy link
Author

JENKINS-71706 claims to be on 2.6.5. This change made it into 2.7.

@eplodn
Copy link

eplodn commented Jul 31, 2023

I have attached a minimal pipeline over at JENKINS-71724 that constantly works on 2.6.5 and mostly fails on 2.7.

Something about the parameters is strange, sometimes i see

                            UnoChoice.renderCascadeChoiceParameter('#choice-parameter-14260437059427953', , 'LEASE_TIME', 'choice-parameter-14260437059427953', 1, 'choice-parameter-14260437059427953', referencedParameters, cascadeChoiceParameter);

(note two , in a row.)

Sometimes I see


                        UnoChoice.renderCascadeChoiceParameter('#choice-parameter-14261231071587458', false, 'LEASE_TIME', 'choice-parameter-14261231071587458', 1, 'choice-parameter-14261231071587458', referencedParameters, cascadeChoiceParameter);

(note false at the previously empty place.)

Going into Configure - Save toggles it between a working and non-working state on 2.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants