diff --git a/editor/components/block-drop-zone/index.js b/editor/components/block-drop-zone/index.js index ef8da49f0e459d..832ad2f5f7ed28 100644 --- a/editor/components/block-drop-zone/index.js +++ b/editor/components/block-drop-zone/index.js @@ -2,12 +2,12 @@ * External Dependencies */ import { connect } from 'react-redux'; -import { reduce, get, find } from 'lodash'; +import { reduce, get, find, flow } from 'lodash'; /** * WordPress dependencies */ -import { DropZone } from '@wordpress/components'; +import { DropZone, withContext } from '@wordpress/components'; import { getBlockTypes } from '@wordpress/blocks'; /** @@ -15,7 +15,11 @@ import { getBlockTypes } from '@wordpress/blocks'; */ import { insertBlocks } from '../../actions'; -function BlockDropZone( { index, ...props } ) { +function BlockDropZone( { index, isLocked, ...props } ) { + if ( isLocked ) { + return null; + } + const dropFiles = ( files, position ) => { const transformation = reduce( getBlockTypes(), ( ret, blockType ) => { if ( ret ) { @@ -45,7 +49,16 @@ function BlockDropZone( { index, ...props } ) { ); } -export default connect( - undefined, - { insertBlocks } +export default flow( + connect( + undefined, + { insertBlocks } + ), + withContext( 'editor' )( ( settings ) => { + const { templateLock } = settings; + + return { + isLocked: !! templateLock, + }; + } ) )( BlockDropZone ); diff --git a/editor/components/default-block-appender/test/__snapshots__/index.js.snap b/editor/components/default-block-appender/test/__snapshots__/index.js.snap index f407a818dd32ab..a32487237ad7da 100644 --- a/editor/components/default-block-appender/test/__snapshots__/index.js.snap +++ b/editor/components/default-block-appender/test/__snapshots__/index.js.snap @@ -6,7 +6,7 @@ exports[`DefaultBlockAppender no block present should match snapshot 1`] = `