Skip to content

Commit

Permalink
Improve success messages of some post actions. (#61539)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta authored May 10, 2024
1 parent d489fb3 commit 37dd0f5
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions packages/editor/src/components/post-actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,17 @@ const trashPostAction = {
__( '"%s" moved to the Trash.' ),
getItemTitle( posts[ 0 ] )
);
} else if ( posts[ 0 ].type === 'page' ) {
successMessage = sprintf(
/* translators: The number of pages. */
__( '%s pages moved to the Trash.' ),
posts.length
);
} else {
successMessage = __(
'Pages moved to the Trash.'
successMessage = sprintf(
/* translators: The number of posts. */
__( '%s posts moved to the Trash.' ),
posts.length
);
}
createSuccessNotice( successMessage, {
Expand Down Expand Up @@ -343,23 +351,30 @@ function useRestorePostAction() {
( { status } ) => status === 'fulfilled'
)
) {
createSuccessNotice(
posts.length > 1
? sprintf(
/* translators: The number of posts. */
__( '%d posts have been restored.' ),
posts.length
)
: sprintf(
/* translators: The number of posts. */
__( '"%s" has been restored.' ),
getItemTitle( posts[ 0 ] )
),
{
type: 'snackbar',
id: 'restore-post-action',
}
);
let successMessage;
if ( posts.length === 1 ) {
successMessage = sprintf(
/* translators: The number of posts. */
__( '"%s" has been restored.' ),
getItemTitle( posts[ 0 ] )
);
} else if ( posts[ 0 ].type === 'page' ) {
successMessage = sprintf(
/* translators: The number of posts. */
__( '%d pages have been restored.' ),
posts.length
);
} else {
successMessage = sprintf(
/* translators: The number of posts. */
__( '%d posts have been restored.' ),
posts.length
);
}
createSuccessNotice( successMessage, {
type: 'snackbar',
id: 'restore-post-action',
} );
if ( onActionPerformed ) {
onActionPerformed( posts );
}
Expand Down

0 comments on commit 37dd0f5

Please sign in to comment.