From f537a9c60ab508b6d6ed12069b7cc7fc120018d8 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 25 Apr 2023 10:40:32 +0300 Subject: [PATCH] Fix BlockInfo slot displaying logic --- .../components/block-info-slot-fill/index.js | 9 ++- packages/block-library/src/query/hooks.js | 59 ------------------- 2 files changed, 8 insertions(+), 60 deletions(-) delete mode 100644 packages/block-library/src/query/hooks.js diff --git a/packages/block-editor/src/components/block-info-slot-fill/index.js b/packages/block-editor/src/components/block-info-slot-fill/index.js index bba49bc7cc6375..db7919b6ef5eab 100644 --- a/packages/block-editor/src/components/block-info-slot-fill/index.js +++ b/packages/block-editor/src/components/block-info-slot-fill/index.js @@ -7,11 +7,18 @@ import { privateApis as componentsPrivateApis } from '@wordpress/components'; * Internal dependencies */ import { unlock } from '../../lock-unlock'; +import useDisplayBlockControls from '../use-display-block-controls'; const { createPrivateSlotFill } = unlock( componentsPrivateApis ); const { Fill, Slot } = createPrivateSlotFill( 'BlockInformation' ); -const BlockInfo = ( props ) => ; +const BlockInfo = ( props ) => { + const isDisplayed = useDisplayBlockControls(); + if ( ! isDisplayed ) { + return null; + } + return ; +}; BlockInfo.Slot = ( props ) => ; export default BlockInfo; diff --git a/packages/block-library/src/query/hooks.js b/packages/block-library/src/query/hooks.js deleted file mode 100644 index 1f367e13d019f3..00000000000000 --- a/packages/block-library/src/query/hooks.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { createInterpolateElement } from '@wordpress/element'; -import { addQueryArgs } from '@wordpress/url'; -import { createHigherOrderComponent } from '@wordpress/compose'; -import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor'; - -/** - * Internal dependencies - */ -import { unlock } from '../private-apis'; - -const { BlockInfo } = unlock( blockEditorPrivateApis ); -const CreateNewPostLink = ( { - attributes: { query: { postType } = {} } = {}, -} ) => { - if ( ! postType ) return null; - const newPostUrl = addQueryArgs( 'post-new.php', { - post_type: postType, - } ); - return ( -
- { createInterpolateElement( - __( 'Add new post' ), - // eslint-disable-next-line jsx-a11y/anchor-has-content - { a: } - ) } -
- ); -}; - -/** - * Override the default edit UI to include layout controls - * - * @param {Function} BlockEdit Original component - * @return {Function} Wrapped component - */ -const queryTopBlockInfo = createHigherOrderComponent( - ( BlockEdit ) => ( props ) => { - const { name, isSelected } = props; - if ( name !== 'core/query' || ! isSelected ) { - return ; - } - - return ( - <> - - - - - - ); - }, - 'withBlockInfo' -); - -export default queryTopBlockInfo;