Skip to content

Commit

Permalink
Consolidate and fix delete and edit post actions (#61912)
Browse files Browse the repository at this point in the history
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: jorgefilipecosta <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: richtabor <[email protected]>
  • Loading branch information
7 people authored May 27, 2024
1 parent 5498ae2 commit 70585e4
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 335 deletions.
9 changes: 7 additions & 2 deletions packages/edit-site/src/components/dataviews-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
/**
* Internal dependencies
*/
import { PATTERN_TYPES } from '../../utils/constants';
import { unlock } from '../../lock-unlock';

const { useHistory } = unlock( routerPrivateApis );
Expand All @@ -21,8 +22,12 @@ export const useEditPostAction = () => {
label: __( 'Edit' ),
isPrimary: true,
icon: edit,
isEligible( { status } ) {
return status !== 'trash';
isEligible( post ) {
if ( post.status === 'trash' ) {
return false;
}
// It's eligible for all post types except theme patterns.
return post.type !== PATTERN_TYPES.theme;
},
callback( items ) {
const post = items[ 0 ];
Expand Down
1 change: 1 addition & 0 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export default function Editor( { isLoading } ) {
( actionId, items ) => {
switch ( actionId ) {
case 'move-to-trash':
case 'delete-post':
{
history.push( {
postType: items[ 0 ].type,
Expand Down
Loading

0 comments on commit 70585e4

Please sign in to comment.