Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed May 23, 2024
1 parent 0430368 commit 2278e5f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 26 deletions.
12 changes: 2 additions & 10 deletions packages/edit-site/src/components/dataviews-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,8 @@ export const useEditPostAction = () => {
if ( post.status === 'trash' ) {
return false;
}
// It's eligible for all post types except patterns.
if (
! [ ...Object.values( PATTERN_TYPES ) ].includes(
post.type
)
) {
return true;
}
// We can only edit user patterns.
return post.type === PATTERN_TYPES.user;
// It's eligible for all post types except theme patterns.
return post.type !== PATTERN_TYPES.theme;
},
callback( items ) {
const post = items[ 0 ];
Expand Down
24 changes: 9 additions & 15 deletions packages/editor/src/components/post-actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { store as coreStore } from '@wordpress/core-data';
import { __, _n, sprintf, _x } from '@wordpress/i18n';
import { store as noticesStore } from '@wordpress/notices';
import { useMemo, useState } from '@wordpress/element';
import { store as reusableBlocksStore } from '@wordpress/reusable-blocks';
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';

import {
Expand Down Expand Up @@ -110,19 +109,6 @@ const deletePostAction = {
const { createSuccessNotice, createErrorNotice } =
useDispatch( noticesStore );
const { deleteEntityRecord } = useDispatch( coreStore );
const { __experimentalDeleteReusableBlock } =
useDispatch( reusableBlocksStore );
const isPattern = items[ 0 ].type === PATTERN_POST_TYPE;
const deleteItem = isPattern
? ( item ) => __experimentalDeleteReusableBlock( item.id )
: ( item ) =>
deleteEntityRecord(
'postType',
item.type,
item.id,
{},
{ throwOnError: true }
);
return (
<VStack spacing="5">
<Text>
Expand Down Expand Up @@ -159,7 +145,15 @@ const deletePostAction = {
onActionStart( items );
}
const promiseResult = await Promise.allSettled(
items.map( deleteItem )
items.map( ( item ) =>
deleteEntityRecord(
'postType',
item.type,
item.id,
{},
{ throwOnError: true }
)
)
);
// If all the promises were fulfilled with success.
if (
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/various/change-detection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ test.describe( 'Change detection', () => {
.click();
await page
.getByRole( 'menu' )
.getByRole( 'menuitem', { name: 'Move to Trash' } )
.getByRole( 'menuitem', { name: 'Delete' } )
.click();
await page
.getByRole( 'dialog' )
Expand Down

0 comments on commit 2278e5f

Please sign in to comment.