From dde2f52643d167fe26d258032bc7fd38b6621d8c Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Mon, 4 Apr 2022 13:08:11 +0400 Subject: [PATCH] Template Parts: Hide 'Detach blocks' when locked (#40000) --- .../template-part-converter/convert-to-regular.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/edit-site/src/components/template-part-converter/convert-to-regular.js b/packages/edit-site/src/components/template-part-converter/convert-to-regular.js index 6407f8a22b0717..d64cbc90737e24 100644 --- a/packages/edit-site/src/components/template-part-converter/convert-to-regular.js +++ b/packages/edit-site/src/components/template-part-converter/convert-to-regular.js @@ -13,6 +13,15 @@ export default function ConvertToRegularBlocks( { clientId } ) { const { getBlocks } = useSelect( blockEditorStore ); const { replaceBlocks } = useDispatch( blockEditorStore ); + const canRemove = useSelect( + ( select ) => select( blockEditorStore ).canRemoveBlock( clientId ), + [ clientId ] + ); + + if ( ! canRemove ) { + return null; + } + return ( { ( { onClose } ) => (