@@ -76,19 +76,18 @@ jQuery( document ).ready( function( $ ) {
7676 post_id : jQuery ( '#post_ID' ) . val ( ) ,
7777 } ;
7878
79- const toggleWarningBadges = function ( container , response ) {
79+ const toggleWarningBadges = function ( container , { userHasNoAccess , userHasNoEmail } ) {
8080 const $el = jQuery ( container ) . parent ( ) ;
8181 const $badgesContainer = $el . closest ( 'li' ) . find ( '.ef-user-list-badges' ) ;
82+
8283 // "No Access" If this user was flagged as not having access
83- const userHasNoAccess = response . data . subscribers_with_no_access . includes ( parseInt ( jQuery ( container ) . val ( ) , 10 ) ) ;
8484 if ( userHasNoAccess ) {
8585 addBadgeToEl ( $badgesContainer , BADGES . NO_ACCESS ) ;
8686 } else {
8787 removeBadgeFromEl ( $badgesContainer , BADGES . NO_ACCESS ) ;
8888 }
8989
9090 // "No Email" If this user was flagged as not having an email
91- const userHasNoEmail = response . data . subscribers_with_no_email . includes ( parseInt ( jQuery ( container ) . val ( ) , 10 ) ) ;
9291 if ( userHasNoEmail ) {
9392 addBadgeToEl ( $badgesContainer , BADGES . NO_EMAIL ) ;
9493 } else {
@@ -140,11 +139,19 @@ jQuery( document ).ready( function( $ ) {
140139 success : function ( response ) {
141140 // Toggle the warning badges ("No Access" and "No Email") to signal the user won't receive notifications
142141 if ( undefined !== response . data ) {
143- toggleWarningBadges ( jQuery ( parentThis ) , response ) ;
142+ const userHasNoAccess = response . data . subscribers_with_no_access . includes ( parseInt ( jQuery ( container ) . val ( ) , 10 ) ) ;
143+ const userHasNoEmail = response . data . subscribers_with_no_email . includes ( parseInt ( jQuery ( container ) . val ( ) , 10 ) ) ;
144+
145+ toggleWarningBadges ( jQuery ( parentThis ) , { userHasNoAccess, userHasNoEmail } ) ;
144146 }
145147
146148 // Green 40% by default
147- const backgroundHighlightColor = '#90d296' ;
149+ let backgroundHighlightColor = '#90d296' ;
150+
151+ if ( userHasNoAccess || userHasNoEmail ) {
152+ // Red 40% if there's a warning
153+ backgroundHighlightColor = "#ea8484" ;
154+ }
148155
149156 const backgroundColor = 'transparent' ;
150157 jQuery ( parentThis . parents ( 'label' ) )
0 commit comments