diff --git a/packages/block-library/src/block/edit.js b/packages/block-library/src/block/edit.js index 86c9483c98b34..53422e1c4cb8c 100644 --- a/packages/block-library/src/block/edit.js +++ b/packages/block-library/src/block/edit.js @@ -121,6 +121,51 @@ export default function ReusableBlockEditRecursionWrapper( props ) { ); } +function ReusableBlockControl( { + recordId, + canOverrideBlocks, + hasContent, + handleEditOriginal, + resetContent, +} ) { + const canUserEdit = useSelect( + ( select ) => + !! select( coreStore ).canUser( 'update', { + kind: 'postType', + name: 'wp_block', + id: recordId, + } ), + [ recordId ] + ); + + return ( + <> + { canUserEdit && !! handleEditOriginal && ( + + + + { __( 'Edit original' ) } + + + + ) } + + { canOverrideBlocks && ( + + + + { __( 'Reset' ) } + + + + ) } + + ); +} + function ReusableBlockEdit( { name, attributes: { ref, content }, @@ -143,29 +188,20 @@ function ReusableBlockEdit( { const { innerBlocks, - userCanEdit, onNavigateToEntityRecord, editingMode, hasPatternOverridesSource, } = useSelect( ( select ) => { - const { canUser } = select( coreStore ); const { getBlocks, getSettings, getBlockEditingMode: _getBlockEditingMode, } = select( blockEditorStore ); const { getBlockBindingsSource } = unlock( select( blocksStore ) ); - const canEdit = canUser( 'update', { - kind: 'postType', - name: 'wp_block', - id: ref, - } ); - // For editing link to the site editor if the theme and user permissions support it. return { innerBlocks: getBlocks( patternClientId ), - userCanEdit: canEdit, getBlockEditingMode: _getBlockEditingMode, onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord, @@ -175,7 +211,7 @@ function ReusableBlockEdit( { ), }; }, - [ patternClientId, ref ] + [ patternClientId ] ); // Sync the editing mode of the pattern block with the inner blocks. @@ -256,27 +292,18 @@ function ReusableBlockEdit( { return ( <> - { userCanEdit && onNavigateToEntityRecord && ( - - - - { __( 'Edit original' ) } - - - - ) } - - { canOverrideBlocks && ( - - - - { __( 'Reset' ) } - - - + { hasResolved && ( + ) } { children === null ? (