Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PluginDocumentSettingPanel in template inspector controls #60961

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 />
Copy link
Member

@Mamaduka Mamaduka Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike other post-type properties, the wp_template supports revisions, and unlike the trunk, this might result in revision panel rendering for templates.

I think @ntsekouras answered my questions here -#60961 (comment).

<PostTaxonomiesPanel />
<PostExcerptPanel />
<PostDiscussionPanel />
<PageAttributesPanel />
<PatternOverridesPanel />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that all of these components being rendered for templates is fine? It probably is just want to confirm that it doesn't result in different UIs than trunk :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were still rendered here: https://github.com/WordPress/gutenberg/pull/60961/files#diff-6139877d7164dad773ae6521334135a37eb7e0bb351ade4c4f2169aa69da6e34L137 in site editor, so it should be the same in post editor, since they have checks whether to render or not.

The alternative would be to separate them in site editor too(the above linked code) and just remove them from there and keep them in PagePanels.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally the revisions panel was rendered in site editor and now it does in post editor too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely worth unifying like you did.

{ ! 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 />
</>
);
}
Loading