-
Notifications
You must be signed in to change notification settings - Fork 185
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-73948] Extract inline JavaScript from LockableResourcesRootAction/tableQueue/table.jelly
#719
Conversation
…ction/tableQueue/table.jelly
<script type="text/javascript">notificationBar.show('${%queue.warning.count(queue.getAll().size(), h.getTimeSpanString(oldestQueue.getQueuedTimestamp()))}', notificationBar.WARNING)</script> | ||
<span class="lockable-resources-queue-too-long-message" | ||
data-warning-message="${%queue.warning.count(queue.getAll().size(), h.getTimeSpanString(oldestQueue.getQueuedTimestamp()))}" | ||
style="display:none"/> |
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.
Could you please give me your opinion about two issues:
- In [JENKINS-73891] Extract inline JS in
ConfigFilesUI/edit.jelly
andConfigFilesUI/show.jelly
config-file-provider-plugin#342 we're using an invisible entry rather thandisplay: none
. Which is preferable and why? If they are more or less the same, then I don't have a strong preference which one we follow, but I do prefer that this project's PRs be consistent with each other. That way, we are less likely to have strange bugs caused by inconsistent implementation strategies. - In [JENKINS-73891] Extract inline JS in
ConfigFilesUI/edit.jelly
andConfigFilesUI/show.jelly
config-file-provider-plugin#342 we aren't putting a class attribute but instead usingconst contentTypeElement = document.querySelector("span[data-content-type]")
. Similar question as to which is preferable, and if we had to pick a project-wide convention, which would it be?
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 me everything that's inside the
form
tag lib semantically belongs to forms. We do not do anything with forms here, we only want something to hold data that we use in scripts. So if we speak only about holding data I'd stick to spans. - I think we should use classes and stay away from sometimes overcomplicated selectors. Class selectors are concise understandable by everyone. In case
js
files live far away fromjelly
ones having a class name it is trivially easy to find all parts of the equation. With classes we are better protected against potential future markup changes. Someone may introduce new element that may be unintentionally targeted by those fancy selectors. It is less likely that someone will add a very specific class name to their element unless they know what they're doing.
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.
So regarding 1), your preference would be to use a span
with display: none
when there is a form and a span
without display: none
inside of an invisibleEntry
when there is not a form? Or would you want to use a span
with display: none
with or without a form? Or am I misunderstanding and your preference is for something else entirely?
Regarding 2), I agree with the argument about avoiding fragility.
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 wouldn't use invisibleEntry
at all for the sake of holding data for JavaScript.
From its doc:
Invisible
<f:entry>
type. Useful for adding hidden field values.
Would use it that same way entry
is used, but when I don't want the field to be visible. E.g. hold a CSRF key in a form that has to be submitted with the form, but we don't want anyone to tamper with it.
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!
LockableResourcesRootAction/tableQueue/table.jelly
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 the PR!
See JENKINS-73948.
Testing done
Took an example pipeline from the plugin page:
Firing 2 of such pipelines is enough to make the second one queue for a resource.
For the part that shows a warning notification (that was broken before the change) I've modified this line to make the notification appear faster.
https://www.loom.com/share/cecff681e8f3470fbde067c89430fe00?sid=98596835-70b6-4e2e-9561-9733a91ba64c
https://www.loom.com/share/199c7ed9269c4d879782fa3271ad3049?sid=515ece01-6a67-4475-a851-9a978c60f0bc
Submitter checklist
@NoExternalUse
. In case it is used by non java code theUsed by {@code <panel>.jelly}
Javadocs are annotated.eval
to ease the future introduction of Content Security Policy (CSP) directives (see documentation).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).