Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve success messages of some post actions. #61539

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading