Skip to content

Commit

Permalink
Consolidate and fix delete and edit post actions (WordPress#61912)
Browse files Browse the repository at this point in the history
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
  • Loading branch information
7 people authored and patil-vipul committed Jun 17, 2024
1 parent 1104ec4 commit 09ca0d8
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 09ca0d8

Please sign in to comment.