-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
Hacktoberfest [JENKINS-66730] Un-inlining AsynchPeople/index.jelly #5835
Hacktoberfest [JENKINS-66730] Un-inlining AsynchPeople/index.jelly #5835
Conversation
|
||
var d = document.createElement('td'); | ||
var a = document.createElement('a'); | ||
a.href = '${rootURL}/' + e.url; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think rootURL is available like this, cc @Wadeck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks to be the same issue as #5787 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this link could be relative instead of using ${rootURL}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful, the ${rootURL} is NOT the root URL :'( it's the contextPath.
jenkins/core/src/main/java/hudson/Functions.java
Lines 278 to 285 in 632033d
String rootURL = currentRequest.getContextPath(); | |
Functions h = new Functions(); | |
context.setVariable("h", h); | |
// The path starts with a "/" character but does not end with a "/" character. | |
context.setVariable("rootURL", rootURL); |
(yes this is crappy :D)
a.className = 'model-link inside'; | ||
var i = document.createElement('img'); | ||
i.src = e.avatar; | ||
i.className = 'icon${iconSize}'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this ${iconSize}
an issue too maybe ?
Thanks @P4uline for the contribution :) For the variables, you have to use https://www.jenkins.io/doc/developer/security/xss-prevention/#passing-values-to-javascript to pass the value from Java context to JavaScript. In this particular PR, you're lucky that rootURL is provided by layout.jelly#L103. You can do something similar to buildTimeTrend_resources.js#L7 to retrieve the value stored by the layout.jelly. For the iconSize, you're unlucky ^^ It's a bit more complicated. The variable is defined by (t:setIconSize)[https://github.com/jenkinsci/jenkins/blob/ae557780a59d372d09dc71a5490da98b577da397/core/src/main/resources/hudson/model/View/AsynchPeople/index.jelly#L29], which create a variable inside the context of the page. To get access to this variable, you have to set its value as explained in the first link from this comment. You can change the 💡 I recommend that you test your code when you are updating pages, for example this feature is available at http://localhost:8080/jenkins/asynchPeople/ and you can see the different variables not being replaced by the expected value. I hope that the explanations are clear otherwise just ask questions ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure this PR is not merged as is, the variables are not replaced as expected.
💡 I updated the "submitter" checklist, it's expected to be filled by the author ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core/src/main/resources/hudson/model/View/AsynchPeople/index.jelly
Outdated
Show resolved
Hide resolved
core/src/main/resources/hudson/model/View/AsynchPeople/index.jelly
Outdated
Show resolved
Hide resolved
…elly Co-authored-by: Wadeck Follonier <Wadeck@users.noreply.github.com>
…elly Co-authored-by: Wadeck Follonier <Wadeck@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new version looks mfine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not manually re-tested but the change is what I expected, thanks for the changes! 🚀
This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback. Thanks! Will merge in time for weekly if no objections |
See JENKINS-66730.
Proposed changelog entries
Proposed upgrade guidelines
N/A
Submitter checklist
Proposed changelog entries
section only if there are breaking changes or other changes which may require extra steps from users during the upgradeDesired reviewers
@mention
Maintainer checklist
Before the changes are marked as
ready-for-merge
:Proposed changelog entries
are correctupgrade-guide-needed
label is set and there is aProposed upgrade guidelines
section in the PR title. (example)lts-candidate
to be considered (see query).