From 514b670054cac6b84d44b606af3973649ba3354b Mon Sep 17 00:00:00 2001 From: dhruvang21 <105810308+dhruvang21@users.noreply.github.com> Date: Tue, 26 Nov 2024 15:58:03 +0530 Subject: [PATCH] Query Loop block: remove 'add new post' prompt in the sidebar (#67189) Co-authored-by: dhruvang21 Co-authored-by: ntsekouras Co-authored-by: t-hamano Co-authored-by: aaronrobertshaw Co-authored-by: annezazu --- .../components/block-info-slot-fill/index.js | 25 --------------- .../src/components/block-inspector/index.js | 2 -- packages/block-editor/src/private-apis.js | 2 -- .../create-new-post-link.js | 32 ------------------- .../query/edit/inspector-controls/index.js | 10 ------ packages/block-library/src/query/editor.scss | 4 --- 6 files changed, 75 deletions(-) delete mode 100644 packages/block-editor/src/components/block-info-slot-fill/index.js delete mode 100644 packages/block-library/src/query/edit/inspector-controls/create-new-post-link.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 deleted file mode 100644 index 3592fc0424329b..00000000000000 --- a/packages/block-editor/src/components/block-info-slot-fill/index.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * WordPress dependencies - */ -import { createSlotFill } from '@wordpress/components'; - -/** - * Internal dependencies - */ -import { - useBlockEditContext, - mayDisplayControlsKey, -} from '../block-edit/context'; - -const { Fill, Slot } = createSlotFill( Symbol( 'BlockInformation' ) ); - -const BlockInfo = ( props ) => { - const context = useBlockEditContext(); - if ( ! context[ mayDisplayControlsKey ] ) { - return null; - } - return ; -}; -BlockInfo.Slot = ( props ) => ; - -export default BlockInfo; diff --git a/packages/block-editor/src/components/block-inspector/index.js b/packages/block-editor/src/components/block-inspector/index.js index 475d4f6a4b8c2e..450a370b5c212a 100644 --- a/packages/block-editor/src/components/block-inspector/index.js +++ b/packages/block-editor/src/components/block-inspector/index.js @@ -26,7 +26,6 @@ import useInspectorControlsTabs from '../inspector-controls-tabs/use-inspector-c import AdvancedControls from '../inspector-controls-tabs/advanced-controls-panel'; import PositionControls from '../inspector-controls-tabs/position-controls-panel'; import useBlockInspectorAnimationSettings from './useBlockInspectorAnimationSettings'; -import BlockInfo from '../block-info-slot-fill'; import BlockQuickNavigation from '../block-quick-navigation'; import { useBorderPanelLabel } from '../../hooks/border'; @@ -253,7 +252,6 @@ const BlockInspectorSingleBlock = ( { className={ blockInformation.isSynced && 'is-synced' } /> - { showTabs && ( { - const newPostUrl = addQueryArgs( 'post-new.php', { - post_type: postType, - } ); - - const addNewItemLabel = useSelect( - ( select ) => { - const { getPostType } = select( coreStore ); - return getPostType( postType )?.labels?.add_new_item; - }, - [ postType ] - ); - return ( -
- { createInterpolateElement( - '' + addNewItemLabel + '', - // eslint-disable-next-line jsx-a11y/anchor-has-content - { a: } - ) } -
- ); -}; - -export default CreateNewPostLink; diff --git a/packages/block-library/src/query/edit/inspector-controls/index.js b/packages/block-library/src/query/edit/inspector-controls/index.js index 7d5745e190c9a7..0ae4b052b57873 100644 --- a/packages/block-library/src/query/edit/inspector-controls/index.js +++ b/packages/block-library/src/query/edit/inspector-controls/index.js @@ -15,7 +15,6 @@ import { import { useSelect } from '@wordpress/data'; import { store as coreStore } from '@wordpress/core-data'; import { __ } from '@wordpress/i18n'; -import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor'; import { debounce } from '@wordpress/compose'; import { useEffect, useState, useCallback } from '@wordpress/element'; @@ -28,11 +27,9 @@ import ParentControl from './parent-control'; import { TaxonomyControls } from './taxonomy-controls'; import FormatControls from './format-controls'; import StickyControl from './sticky-control'; -import CreateNewPostLink from './create-new-post-link'; import PerPageControl from './per-page-control'; import OffsetControl from './offset-controls'; import PagesControl from './pages-control'; -import { unlock } from '../../../lock-unlock'; import { usePostTypes, useIsPostTypeHierarchical, @@ -42,8 +39,6 @@ import { } from '../../utils'; import { useToolsPanelDropdownMenuProps } from '../../../utils/hooks'; -const { BlockInfo } = unlock( blockEditorPrivateApis ); - export default function QueryInspectorControls( props ) { const { attributes, setQuery, setDisplayLayout, isSingular } = props; const { query, displayLayout } = attributes; @@ -191,11 +186,6 @@ export default function QueryInspectorControls( props ) { return ( <> - { !! postType && ( - - - - ) } { showSettingsPanel && ( { showInheritControl && ( diff --git a/packages/block-library/src/query/editor.scss b/packages/block-library/src/query/editor.scss index b86eae0cbf65a8..da863bff0b5da6 100644 --- a/packages/block-library/src/query/editor.scss +++ b/packages/block-library/src/query/editor.scss @@ -6,10 +6,6 @@ } } -.wp-block-query__create-new-link { - padding: 0 $grid-unit-20 $grid-unit-20 52px; -} - .block-library-query__pattern-selection-content .block-editor-block-patterns-list { display: grid; grid-template-columns: 1fr 1fr 1fr;