From 05fbb7387fbccd6ee4a25d5c4e8adaadb8339362 Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Tue, 23 Apr 2024 13:36:50 +0300 Subject: [PATCH] Add PluginDocumentSettingPanel in template inspector controls (#60961) Co-authored-by: ntsekouras Co-authored-by: youknowriad Co-authored-by: Mamaduka --- .../sidebar/settings-sidebar/index.js | 22 ++++++++----------- .../plugin-template-setting-panel/index.js | 8 +++++++ .../src/components/sidebar-edit-mode/index.js | 17 ++++++++++++-- .../sidebar-edit-mode/page-panels/index.js | 10 --------- .../sidebar-edit-mode/template-panel/index.js | 14 ++---------- 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/packages/edit-post/src/components/sidebar/settings-sidebar/index.js b/packages/edit-post/src/components/sidebar/settings-sidebar/index.js index d28a1406796616..05fb4fc91e69c2 100644 --- a/packages/edit-post/src/components/sidebar/settings-sidebar/index.js +++ b/packages/edit-post/src/components/sidebar/settings-sidebar/index.js @@ -126,19 +126,15 @@ const SidebarContent = ( { tabName, keyboardShortcut, isEditingTemplate } ) => { /> } /> - { ! isEditingTemplate && ( - <> - - - - - - - - - - - ) } + { ! isEditingTemplate && } + + + + + + + + { ! isEditingTemplate && } diff --git a/packages/edit-site/src/components/plugin-template-setting-panel/index.js b/packages/edit-site/src/components/plugin-template-setting-panel/index.js index 3ba04b091ba4f9..5183350c633863 100644 --- a/packages/edit-site/src/components/plugin-template-setting-panel/index.js +++ b/packages/edit-site/src/components/plugin-template-setting-panel/index.js @@ -8,10 +8,16 @@ import { store as editorStore } from '@wordpress/editor'; import { useSelect } from '@wordpress/data'; import { createSlotFill } from '@wordpress/components'; +import deprecated from '@wordpress/deprecated'; const { Fill, Slot } = createSlotFill( 'PluginTemplateSettingPanel' ); const PluginTemplateSettingPanel = ( { children } ) => { + deprecated( 'wp.editSite.PluginTemplateSettingPanel', { + since: '6.6', + version: '6.8', + alternative: 'wp.editor.PluginDocumentSettingPanel', + } ); const isCurrentEntityTemplate = useSelect( ( select ) => select( editorStore ).getCurrentPostType() === 'wp_template', @@ -29,6 +35,8 @@ PluginTemplateSettingPanel.Slot = Slot; * Renders items in the Template Sidebar below the main information * like the Template Card. * + * @deprecated since 6.6. Use `wp.editor.PluginDocumentSettingPanel` instead. + * * @example * ```jsx * // Using ESNext syntax diff --git a/packages/edit-site/src/components/sidebar-edit-mode/index.js b/packages/edit-site/src/components/sidebar-edit-mode/index.js index 0fe117c3ea0679..7ac2098a00c1be 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/index.js +++ b/packages/edit-site/src/components/sidebar-edit-mode/index.js @@ -11,7 +11,14 @@ import { useCallback, useContext, useEffect, useRef } from '@wordpress/element'; import { useSelect, useDispatch } from '@wordpress/data'; import { store as blockEditorStore } from '@wordpress/block-editor'; import { store as coreStore } from '@wordpress/core-data'; -import { privateApis as editorPrivateApis } from '@wordpress/editor'; +import { + PageAttributesPanel, + PostDiscussionPanel, + PostExcerptPanel, + PostLastRevisionPanel, + PostTaxonomiesPanel, + privateApis as editorPrivateApis, +} from '@wordpress/editor'; /** * Internal dependencies @@ -25,7 +32,7 @@ import { store as editSiteStore } from '../../store'; import { unlock } from '../../lock-unlock'; const { Tabs } = unlock( componentsPrivateApis ); -const { interfaceStore, useAutoSwitchEditorSidebars } = +const { interfaceStore, useAutoSwitchEditorSidebars, PatternOverridesPanel } = unlock( editorPrivateApis ); const { Slot: InspectorSlot, Fill: InspectorFill } = createSlotFill( 'EditSiteSidebarInspector' @@ -91,6 +98,12 @@ const FillContents = ( { tabName, isEditingPage, supportsGlobalStyles } ) => { focusable={ false } > { isEditingPage ? : } + + + + + + diff --git a/packages/edit-site/src/components/sidebar-edit-mode/page-panels/index.js b/packages/edit-site/src/components/sidebar-edit-mode/page-panels/index.js index 021050d2c18f5a..c5d0a2cc7ba7ca 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/page-panels/index.js +++ b/packages/edit-site/src/components/sidebar-edit-mode/page-panels/index.js @@ -6,12 +6,7 @@ import { __ } from '@wordpress/i18n'; import { useSelect } from '@wordpress/data'; import { store as coreStore } from '@wordpress/core-data'; import { - PageAttributesPanel, PluginDocumentSettingPanel, - PostDiscussionPanel, - PostExcerptPanel, - PostLastRevisionPanel, - PostTaxonomiesPanel, store as editorStore, privateApis as editorPrivateApis, } from '@wordpress/editor'; @@ -95,11 +90,6 @@ export default function PagePanels() { ) } - - - - - ); } diff --git a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js index f656858e11fa21..f0abc9aed09d00 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js +++ b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js @@ -4,11 +4,7 @@ import { useSelect, useDispatch } from '@wordpress/data'; import { PanelBody, PanelRow } from '@wordpress/components'; import { - PageAttributesPanel, - PostDiscussionPanel, - PostExcerptPanel, - PostLastRevisionPanel, - PostTaxonomiesPanel, + PluginDocumentSettingPanel, privateApis as editorPrivateApis, store as editorStore, } from '@wordpress/editor'; @@ -30,7 +26,6 @@ import { TEMPLATE_PART_POST_TYPE } from '../../../utils/constants'; import { unlock } from '../../../lock-unlock'; const { PostCardPanel } = unlock( editorPrivateApis ); -const { PatternOverridesPanel } = unlock( editorPrivateApis ); const { useHistory } = unlock( routerPrivateApis ); function TemplatesList( { availableTemplates, onSelect } ) { @@ -114,6 +109,7 @@ export default function TemplatePanel() { } /> + { availablePatterns?.length > 0 && ( ) } - - - - - - ); }