diff --git a/packages/editor/src/components/post-trash/check.js b/packages/editor/src/components/post-trash/check.js
index 8f51df175c898..7edc7c0f18c27 100644
--- a/packages/editor/src/components/post-trash/check.js
+++ b/packages/editor/src/components/post-trash/check.js
@@ -8,6 +8,7 @@ import { store as coreStore } from '@wordpress/core-data';
* Internal dependencies
*/
import { store as editorStore } from '../../store';
+import { GLOBAL_POST_TYPES } from '../../store/constants';
/**
* Wrapper component that renders its children only if the post can trashed.
@@ -34,10 +35,12 @@ export default function PostTrashCheck( { children } ) {
: false;
return {
- canTrashPost: ( ! isNew || postId ) && canUserDelete,
+ canTrashPost:
+ ( ! isNew || postId ) &&
+ canUserDelete &&
+ ! GLOBAL_POST_TYPES.includes( postType ),
};
}, [] );
-
if ( ! canTrashPost ) {
return null;
}
diff --git a/packages/editor/src/components/post-trash/index.js b/packages/editor/src/components/post-trash/index.js
index c29dfd66a2d8c..ddb1776d479db 100644
--- a/packages/editor/src/components/post-trash/index.js
+++ b/packages/editor/src/components/post-trash/index.js
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
-import { __ } from '@wordpress/i18n';
+import { __, sprintf } from '@wordpress/i18n';
import {
Button,
__experimentalConfirmDialog as ConfirmDialog,
@@ -13,6 +13,7 @@ import { useState } from '@wordpress/element';
* Internal dependencies
*/
import { store as editorStore } from '../../store';
+import PostTrashCheck from './check';
/**
* Displays the Post Trash Button and Confirm Dialog in the Editor.
@@ -20,12 +21,13 @@ import { store as editorStore } from '../../store';
* @return {JSX.Element|null} The rendered PostTrash component.
*/
export default function PostTrash() {
- const { isNew, isDeleting, postId } = useSelect( ( select ) => {
+ const { isNew, isDeleting, postId, title } = useSelect( ( select ) => {
const store = select( editorStore );
return {
isNew: store.isEditedPostNew(),
isDeleting: store.isDeletingPost(),
postId: store.getCurrentPostId(),
+ title: store.getCurrentPostAttribute( 'title' ),
};
}, [] );
const { trashPost } = useDispatch( editorStore );
@@ -41,7 +43,7 @@ export default function PostTrash() {
};
return (
- <>
+
);
}
diff --git a/packages/editor/src/components/sidebar/post-summary.js b/packages/editor/src/components/sidebar/post-summary.js
index b19848f224706..b7fc6efab11ce 100644
--- a/packages/editor/src/components/sidebar/post-summary.js
+++ b/packages/editor/src/components/sidebar/post-summary.js
@@ -28,6 +28,7 @@ import PostsPerPage from '../posts-per-page';
import SiteDiscussion from '../site-discussion';
import { store as editorStore } from '../../store';
import { PrivatePostLastRevision } from '../post-last-revision';
+import PostTrash from '../post-trash';
/**
* Module Constants
@@ -87,6 +88,7 @@ export default function PostSummary( { onActionPerformed } ) {
+
{ fills }
) }