Skip to content

Commit

Permalink
Use templateLock value as initial state
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Jul 13, 2022
1 parent 2f84ee5 commit 8262739
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/block-editor/src/components/block-lock/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,26 @@ function getTemplateLockValue( lock ) {
}

export default function BlockLockModal( { clientId, onClose } ) {
const [ applyTemplateLock, setApplyTemplateLock ] = useState( false );
const [ lock, setLock ] = useState( { move: false, remove: false } );
const { canEdit, canMove, canRemove } = useBlockLock( clientId );
const { isReusable, hasTemplateLock } = useSelect(
const { isReusable, templateLock, hasTemplateLock } = useSelect(
( select ) => {
const { getBlockName } = select( blockEditorStore );
const { getBlockName, getBlockAttributes } =
select( blockEditorStore );
const blockName = getBlockName( clientId );
const blockType = getBlockType( blockName );

return {
isReusable: isReusableBlock( blockType ),
templateLock: getBlockAttributes( clientId )?.templateLock,
hasTemplateLock: !! blockType?.attributes?.templateLock,
};
},
[ clientId ]
);
const [ applyTemplateLock, setApplyTemplateLock ] = useState(
templateLock ?? false
);
const { updateBlockAttributes } = useDispatch( blockEditorStore );
const blockInformation = useBlockDisplayInformation( clientId );
const instanceId = useInstanceId(
Expand Down

0 comments on commit 8262739

Please sign in to comment.