Skip to content

Commit f9965bb

Browse files
authored
show proper message on trash (#25563)
1 parent a1df992 commit f9965bb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/editor/src/store/utils/notice-builder.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ export function getNotificationArgumentsForSaveSuccess( data ) {
3131
const publishStatus = [ 'publish', 'private', 'future' ];
3232
const isPublished = includes( publishStatus, previousPost.status );
3333
const willPublish = includes( publishStatus, post.status );
34+
const isTrashed = post.status === 'trash';
3435

3536
let noticeMessage;
3637
let shouldShowLink = get( postType, [ 'viewable' ], false );
3738

38-
if ( ! isPublished && ! willPublish ) {
39+
// Since there is not a label for a post_type `trash` action,
40+
// we add the message manually.
41+
// Reference: https://developer.wordpress.org/reference/functions/get_post_type_labels/
42+
if ( isTrashed ) {
43+
noticeMessage = `${ postType.labels.singular_name } trashed.`;
44+
shouldShowLink = false;
45+
} else if ( ! isPublished && ! willPublish ) {
3946
// If saving a non-published post, don't show notice.
4047
noticeMessage = null;
4148
} else if ( isPublished && ! willPublish ) {

packages/editor/src/store/utils/test/notice-builder.js

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe( 'getNotificationArgumentsForSaveSuccess()', () => {
1717
item_scheduled: 'scheduled',
1818
item_updated: 'updated',
1919
view_item: 'view',
20+
singular_name: 'post',
2021
},
2122
viewable: false,
2223
};
@@ -74,6 +75,11 @@ describe( 'getNotificationArgumentsForSaveSuccess()', () => {
7475
},
7576
],
7677
],
78+
[
79+
'when post is trashed',
80+
[ 'publish', 'trash' ],
81+
[ 'post trashed.', defaultExpectedAction ],
82+
],
7783
].forEach(
7884
( [
7985
description,

0 commit comments

Comments
 (0)