Make WordPress Core

Ticket #44264: 44264.7.diff

File 44264.7.diff, 4.4 KB (added by pbiron, 5 years ago)
  • src/js/_enqueues/admin/privacy-tools.js

    From a3af7d96b9418ec15b66e35afb71278a02de1aab Mon Sep 17 00:00:00 2001
    From: Paul Biron <paul@sparrowhawkcomputing.com>
    Date: Fri, 14 Feb 2020 16:25:48 -0700
    Subject: [PATCH] Keep the progress indicator in the row-actions visible while
     the export/erase is happening, even when that cell isn't hovered over.
    
    ---
     src/js/_enqueues/admin/privacy-tools.js | 53 ++++++++++++++++++++-----
     1 file changed, 43 insertions(+), 10 deletions(-)
    
    diff --git a/src/js/_enqueues/admin/privacy-tools.js b/src/js/_enqueues/admin/privacy-tools.js
    index 5d5a2067a4..6a9f93b4c8 100644
    a b jQuery( document ).ready( function( $ ) { 
    5555                });
    5656        }
    5757
     58        function showRowActions( $rowActions, $hasRowActions ) {
     59                if ( $rowActions.length > 0 ) {
     60                        $( $rowActions ).addClass( 'visible' );
     61                        $( $hasRowActions ).removeClass( 'has-row-actions' );
     62                }
     63        }
     64
     65        function hideRowActions( $rowActions, $hasRowActions ) {
     66                if ( $rowActions.length > 0 ) {
     67                        $( $rowActions ).removeClass( 'visible' );
     68                        $( $hasRowActions ).addClass( 'has-row-actions' );
     69                }
     70        }
     71
    5872        $( '.export-personal-data-handle' ).click( function( event ) {
    5973                var $this          = $( this ),
    6074                        $action        = $this.parents( '.export-personal-data' ),
    6175                        $requestRow    = $this.parents( 'tr' ),
    6276                        $progress      = $requestRow.find( '.export-progress' ),
     77                        $rowActions    = $this.parents( '.row-actions' ),
     78                        $hasRowActions = $( '.has-row-actions' ),
    6379                        requestID      = $action.data( 'request-id' ),
    6480                        nonce          = $action.data( 'nonce' ),
    6581                        exportersCount = $action.data( 'exporters-count' ),
    jQuery( document ).ready( function( $ ) { 
    6884                event.preventDefault();
    6985                event.stopPropagation();
    7086
     87                // have to do this before the `$action.blur()`.
     88                showRowActions( $rowActions, $hasRowActions );
     89
    7190                $action.blur();
    7291                clearResultsAfterRow( $requestRow );
    7392                setExportProgress( 0 );
    jQuery( document ).ready( function( $ ) { 
    7796
    7897                        setActionState( $action, 'export-personal-data-success' );
    7998
     99                        hideRowActions( $rowActions, $hasRowActions );
     100
    80101                        appendResultsAfterRow( $requestRow, 'notice-success', summaryMessage, [] );
    81102                        $this.hide();
    82103
    jQuery( document ).ready( function( $ ) { 
    92113                        if ( errorMessage ) {
    93114                                appendResultsAfterRow( $requestRow, 'notice-error', strings.exportError, [ errorMessage ] );
    94115                        }
     116
     117                        hideRowActions( $rowActions, $hasRowActions );
    95118                }
    96119
    97120                function setExportProgress( exporterIndex ) {
    jQuery( document ).ready( function( $ ) { 
    147170        });
    148171
    149172        $( '.remove-personal-data-handle' ).click( function( event ) {
    150                 var $this         = $( this ),
    151                         $action       = $this.parents( '.remove-personal-data' ),
    152                         $requestRow   = $this.parents( 'tr' ),
    153                         $progress     = $requestRow.find( '.erasure-progress' ),
    154                         requestID     = $action.data( 'request-id' ),
    155                         nonce         = $action.data( 'nonce' ),
    156                         erasersCount  = $action.data( 'erasers-count' ),
    157                         hasRemoved    = false,
    158                         hasRetained   = false,
    159                         messages      = [];
     173                var $this          = $( this ),
     174                        $action        = $this.parents( '.remove-personal-data' ),
     175                        $requestRow    = $this.parents( 'tr' ),
     176                        $progress      = $requestRow.find( '.erasure-progress' ),
     177                        requestID      = $action.data( 'request-id' ),
     178                        $rowActions    = $this.parents( '.row-actions' ),
     179                        $hasRowActions = $( '.has-row-actions' ),
     180                        nonce          = $action.data( 'nonce' ),
     181                        erasersCount   = $action.data( 'erasers-count' ),
     182                        hasRemoved     = false,
     183                        hasRetained    = false,
     184                        messages       = [];
    160185
    161186                event.stopPropagation();
    162187
     188                // have to do this before the `$action.blur()`.
     189                showRowActions( $rowActions, $hasRowActions );
     190
    163191                $action.blur();
    164192                clearResultsAfterRow( $requestRow );
    165193                setErasureProgress( 0 );
    jQuery( document ).ready( function( $ ) { 
    170198
    171199                        setActionState( $action, 'remove-personal-data-success' );
    172200
     201                        hideRowActions( $rowActions, $hasRowActions );
     202
    173203                        if ( false === hasRemoved ) {
    174204                                if ( false === hasRetained ) {
    175205                                        summaryMessage = strings.noDataFound;
    jQuery( document ).ready( function( $ ) { 
    191221
    192222                function onErasureFailure() {
    193223                        setActionState( $action, 'remove-personal-data-failed' );
     224
     225                        hideRowActions( $rowActions, $hasRowActions );
     226
    194227                        appendResultsAfterRow( $requestRow, 'notice-error', strings.removalError, [] );
    195228                }
    196229