Skip to content

Commit

Permalink
Removed unused rename component.
Browse files Browse the repository at this point in the history
Cleaning up after rebase
  • Loading branch information
ramonjd committed Sep 21, 2023
1 parent 5da8939 commit 314d5b7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 135 deletions.
126 changes: 0 additions & 126 deletions packages/edit-site/src/components/page-patterns/rename-menu-item.js

This file was deleted.

13 changes: 7 additions & 6 deletions packages/edit-site/src/components/template-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import RenameMenuItem from './rename-menu-item';
import {
TEMPLATE_POST_TYPE,
TEMPLATE_PART_POST_TYPE,
PATTERN_POST_TYPE,
POST_TYPE_LABELS,
PATTERN_TYPES,
} from '../../utils/constants';

export default function TemplateActions( {
postType,
postId,
Expand All @@ -50,7 +49,7 @@ export default function TemplateActions( {
useDispatch( reusableBlocksStore );
const isRemovable = isTemplateRemovable( record );
// Only custom patterns or custom template parts can be renamed or deleted.
const isUserPattern = record?.type === PATTERN_POST_TYPE;
const isUserPattern = record?.type === PATTERN_TYPES.user;
const isTemplate = record?.type === TEMPLATE_POST_TYPE;
const isTemplatePart = record?.type === TEMPLATE_PART_POST_TYPE;

Expand All @@ -72,7 +71,9 @@ export default function TemplateActions( {
sprintf(
// translators: %s: The pattern's title e.g. 'Call to action'.
__( '"%s" deleted.' ),
pattern.title
decodeEntities(
pattern?.title?.rendered || pattern?.title?.raw
)
),
{ type: 'snackbar', id: 'edit-site-patterns-success' }
);
Expand All @@ -89,9 +90,9 @@ export default function TemplateActions( {
};

const deleteItem = async ( item ) => {
if ( isUserPattern ) {
if ( isTemplateRemovable( item ) ) {
removeTemplate( item );
} else if ( isTemplateRemovable( item ) ) {
} else if ( isUserPattern ) {
deletePattern( item );
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { decodeEntities } from '@wordpress/html-entities';
import {
TEMPLATE_POST_TYPE,
TEMPLATE_PART_POST_TYPE,
PATTERN_POST_TYPE,
PATTERN_TYPES,
TEMPLATE_CUSTOM_SOURCE,
POST_TYPE_LABELS,
} from '../../utils/constants';
Expand All @@ -44,7 +44,7 @@ export default function RenameMenuItem( { postType, postId, onClose } ) {

const isTemplate = record?.type === TEMPLATE_POST_TYPE;
const isTemplatePart = record?.type === TEMPLATE_PART_POST_TYPE;
const isUserPattern = record?.type === PATTERN_POST_TYPE;
const isUserPattern = record?.type === PATTERN_TYPES.user;

if (
( isTemplate || isTemplatePart ) &&
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const removeTemplate =
throw lastError;
}

// Depending on how the entity was retrieved it's title might be
// Depending on how the entity was retrieved its title might be
// an object or simple string.
const templateTitle =
typeof template.title === 'string'
Expand Down

0 comments on commit 314d5b7

Please sign in to comment.