From e46f7af684d8ca411e463ba0e80fc8f359882d30 Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Fri, 14 Apr 2023 15:27:27 +1000 Subject: [PATCH] Update Query to use BlockInfo for new post link --- packages/block-library/src/query/hooks.js | 20 +++++++++++++------- packages/block-library/src/query/index.js | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/block-library/src/query/hooks.js b/packages/block-library/src/query/hooks.js index b2bb32a7be7b4..1f367e13d019f 100644 --- a/packages/block-library/src/query/hooks.js +++ b/packages/block-library/src/query/hooks.js @@ -5,8 +5,14 @@ import { __ } from '@wordpress/i18n'; import { createInterpolateElement } from '@wordpress/element'; import { addQueryArgs } from '@wordpress/url'; import { createHigherOrderComponent } from '@wordpress/compose'; -import { InspectorControls } from '@wordpress/block-editor'; +import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor'; +/** + * Internal dependencies + */ +import { unlock } from '../private-apis'; + +const { BlockInfo } = unlock( blockEditorPrivateApis ); const CreateNewPostLink = ( { attributes: { query: { postType } = {} } = {}, } ) => { @@ -17,7 +23,7 @@ const CreateNewPostLink = ( { return (
{ createInterpolateElement( - __( 'Create a new post for this feed.' ), + __( 'Add new post' ), // eslint-disable-next-line jsx-a11y/anchor-has-content { a: } ) } @@ -31,7 +37,7 @@ const CreateNewPostLink = ( { * @param {Function} BlockEdit Original component * @return {Function} Wrapped component */ -const queryTopInspectorControls = createHigherOrderComponent( +const queryTopBlockInfo = createHigherOrderComponent( ( BlockEdit ) => ( props ) => { const { name, isSelected } = props; if ( name !== 'core/query' || ! isSelected ) { @@ -40,14 +46,14 @@ const queryTopInspectorControls = createHigherOrderComponent( return ( <> - + - + ); }, - 'withInspectorControls' + 'withBlockInfo' ); -export default queryTopInspectorControls; +export default queryTopBlockInfo; diff --git a/packages/block-library/src/query/index.js b/packages/block-library/src/query/index.js index baf58470b76ac..c109410e58c0c 100644 --- a/packages/block-library/src/query/index.js +++ b/packages/block-library/src/query/index.js @@ -13,7 +13,7 @@ import edit from './edit'; import save from './save'; import variations from './variations'; import deprecated from './deprecated'; -import queryInspectorControls from './hooks'; +import queryBlockInfo from './hooks'; const { name } = metadata; export { metadata, name }; @@ -27,7 +27,7 @@ export const settings = { }; export const init = () => { - addFilter( 'editor.BlockEdit', 'core/query', queryInspectorControls ); + addFilter( 'editor.BlockEdit', 'core/query', queryBlockInfo ); return initBlock( { name, metadata, settings } ); };