Updates: Improve experience for Bulk Actions when FTP is dismissed.

Before this change, when a bulk update was canceled due dismissing the FTP credentials modal, part of the actions didn't get canceled.  This meant the "There is a new version of…” notices become blank and the updates you had checked became unchecked.  Now, the notices remain and you are essentially returned to the screen you had before. Strings are also updated to improve ARIA usage.

Fixes #37563.
Props ocean90, swissspidy, obenland, afercia.



git-svn-id: https://develop.svn.wordpress.org/trunk@38221 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Aaron Jorbin 2016-08-09 01:13:08 +00:00
parent 3d057fef40
commit 7044243aa2
4 changed files with 34 additions and 15 deletions

View File

@ -476,6 +476,8 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
$action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">' . _x( 'Active', 'plugin' ) . '</button>';
} elseif ( current_user_can( 'activate_plugins' ) ) {
$button_text = __( 'Activate' );
/* translators: %s: Plugin name */
$button_label = _x( 'Activate %s', 'plugin' );
$activate_url = add_query_arg( array(
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
'action' => 'activate',
@ -484,14 +486,15 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
if ( is_network_admin() ) {
$button_text = __( 'Network Activate' );
/* translators: %s: Plugin name */
$button_label = _x( 'Network Activate %s', 'plugin' );
$activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url );
}
$action_links[] = sprintf(
'<a href="%1$s" class="button activate-now button-secondary" aria-label="%2$s">%3$s</a>',
esc_url( $activate_url ),
/* translators: %s: Plugin name */
esc_attr( sprintf( _x( 'Activate %s', 'plugin' ), $plugin['name'] ) ),
esc_attr( sprintf( $button_label, $plugin['name'] ) ),
$button_text
);
} else {

View File

@ -523,11 +523,14 @@
$message = $( '[data-slug="' + args.slug + '"]' );
}
$message.text( wp.updates.l10n.installing );
if ( $message.html() !== wp.updates.l10n.installing ) {
$message.data( 'originaltext', $message.html() );
}
$message
.addClass( 'updating-message' )
.attr( 'aria-label', wp.updates.l10n.pluginInstallingLabel.replace( '%s', $message.data( 'name' ) ) );
.attr( 'aria-label', wp.updates.l10n.pluginInstallingLabel.replace( '%s', $message.data( 'name' ) ) )
.text( wp.updates.l10n.installing );
wp.a11y.speak( wp.updates.l10n.installingMsg, 'polite' );
@ -1505,7 +1508,7 @@
// Restore callbacks.
response = wp.updates._addCallbacks( response, action );
wp.updates.queue.push( {
wp.updates.queue.unshift( {
action: action,
/*
@ -1708,13 +1711,11 @@
$updatingMessage.removeClass( 'updating-message' );
} else if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
$message = $( 'tr[data-plugin="' + job.data.plugin + '"]' ).find( '.update-message' );
} else if ( 'plugin-install' === pagenow || 'plugin-install-network' === pagenow ) {
$message = $( '.update-now.updating-message' );
} else {
$message = $updatingMessage;
}
if ( $message ) {
if ( $message && $message.hasClass( 'updating-message' ) ) {
originalText = $message.data( 'originaltext' );
if ( 'undefined' === typeof originalText ) {
@ -1724,6 +1725,14 @@
$message
.removeClass( 'updating-message' )
.html( originalText );
if ( 'plugin-install' === pagenow || 'plugin-install-network' === pagenow ) {
if ( 'update-plugin' === job.action ) {
$message.attr( 'aria-label', wp.updates.l10n.updateNowLabel.replace( '%s', $message.data( 'name' ) ) );
} else if ( 'install-plugin' === job.action ) {
$message.attr( 'aria-label', wp.updates.l10n.installNowLabel.replace( '%s', $message.data( 'name' ) ) );
}
}
}
wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
@ -1999,14 +2008,14 @@
// Find all the checkboxes which have been checked.
itemsSelected.each( function( index, element ) {
var $checkbox = $( element ),
var $checkbox = $( element ),
$itemRow = $checkbox.parents( 'tr' );
// Un-check the box.
$checkbox.prop( 'checked', false );
// Only add update-able items to the update queue.
if ( 'update-selected' === bulkAction && ( ! $itemRow.hasClass( 'update' ) || $itemRow.find( 'notice-error' ).length ) ) {
// Un-check the box.
$checkbox.prop( 'checked', false );
return;
}
@ -2022,17 +2031,20 @@
// Display bulk notification for updates of any kind.
$document.on( 'wp-plugin-update-success wp-plugin-update-error wp-theme-update-success wp-theme-update-error', function( event, response ) {
var $bulkActionNotice, itemName;
var $itemRow = $( '[data-slug="' + response.slug + '"]' ),
$bulkActionNotice, itemName;
if ( 'wp-' + response.update + '-update-success' === event.type ) {
success++;
} else {
itemName = response.pluginName ? response.pluginName : $( '[data-slug="' + response.slug + '"]' ).find( '.column-primary strong' ).text();
itemName = response.pluginName ? response.pluginName : $itemRow.find( '.column-primary strong' ).text();
error++;
errorMessages.push( itemName + ': ' + response.errorMessage );
}
$itemRow.find( 'input[name="checked[]"]:checked' ).prop( 'checked', false );
wp.updates.adminNotice = wp.template( 'wp-bulk-updates-admin-notice' );
wp.updates.addAdminNotice( {

View File

@ -616,6 +616,8 @@ function wp_default_scripts( &$scripts ) {
'updated' => __( 'Updated!' ),
'update' => __( 'Update' ),
'updateNow' => __( 'Update Now' ),
/* translators: %s: Plugin name and version */
'updateNowLabel' => __( 'Update %s now' ),
'updateFailedShort' => __( 'Update Failed!' ),
/* translators: %s: Error string for a failed update */
'updateFailed' => __( 'Update Failed: %s' ),
@ -634,7 +636,7 @@ function wp_default_scripts( &$scripts ) {
'beforeunload' => __( 'Updates may not complete if you navigate away from this page.' ),
'installNow' => __( 'Install Now' ),
/* translators: %s: Plugin name */
'installNowLabel' => __( 'Install %s' ),
'installNowLabel' => __( 'Install %s now' ),
'installing' => __( 'Installing...' ),
'installed' => __( 'Installed!' ),
'installFailedShort' => __( 'Install Failed!' ),

View File

@ -9,6 +9,7 @@ window._wpUpdatesSettings = {
'updated': 'Updated!',
'update': 'Update',
'updateNow': 'Update Now',
'updateNowLabel': 'Update %s now',
'updateFailedShort': 'Update Failed!',
'updateFailed': 'Update Failed: %s',
'updatingLabel': 'Updating %s...',
@ -19,6 +20,7 @@ window._wpUpdatesSettings = {
'updateCancel': 'Update canceled.',
'beforeunload': 'Updates may not complete if you navigate away from this page.',
'installNow': 'Install Now',
'installNowLabel': 'Install %s now',
'installing': 'Installing...',
'installed': 'Installed!',
'installFailedShort': 'Install Failed!',