-
Notifications
You must be signed in to change notification settings - Fork 34
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-73968] Extract event handler in QuickDiskUsagePlugin/sidepanel.jelly
#113
Merged
+16
−12
Merged
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
10c26a8
Require 2.440.3 as minimum Jenkins version
shlomomdahan 34437e5
extract JS in sidepanel.jelly - use updated <l:task>
shlomomdahan b39c027
extract JS in sidepanel.jelly - use updated <l:task>
shlomomdahan b606078
address comments
shlomomdahan 61137eb
address comments
shlomomdahan d2e4208
use xhr instead of fetch
shlomomdahan 513ab4f
remove comments
shlomomdahan 1d46553
remove comments
shlomomdahan 449a69b
Merge branch 'master' into JENKINS-73968
PierreBtz 1e53003
use fetch api
shlomomdahan 1c171fa
use fetch api
shlomomdahan 3aee937
Merge remote-tracking branch 'origin/JENKINS-73968' into JENKINS-73968
shlomomdahan 44f6c00
use fetch api
shlomomdahan cf981c9
use fetch api
shlomomdahan 161b4fd
use fetch api - remove explicit header
shlomomdahan c33593b
Fix functionality
basil a08412e
Use notification bar to show proper colors
basil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/resources/com/cloudbees/simplediskusage/QuickDiskUsagePlugin/refresh-disk-usage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function refreshDiskUsage(a) { | ||
|
||
var xhr = new XMLHttpRequest(); | ||
xhr.open("POST", "refresh", true); | ||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); | ||
|
||
var headers = crumb.wrap({}); | ||
xhr.setRequestHeader("Jenkins-Crumb", headers['Jenkins-Crumb']); | ||
|
||
xhr.send(); | ||
|
||
hoverNotification('Refresh scheduled', a.parentNode); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It feels a bit weird to me that we're switching to older APIs.
Regarding the errors that you're getting with
fetch
my guess is that the execution order is different in old and new version.callback
sounds like something that will be executed after the main action, which is following the href in case of anchor tag. While inonclick
that JavaScript would be executed before following the href.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.
Yaroslav's explanation seems spot on. I just checked and couldn't reproduce the issue.
I cannot say I'm thrilled to go back to an older API :/
Unfortunately since I couldn't reproduce on 2 different browsers, I'm having a hard time giving additional advice. What's for sure is that, as Basil said, we do not want to catch and drop every error, it's bad and might hide a real issue.
What we could consider, however, is to handle this specific error if we understand it.
Do you have additional details about the exception? When the exception is thrown, is the POST request still sent?
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.
@PierreBtz
I tested the issue in Chrome and was unable to reproduce it. It appears this issue is specific to Safari, and I apologize for not testing in other browsers earlier. The error details were quite limited, but it's clear that Safari was causing the problem, even though the server handled the page refresh correctly, and the POST requests were sent without issue.
In Chrome, the fetch API works as expected.