Skip to content

Commit

Permalink
Editor: Refine availability of rename post action (WordPress#62248)
Browse files Browse the repository at this point in the history
Co-authored-by: stokesman <presstoke@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
  • Loading branch information
3 people authored Jun 6, 2024
1 parent 9d8420f commit 6c406e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/editor/src/components/post-actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ export function usePostActions( postType, onActionPerformed ) {
const isPattern = postType === PATTERN_POST_TYPE;
const isLoaded = !! postTypeObject;
const supportsRevisions = !! postTypeObject?.supports?.revisions;
const supportsTitle = !! postTypeObject?.supports?.title;
return useMemo( () => {
if ( ! isLoaded ) {
return [];
Expand All @@ -1064,7 +1065,7 @@ export function usePostActions( postType, onActionPerformed ) {
: false,
isTemplateOrTemplatePart && duplicateTemplatePartAction,
isPattern && duplicatePatternAction,
renamePostAction,
supportsTitle && renamePostAction,
isPattern && exportPatternAsJSONAction,
isTemplateOrTemplatePart ? resetTemplateAction : restorePostAction,
isTemplateOrTemplatePart || isPattern
Expand Down Expand Up @@ -1124,5 +1125,6 @@ export function usePostActions( postType, onActionPerformed ) {
onActionPerformed,
isLoaded,
supportsRevisions,
supportsTitle,
] );
}
13 changes: 13 additions & 0 deletions test/e2e/specs/editor/plugins/custom-post-types.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ test.describe( 'Test Custom Post Types', () => {
await expect( parentPageLocator ).toHaveValue( parentPage );
} );

test( 'should not be able to rename a post that lacks title support', async ( {
admin,
editor,
page,
} ) => {
await admin.createNewPost( { postType: 'hierar-no-title' } );
await editor.openDocumentSettingsSidebar();
await page.getByRole( 'button', { name: 'Actions' } ).click();
await expect(
page.getByRole( 'menuitem', { name: 'Rename' } )
).toHaveCount( 0 );
} );

test( 'should create a cpt with a legacy block in its template without WSOD', async ( {
admin,
editor,
Expand Down

0 comments on commit 6c406e5

Please sign in to comment.