diff --git a/packages/block-library/src/template-part/edit/index.js b/packages/block-library/src/template-part/edit/index.js index 5af3ede02b677e..52d740735eaf61 100644 --- a/packages/block-library/src/template-part/edit/index.js +++ b/packages/block-library/src/template-part/edit/index.js @@ -128,6 +128,7 @@ export default function TemplatePartEdit( { area, onNavigateToEntityRecord, title, + canEditTemplate, } = useSelect( ( select ) => { const { getEditedEntityRecord, hasFinishedResolution } = @@ -150,6 +151,9 @@ export default function TemplatePartEdit( { ) : false; + const _canEditTemplate = + select( coreStore ).canUser( 'create', 'templates' ) ?? false; + return { hasInnerBlocks: getBlockCount( clientId ) > 0, isResolved: hasResolvedEntity, @@ -161,6 +165,7 @@ export default function TemplatePartEdit( { onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord, title: entityRecord?.title, + canEditTemplate: _canEditTemplate, }; }, [ templatePartId, attributes.area, clientId ] @@ -228,20 +233,22 @@ export default function TemplatePartEdit( { return ( <> - { isEntityAvailable && onNavigateToEntityRecord && ( - - - onNavigateToEntityRecord( { - postId: templatePartId, - postType: 'wp_template_part', - } ) - } - > - { __( 'Edit' ) } - - - ) } + { isEntityAvailable && + onNavigateToEntityRecord && + canEditTemplate && ( + + + onNavigateToEntityRecord( { + postId: templatePartId, + postType: 'wp_template_part', + } ) + } + > + { __( 'Edit' ) } + + + ) }