From ececee1e1eafdfb970e4015b96c40e5b150a19a2 Mon Sep 17 00:00:00 2001 From: Jorge Date: Fri, 8 Jun 2018 10:45:15 +0100 Subject: [PATCH] Don't allow to start dragging blocks if a locking lock all exists --- components/draggable/README.md | 8 ++++++++ components/draggable/index.js | 4 ++-- editor/components/block-list/block.js | 3 +++ editor/components/block-list/style.scss | 7 ++++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/components/draggable/README.md b/components/draggable/README.md index 974f1eab06db62..8752607dadbcd0 100644 --- a/components/draggable/README.md +++ b/components/draggable/README.md @@ -6,6 +6,14 @@ The component accepts the following props: +### draggable + +If the component is in a draggable state or not. If false, the component is rendered but it is not possible to drag it. Defaults to true. + +- Type: `boolean` +- Required: No +- Default: `true` + ### elementId The HTML id of the element to clone on drag diff --git a/components/draggable/index.js b/components/draggable/index.js index ec0ac57464c2d2..586432c8825457 100644 --- a/components/draggable/index.js +++ b/components/draggable/index.js @@ -152,13 +152,13 @@ class Draggable extends Component { } render() { - const { children, className } = this.props; + const { children, draggable = true, className } = this.props; return (
{ children }
diff --git a/editor/components/block-list/block.js b/editor/components/block-list/block.js index 70eb8f82088c9e..5661a744bbca88 100644 --- a/editor/components/block-list/block.js +++ b/editor/components/block-list/block.js @@ -414,6 +414,7 @@ export class BlockListBlock extends Component { isEmptyDefaultBlock, isPreviousBlockADefaultEmptyBlock, hasSelectedInnerBlock, + templateLock, } = this.props; const isHovered = this.state.isHovered && ! isMultiSelecting; const { name: blockName, isValid } = block; @@ -504,6 +505,7 @@ export class BlockListBlock extends Component { onDragEnd={ this.onDragEnd } isDragging={ dragging } elementId={ blockElementId } + draggable={ 'all' !== templateLock } // only in locking all moving blocks is totally impossible /> ) } { shouldShowInsertionPoint && ( @@ -646,6 +648,7 @@ const applyWithSelect = withSelect( ( select, { uid, rootUID } ) => { initialPosition: getSelectedBlocksInitialCaretPosition(), isEmptyDefaultBlock: block && isUnmodifiedDefaultBlock( block ), isPreviousBlockADefaultEmptyBlock: previousBlock && isUnmodifiedDefaultBlock( previousBlock ), + templateLock, isLocked: !! templateLock, previousBlockUid, block, diff --git a/editor/components/block-list/style.scss b/editor/components/block-list/style.scss index 2f3e02146ef939..260772fbda7d47 100644 --- a/editor/components/block-list/style.scss +++ b/editor/components/block-list/style.scss @@ -74,9 +74,10 @@ } } - - cursor: move; // Fallback for IE/Edge < 14 - cursor: grab; + &[draggable=true]{ + cursor: move; // Fallback for IE/Edge < 14 + cursor: grab; + } }