From ff416b77f34c433b725fbb5a1dfa399fe22fdd6e Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Tue, 9 Aug 2016 10:38:28 +0000 Subject: [PATCH] Updates: Add visual feedback when deleting themes/plugins. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This corrects the selector for the delete link in `wp.updates.deletePlugin()` so the text can be changed to 'Deleting…'. `wp.updates.deleteTheme()` already worked on wp-admin/themes.php but not on wp-admin/network/themes.php because the network screen is similar to the plugins list table, this is now fixed too. The `credential-modal-cancel` handler has been updated to support canceled delete jobs. Props swissspidy. Props jorbin for review. Fixes #37603. git-svn-id: https://develop.svn.wordpress.org/trunk@38227 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/updates.js | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/js/updates.js b/src/wp-admin/js/updates.js index 9c932056e9..ac6e2cf960 100644 --- a/src/wp-admin/js/updates.js +++ b/src/wp-admin/js/updates.js @@ -716,15 +716,17 @@ * decorated with an abort() method. */ wp.updates.deletePlugin = function( args ) { - var $message = $( '[data-plugin="' + args.plugin + '"]' ).find( '.update-message p' ); + var $link = $( '[data-plugin="' + args.plugin + '"]' ).find( '.row-actions a.delete' ); args = _.extend( { success: wp.updates.deletePluginSuccess, error: wp.updates.deletePluginError }, args ); - if ( $message.html() !== wp.updates.l10n.updating ) { - $message.data( 'originaltext', $message.html() ); + if ( $link.html() !== wp.updates.l10n.deleting ) { + $link + .data( 'originaltext', $link.html() ) + .text( wp.updates.l10n.deleting ); } wp.a11y.speak( wp.updates.l10n.deleting, 'polite' ); @@ -1168,18 +1170,25 @@ * decorated with an abort() method. */ wp.updates.deleteTheme = function( args ) { - var $button = $( '.theme-actions .delete-theme' ); + var $button; + + if ( 'themes' === pagenow ) { + $button = $( '.theme-actions .delete-theme' ); + } else if ( 'themes-network' === pagenow ) { + $button = $( '[data-slug="' + args.slug + '"]' ).find( '.row-actions a.delete' ); + } args = _.extend( { success: wp.updates.deleteThemeSuccess, error: wp.updates.deleteThemeError }, args ); - if ( $button.html() !== wp.updates.l10n.deleting ) { - $button.data( 'originaltext', $button.html() ); + if ( $button && $button.html() !== wp.updates.l10n.deleting ) { + $button + .data( 'originaltext', $button.html() ) + .text( wp.updates.l10n.deleting ); } - $button.text( wp.updates.l10n.deleting ); wp.a11y.speak( wp.updates.l10n.deleting, 'polite' ); // Remove previous error messages, if any. @@ -1710,7 +1719,19 @@ if ( 'import' === pagenow ) { $updatingMessage.removeClass( 'updating-message' ); } else if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) { - $message = $( 'tr[data-plugin="' + job.data.plugin + '"]' ).find( '.update-message' ); + if ( 'update-plugin' === job.action ) { + $message = $( 'tr[data-plugin="' + job.data.plugin + '"]' ).find( '.update-message' ); + } else if ( 'delete-plugin' === job.action ) { + $message = $( '[data-plugin="' + job.data.plugin + '"]' ).find( '.row-actions a.delete' ); + } + } else if ( 'themes' === pagenow || 'themes-network' === pagenow ) { + if ( 'update-theme' === job.action ) { + $message = $( '[data-slug="' + job.data.slug + '"]' ).find( '.update-message' ); + } else if ( 'delete-theme' === job.action && 'themes-network' === pagenow ) { + $message = $( '[data-slug="' + job.data.slug + '"]' ).find( '.row-actions a.delete' ); + } else if ( 'delete-theme' === job.action && 'themes' === pagenow ) { + $message = $( '.theme-actions .delete-theme' ); + } } else { $message = $updatingMessage; }