Skip to content

Commit

Permalink
Add support for multiple dismiss labels.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmymadon committed Dec 23, 2024
1 parent 1570bae commit 2775ad5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function ActionsCTALinkDismiss( {
ctaLabel,
onCTAClick,
onDismiss = () => {},
dismissLabelInitial,
dismissLabel = __( 'OK, Got it!', 'google-site-kit' ),
dismissExpires = 0,
dismissOptions = {},
Expand All @@ -57,6 +58,7 @@ export default function ActionsCTALinkDismiss( {
<Dismiss
id={ id }
primary={ false }
dismissLabelInitial={ dismissLabelInitial }
dismissLabel={ dismissLabel }
dismissExpires={ dismissExpires }
disabled={ isNavigatingToCTALink }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { useDispatch } from 'googlesitekit-data';
import { useDispatch, useSelect } from 'googlesitekit-data';
import useNotificationEvents from '../../hooks/useNotificationEvents';
import { CORE_NOTIFICATIONS } from '../../datastore/constants';
import { Button } from 'googlesitekit-components';

export default function Dismiss( {
id,
primary = true,
dismissLabelInitial,
dismissLabel = __( 'OK, Got it!', 'google-site-kit' ),
dismissExpires = 0,
disabled,
Expand All @@ -49,6 +50,10 @@ export default function Dismiss( {

const { dismissNotification } = useDispatch( CORE_NOTIFICATIONS );

const isDismissalFinal = useSelect( ( select ) =>
select( CORE_NOTIFICATIONS ).isNotificationRetryFinal( id )
);

const handleDismiss = async ( event ) => {
await onDismiss?.( event );
trackEvents.dismiss(
Expand All @@ -67,7 +72,7 @@ export default function Dismiss( {
onClick={ handleDismiss }
disabled={ disabled }
>
{ dismissLabel }
{ isDismissalFinal ? dismissLabel : dismissLabelInitial }
</Button>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,14 @@ export default function ReaderRevenueManagerSetupCTABanner( {
'google-site-kit'
) }
onCTAClick={ onSetupActivate }
dismissLabel={ __( 'Maybe later', 'google-site-kit' ) }
dismissLabelInitial={ __(
'Maybe later',
'google-site-kit'
) }
dismissLabel={ __(
'Don’t show again',
'google-site-kit'
) }
onDismiss={ showTooltip }
dismissOptions={ {
skipHidingFromQueue: true,
Expand Down

0 comments on commit 2775ad5

Please sign in to comment.