diff --git a/packages/editor/src/store/utils/notice-builder.js b/packages/editor/src/store/utils/notice-builder.js index e287830679713..41049ec917e61 100644 --- a/packages/editor/src/store/utils/notice-builder.js +++ b/packages/editor/src/store/utils/notice-builder.js @@ -31,11 +31,18 @@ export function getNotificationArgumentsForSaveSuccess( data ) { const publishStatus = [ 'publish', 'private', 'future' ]; const isPublished = includes( publishStatus, previousPost.status ); const willPublish = includes( publishStatus, post.status ); + const isTrashed = post.status === 'trash'; let noticeMessage; let shouldShowLink = get( postType, [ 'viewable' ], false ); - if ( ! isPublished && ! willPublish ) { + // Since there is not a label for a post_type `trash` action, + // we add the message manually. + // Reference: https://developer.wordpress.org/reference/functions/get_post_type_labels/ + if ( isTrashed ) { + noticeMessage = `${ postType.labels.singular_name } trashed.`; + shouldShowLink = false; + } else if ( ! isPublished && ! willPublish ) { // If saving a non-published post, don't show notice. noticeMessage = null; } else if ( isPublished && ! willPublish ) { diff --git a/packages/editor/src/store/utils/test/notice-builder.js b/packages/editor/src/store/utils/test/notice-builder.js index bc7df7ac526c6..88997904fcf5b 100644 --- a/packages/editor/src/store/utils/test/notice-builder.js +++ b/packages/editor/src/store/utils/test/notice-builder.js @@ -17,6 +17,7 @@ describe( 'getNotificationArgumentsForSaveSuccess()', () => { item_scheduled: 'scheduled', item_updated: 'updated', view_item: 'view', + singular_name: 'post', }, viewable: false, }; @@ -74,6 +75,11 @@ describe( 'getNotificationArgumentsForSaveSuccess()', () => { }, ], ], + [ + 'when post is trashed', + [ 'publish', 'trash' ], + [ 'post trashed.', defaultExpectedAction ], + ], ].forEach( ( [ description,