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

[JENKINS-60866] Advanced button, build health, confirmation link, URI encoding monitor #5515

Merged
merged 5 commits into from
Nov 4, 2021

Conversation

daniel-beck
Copy link
Member

@daniel-beck daniel-beck commented May 22, 2021

See JENKINS-60866.

Testing Notes

  • confirmationLink is e.g. the "Reload from Disk" item on /manage, the script controls the confirmation dialog.
  • buildHealth is the weather column and the weather icon in the build history title, the script controls hover behavior.
  • URICheckEncodingMonitor is only available on /manage. It shows fairly easily for me (who has Latin 1?) but the error I could only trigger by changing params in JS so that actual/expected are different. The monitor has nonstandard appearance since we styled them differently from 1.x, out of scope for this.
  • advanced is the script that controls whether the "something was edited" message appears to the left of the button; this is trivially the case with Mailer plugin's "Send a test email" misuse of this control.

Proposed changelog entries

  • Entry 1: Issue, Human-readable Text
  • ...

Proposed upgrade guidelines

N/A

Submitter checklist

  • (If applicable) Jira issue is well described
  • Changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developer, depending on the change). Examples
    • Fill-in the Proposed changelog entries section only if there are breaking changes or other changes which may require extra steps from users during the upgrade
  • Appropriate autotests or explanation to why this change has no tests
  • For dependency updates: links to external changelogs and, if possible, full diffs

Desired reviewers

@mention

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • There are at least 2 approvals for the pull request and no outstanding requests for change
  • Conversations in the pull request are over OR it is explicit that a reviewer does not block the change
  • Changelog entries in the PR title and/or Proposed changelog entries are correct
  • Proper changelog labels are set so that the changelog can be generated automatically
  • If the change needs additional upgrade steps from users, upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the PR title. (example)
  • If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

@daniel-beck daniel-beck requested a review from Wadeck May 22, 2021 08:50
@daniel-beck daniel-beck mentioned this pull request May 22, 2021
10 tasks
@daniel-beck daniel-beck added the squash-merge-me Unclean or useless commit history, should be merged only with squash-merge label May 22, 2021
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

@daniel-beck daniel-beck changed the title [JENKINS-60881] Advanced button, build health, confirmation link, URI encoding monitor [JENKINS-60866] Advanced button, build health, confirmation link, URI encoding monitor May 24, 2021
@daniel-beck
Copy link
Member Author

@timja Thanks, updated.

Copy link
Contributor

@Wadeck Wadeck left a comment

Choose a reason for hiding this comment

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

The missing wrapping behavior could be potentially problematic but I have no examples to demonstrate that :-)


🐛 Only one where I have serious doubts about is the healthReport in the widget. The adjunct seems not loaded/effective.

Working proofs In case something was wrong but I was not aware :p

URICheckEncodingMonitor

Screenshot_2021-05-25_080338_001

Advanced button

Screenshot_2021-05-25_081400_001

Validate button

Screenshot_2021-05-25_081923_001

BuildHealth in the job table

The effect is working fine and the adjunct is inserted.

Hover working thanks to the added/removed class

Screenshot_2021-05-25_084151_001

Adjunct added as expected

Screenshot_2021-05-25_084250_001

Confirmation link

Screenshot_2021-05-25_103020_001

Not working proofs

🐛 BuildHealth in the left widget

[Disclaimer] To see anything, you need to have at least one build in the history of the job you are looking, otherwise the tooltip will not exist.

The effect is working because of :hover, not because of the .hover class added/removed by the script.
The script itself does not seem to be loaded, even if using the debugging I saw the code from AdjunctsInPage#generate being called.

💡 AFAICT the problem is coming from the widget/ajax nature of that feature.

Be careful, the "desired effect" is working, but not in the way you would expect, and thus could lead to other errors in the future that will be very complicated to solve as the code will "seem to work".

No hover, but tooltip displayed thanks to :hover

Screenshot_2021-05-25_083523_001

No adjunct for BuildHealth

Screenshot_2021-05-25_083849_001

On ci.jenkins.io

As you can see, the hover class is added and you can even see the mouseenter/out event inlined at that point.

Screenshot_2021-05-25_084447_001

Debug information

I compared the confirmationLink adjunct with the buildHealth. The first one is included correctly in the page, compared to the second that is not. The difference I have seen is about the out, being an HTMLWriterOutput for confirmationLink (and all other adjuncts) and an XMLOutput for buildHealth.

Screenshot_2021-05-25_091103_001

Screenshot_2021-05-25_091114_001

Debug with intelligence (headache included for free 🎁)

We are changing HTMLWriterOutput to XMLOutput in the frames at ParseTag#parseBody:

Screenshot_2021-05-25_091530_001

More precisely at HistoryWidget/index.jelly#L28, that is then executed in HistoryWidget/index.jelly#L62.

The problem is that AdjunctsInPage#generate is writing the script "directly" to the output, meaning in text instead of as a tag. When the ParseTag#parseBody does the endDocument, it erases the textBuffer and so, delete the just added script. To correct this behavior we should write the script as a tag, like:

Screenshot_2021-05-25_100924_001

Which, is working fine.

💡 The quick workaround is to call manually the adjunct from buildHealth before the f:parse (manualy tested).

@@ -0,0 +1,3 @@
Behaviour.specify('.Behaviour-validateButton', 'Behaviour-validateButton', 0, function(element) {
element.onclick = function() { safeValidateButton(this); };
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Compared to current behavior, this could be executed after another script that is taken care of the existing onClick and wrap it, to have 2 listeners. Leading to erasing the previously (other) registered listener.

I am not aware of any of those for validateButton.onClick in Jenkins from memory, but if that could trigger someone's memory, that could be nice :)

Example of wrapping behavior: UploadedKeyStoreSource/config.jelly#L50-L55, AFAICT this one is executed after "inline" (like current) and Behaviour (proposed one).

core/src/main/resources/lib/hudson/buildHealth.jelly Outdated Show resolved Hide resolved
@@ -0,0 +1,18 @@
Behaviour.specify("A.confirmation-link", 'confirmation-link', 0, function (element) {
element.onclick = function(event) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as for validateButton

@oleg-nenashev
Copy link
Member

@Wadeck did you have a chance to re-review it?

Copy link
Contributor

@Wadeck Wadeck left a comment

Choose a reason for hiding this comment

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

Working fine and correctly now, thanks for the correct 👍

@oleg-nenashev oleg-nenashev added the skip-changelog Should not be shown in the changelog label Oct 15, 2021
Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Approved once the merge conflict is resolved

@timja timja added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Oct 15, 2021
@timja
Copy link
Member

timja commented Oct 15, 2021

This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback.

Thanks!

@daniel-beck
Copy link
Member Author

Working fine and correctly now, thanks for the correct 👍

@Wadeck I noticed this PR still removes https://github.com/jenkinsci/jenkins/pull/5515/files#diff-633560a936835daf74727cace9bff8b456cce93c71f367710bd7865ff3d4d311L41-L43, do you know whether this is fine? I do not remember 😞

@daniel-beck daniel-beck removed the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Oct 15, 2021
Copy link
Contributor

@Wadeck Wadeck left a comment

Choose a reason for hiding this comment

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

(from Daniel) do you know whether this is fine? I do not remember 😞

(from my previous tests) The effect is working because of :hover, not because of the .hover class added/removed by the script.

So, it's a cleanup => 👍

Also, I checked the related CSS to this "feature", it's expecting any of :hover or .hover. So another cleanup task could be to remove the .hover part as a follow-up :) (code: style.less#L787-L792

(additional manual testing with the new BuildHistory from Jan 🎉)

@Wadeck Wadeck added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Nov 1, 2021
@timja timja merged commit 791447a into jenkinsci:master Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback skip-changelog Should not be shown in the changelog squash-merge-me Unclean or useless commit history, should be merged only with squash-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants