Skip to content

Commit

Permalink
Add PluginDocumentSettingPanel in template inspector controls (#60961)
Browse files Browse the repository at this point in the history
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
  • Loading branch information
4 people authored Apr 23, 2024
1 parent 32e319d commit 05fbb73
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,15 @@ const SidebarContent = ( { tabName, keyboardShortcut, isEditingTemplate } ) => {
/>
}
/>
{ ! isEditingTemplate && (
<>
<PostStatus />
<PluginDocumentSettingPanel.Slot />
<PostLastRevisionPanel />
<PostTaxonomiesPanel />
<PostExcerptPanel />
<PostDiscussionPanel />
<PageAttributesPanel />
<PatternOverridesPanel />
<MetaBoxes location="side" />
</>
) }
{ ! isEditingTemplate && <PostStatus /> }
<PluginDocumentSettingPanel.Slot />
<PostLastRevisionPanel />
<PostTaxonomiesPanel />
<PostExcerptPanel />
<PostDiscussionPanel />
<PageAttributesPanel />
<PatternOverridesPanel />
{ ! isEditingTemplate && <MetaBoxes location="side" /> }
</Tabs.TabPanel>
<Tabs.TabPanel tabId={ sidebars.block } focusable={ false }>
<BlockInspector />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down
17 changes: 15 additions & 2 deletions packages/edit-site/src/components/sidebar-edit-mode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -91,6 +98,12 @@ const FillContents = ( { tabName, isEditingPage, supportsGlobalStyles } ) => {
focusable={ false }
>
{ isEditingPage ? <PagePanels /> : <TemplatePanel /> }
<PostLastRevisionPanel />
<PostTaxonomiesPanel />
<PostExcerptPanel />
<PostDiscussionPanel />
<PageAttributesPanel />
<PatternOverridesPanel />
</Tabs.TabPanel>
<Tabs.TabPanel tabId="edit-post/block" focusable={ false }>
<InspectorSlot bubblesVirtually />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -95,11 +90,6 @@ export default function PagePanels() {
<PageContent />
</PanelBody>
) }
<PostLastRevisionPanel />
<PostTaxonomiesPanel />
<PostExcerptPanel />
<PostDiscussionPanel />
<PageAttributesPanel />
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 } ) {
Expand Down Expand Up @@ -114,6 +109,7 @@ export default function TemplatePanel() {
}
/>
<PluginTemplateSettingPanel.Slot />
<PluginDocumentSettingPanel.Slot />
{ availablePatterns?.length > 0 && (
<PanelBody
title={ __( 'Transform into:' ) }
Expand All @@ -133,12 +129,6 @@ export default function TemplatePanel() {
/>
</PanelBody>
) }
<PostLastRevisionPanel />
<PostTaxonomiesPanel />
<PostExcerptPanel />
<PostDiscussionPanel />
<PageAttributesPanel />
<PatternOverridesPanel />
</>
);
}

0 comments on commit 05fbb73

Please sign in to comment.