Opened 9 years ago
Closed 9 years ago
#31769 closed enhancement (fixed)
Shiny Updates: Prevent navigating away while plugins are updating
Reported by: | johnbillion | Owned by: | jorbin |
---|---|---|---|
Milestone: | 4.2 | Priority: | normal |
Severity: | normal | Version: | 4.2 |
Component: | Upgrade/Install | Keywords: | has-patch commit |
Focuses: | javascript, administration | Cc: |
Description
We should have an onbeforeunload
event active while a plugin is being updated via shiny updates. Especially for bulk updates.
Attachments (4)
Change History (30)
This ticket was mentioned in Slack in #core by drew. View the logs.
9 years ago
#3
@
9 years ago
- Focuses javascript added
- Keywords has-patch dev-feedback added; needs-patch removed
In 31769.2.diff:
- leverage window.onbeforeunload to warn users navigating away while plugin updates still running
- remove onbeforeunload when all updates complete
Tested in firefox: does this work correctly in IE8?
This ticket was mentioned in Slack in #core by kraft. View the logs.
9 years ago
This ticket was mentioned in Slack in #core by drew. View the logs.
9 years ago
#9
follow-ups:
↓ 10
↓ 21
@
9 years ago
- Keywords needs-refresh added
This doesn't clear the onbeforeunload event if an error occurs with a plugin update.
It looks like wp.updates.updateLock = false;
needs to be called in wp.updates.updateError()
in the same way that it is in wp.updates.updateSuccess()
, but I'm not overly familiar with this code.
@jorbin @pento @adamsilverstein thoughts?
Also patch needs a refresh to apply cleanly.
#10
in reply to:
↑ 9
@
9 years ago
I will update the patch and double check to make sure the lock is cleared if the update fails, that sounds right.
I will also test in IE :)
Replying to johnbillion:
This doesn't clear the onbeforeunload event if an error occurs with a plugin update.
It looks like
wp.updates.updateLock = false;
needs to be called inwp.updates.updateError()
in the same way that it is inwp.updates.updateSuccess()
, but I'm not overly familiar with this code.
@jorbin @pento @adamsilverstein thoughts?
Also patch needs a refresh to apply cleanly.
#11
follow-up:
↓ 18
@
9 years ago
In 31769.3.diff clear updateLock, recheck queue and possible clear onbeforeunload in always callback, which happens after success or failure.
Resolves an issue where onbeforeunload would not be cleared when updates fail.
Could use some additional testing: test with failures, test in IE.
I noticed one JS issue updating, i reverted to an old version of Jetpack then updated it, the slug in the response didn’t match the data-slug attribute looked for on L 234: {{ var $pluginRow = $( '[data-slug="' + response.slug + '"]' ).first(); }} - possibly because the slug changed? we should ensure the slug always matches here, or at least check and not fail if it changed, this failure broke the rest of my updates (I had queued multiple).
#12
@
9 years ago
- Keywords needs-refresh removed
The only thing in this ticket blocking beta 4 is the new string change in script-loader.php. Can we get that one change committed in lieu of finishing up this entire ticket?
#13
@
9 years ago
I wonder if the string is exactly what we want. It doesn't provide much actual feedback. What do people think of:
Plugins are currently being updated. If you navigate away there may be unexpected behavior.
This ticket was mentioned in Slack in #core by jorbin. View the logs.
9 years ago
#17
follow-up:
↓ 19
@
9 years ago
- move the
beforeunload
handler to a callback bound via$( window ).on( 'beforeunload' )
, rather than setting and unsetting the callback towindow.onbeforeunload
. We don't need to play hot potato with the callback because the internal conditional logic will decide whether to pop open the "Are you sure?" alert. - remove the
wp.ajax.post().always()
callback, which will cause spurious requests when a user inputs the wrong credentials. See this comment. The lock is released inwp.updates.updateSuccess()
, and the request modal is re-opened in the error modal, so the lock doesn't need to be released inwp.updates.updateError()
.
#18
in reply to:
↑ 11
;
follow-up:
↓ 20
@
9 years ago
Replying to adamsilverstein:
I noticed one JS issue updating, i reverted to an old version of Jetpack then updated it, the slug in the response didn’t match the data-slug attribute looked for on L 234: {{ var $pluginRow = $( '[data-slug="' + response.slug + '"]' ).first(); }} - possibly because the slug changed? we should ensure the slug always matches here, or at least check and not fail if it changed, this failure broke the rest of my updates (I had queued multiple).
Can we open a separate ticket and get clear steps to reproduce here? :D
#19
in reply to:
↑ 17
@
9 years ago
Nice!
Replying to ericlewis:
- move the
beforeunload
handler to a callback bound via$( window ).on( 'beforeunload' )
, rather than setting and unsetting the callback towindow.onbeforeunload
. We don't need to play hot potato with the callback because the internal conditional logic will decide whether to pop open the "Are you sure?" alert.- remove the
wp.ajax.post().always()
callback, which will cause spurious requests when a user inputs the wrong credentials. See this comment. The lock is released inwp.updates.updateSuccess()
, and the request modal is re-opened in the error modal, so the lock doesn't need to be released inwp.updates.updateError()
.
#20
in reply to:
↑ 18
@
9 years ago
Will do, lets get this in and I will open a new ticket.
Replying to ericlewis:
Replying to adamsilverstein:
I noticed one JS issue updating, i reverted to an old version of Jetpack then updated it, the slug in the response didn’t match the data-slug attribute looked for on L 234: {{ var $pluginRow = $( '[data-slug="' + response.slug + '"]' ).first(); }} - possibly because the slug changed? we should ensure the slug always matches here, or at least check and not fail if it changed, this failure broke the rest of my updates (I had queued multiple).
Can we open a separate ticket and get clear steps to reproduce here? :D
#21
in reply to:
↑ 9
@
9 years ago
Replying to johnbillion:
It looks like
wp.updates.updateLock = false;
needs to be called inwp.updates.updateError()
in the same way that it is inwp.updates.updateSuccess()
, but I'm not overly familiar with this code.
Yes. See #31892
#22
@
9 years ago
- Summary changed from Prevent navigating away while plugins are updating via shiny updates to Shiny Updates: Prevent navigating away while plugins are updating
I like the idea of adding an AYS check if an update is in process or if there are items in the queue.