-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
[JENKINS-70934] Remove Prototype usages from buildListTable.jelly
#7830
Conversation
Thanks!
FTR https://github.com/stapler/stapler-adjunct-timeline/blob/c092701bd2856444f5012532f8b1a6d00efef092/src/main/resources/org/kohsuke/stapler/simile/timeline.jelly and #6869 (although the latter might not strictly be necessary, haven't delved deep enough into the widget). |
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.
Thanks for using DOM instead of string concatenation!
core/src/main/resources/hudson/model/Job/buildTimeTrend_resources.js
Outdated
Show resolved
Hide resolved
core/src/main/resources/hudson/model/Job/buildTimeTrend_resources.js
Outdated
Show resolved
Hide resolved
I have no interest in accommodating your request. |
JS now works 👍 While not using |
commit 275eebc |
This PR is now ready for merge. We will merge it after ~24 hours if there is no negative feedback. |
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.
As I don't think this PR satisfies the "low-risk" change from exception#3 due to the regressions previously found in the PR, I preferred to just review the PR and approve it to move forward with the two approvals.
I manually tested the change, everything I tried was as expected 👍 Including, the onClick handler, the parentFullDisplayName.
var a3 = document.createElement("a"); | ||
a3.classList.add("jenkins-table__button"); | ||
a3.href = rootUrl + "/" + e.url + "console"; | ||
a3.innerHTML = p.dataset.consoleOutputIcon; |
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.
For future readers, just in case, the dataset
contains the data-console-output-icon
attribute converted into consoleOutputIcon
. Don't be fooled by the Java variable in the jelly page that is called consoleOutputIcon
window.displayBuilds = function (data) { | ||
var rootUrl = document.head.getAttribute("data-rooturl"); | ||
var p = document.getElementById("projectStatus"); | ||
p.style.display = ""; |
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.
FTR this change is an inlining of the method from prototype.js:
jenkins/war/src/main/webapp/scripts/prototype.js
Lines 1983 to 1987 in 38d3a27
show: function(element) { | |
element = $(element); | |
element.style.display = ''; | |
return element; | |
}, |
@@ -122,3 +122,85 @@ function generateSVGIcon(iconName, iconSizeClass) { | |||
|
|||
return span; | |||
} | |||
|
|||
/** | |||
* Public method to be called by progressiveRendering's callback |
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.
FYI this is the same comment as the first method in this file, which is used for the global build trend.
Not ideal, but not blocking.
See JENKINS-70934 Remove Prototype usages from buildListTable.jelly
Context
See JENKINS-70906. Jenkins core currently uses Prototype 1.7, released on November 15, 2010. The latest version is Prototype 1.7.3, released on September 22, 2015. When an attempt was made to upgrade to 1.7.3 in 2018 in JENKINS-49319, the change had to be reverted. Since this library has been unmaintained for the past 8 years, we ought to eliminate our dependency on it in favor of modern JavaScript APIs.
Problem
See JENKINS-70934. Usages of Prototype remain in
buildListTable.jelly
.Solution
Replace these usages with modern JavaScript APIs.
Bonus
While I was here I fixed two CSP warnings by moving this code out of Jelly and into a JavaScript file.
Testing done
Ran
mvn clean verify -Dtest=jenkins.widgets.BuildTimeTrendTest,jenkins.widgets.BuildListTableTest
. Verified interactively in the UI that the build time trend and the Computer view could still display the list correctly, and clicked on the console link successfully. Verified that thescript-src-attr
/inline
/javascript:tl.getBand(0).scrollToCenter(…
andscript-src-elem
/inline
/function displayBuilds(data) {
CSP warnings were present before this PR and gone after this PR. Noted that thescript-src-elem
/inline
/Timeline.DateTime…
CSP warning was present before and after this PR; this is technical debt that I am explicitly declining to clean up in this PR.Proposed changelog entries
N/A
Proposed upgrade guidelines
N/A
Submitter checklist
@Restricted
or have@since TODO
Javadocs, as appropriate.@Deprecated(since = "TODO")
or@Deprecated(forRemoval = true, since = "TODO")
, if applicable.eval
to ease future introduction of Content Security Policy (CSP) directives (see documentation).Desired reviewers
@mention
Maintainer checklist
Before the changes are marked as
ready-for-merge
:upgrade-guide-needed
label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).lts-candidate
to be considered (see query).