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

Introduce new PluginTemplateSettingPanel slot #50257

Merged
merged 2 commits into from
May 3, 2023
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
@@ -0,0 +1,33 @@
/**
* Defines an extensibility slot for the Template sidebar.
*/

/**
* WordPress dependencies
*/
import { createSlotFill } from '@wordpress/components';

const { Fill, Slot } = createSlotFill( 'PluginTemplateSettingPanel' );

const PluginTemplateSettingPanel = Fill;
PluginTemplateSettingPanel.Slot = Slot;

/**
* Renders items in the Template Sidebar below the main information
* like the Template Card.
*
* @example
* ```jsx
* // Using ESNext syntax
* import { PluginTemplateSettingPanel } from '@wordpress/edit-site';
*
* const MyTemplateSettingTest = () => (
* <PluginTemplateSettingPanel>
* <p>Hello, World!</p>
* </PluginTemplateSettingPanel>
* );
* ```
*
* @return {WPComponent} The component to be rendered.
*/
export default PluginTemplateSettingPanel;
21 changes: 16 additions & 5 deletions packages/edit-site/src/components/sidebar-edit-mode/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* WordPress dependencies
*/
import { createSlotFill, PanelBody } from '@wordpress/components';
import { createSlotFill, PanelBody, PanelRow } from '@wordpress/components';
import { isRTL, __ } from '@wordpress/i18n';
import { drawerLeft, drawerRight } from '@wordpress/icons';
import { useEffect, Fragment } from '@wordpress/element';
import { useEffect } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as interfaceStore } from '@wordpress/interface';
import { store as blockEditorStore } from '@wordpress/block-editor';
Expand All @@ -16,7 +16,9 @@ import DefaultSidebar from './default-sidebar';
import GlobalStylesSidebar from './global-styles-sidebar';
import { STORE_NAME } from '../../store/constants';
import SettingsHeader from './settings-header';
import LastRevision from './template-revisions';
import TemplateCard from './template-card';
import PluginTemplateSettingPanel from '../plugin-template-setting-panel';
import { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from './constants';
import { store as editSiteStore } from '../../store';

Expand Down Expand Up @@ -74,9 +76,18 @@ export function SidebarComplementaryAreaFills() {
headerClassName="edit-site-sidebar-edit-mode__panel-tabs"
>
{ sidebarName === SIDEBAR_TEMPLATE && (
<PanelBody>
<TemplateCard />
</PanelBody>
<>
<PanelBody>
<TemplateCard />
<PanelRow
header={ __( 'Editing history' ) }
className="edit-site-template-revisions"
>
<LastRevision />
</PanelRow>
Comment on lines +82 to +87
Copy link
Contributor

Choose a reason for hiding this comment

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

This is new to this PR. Did it slip in accidentally from another PR or was it intentional? I didn't see it mentioned in the PR discussion so thought I'd ask :)

Copy link
Contributor

@nerrad nerrad May 2, 2023

Choose a reason for hiding this comment

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

Oh nvm, I see it was moved here from template-card/index.js.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh.. I forgot to comment about it, thanks! Yes, I just moved it outside of TemplateCard component because I think it shouldn't be a part of that component.

</PanelBody>
<PluginTemplateSettingPanel.Slot />
</>
) }
{ sidebarName === SIDEBAR_BLOCK && (
<InspectorSlot bubblesVirtually />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { PanelRow, Icon } from '@wordpress/components';
import { Icon } from '@wordpress/components';
import { store as editorStore } from '@wordpress/editor';
import { store as coreStore } from '@wordpress/core-data';
import { decodeEntities } from '@wordpress/html-entities';
Expand All @@ -14,7 +13,6 @@ import { decodeEntities } from '@wordpress/html-entities';
import { store as editSiteStore } from '../../../store';
import TemplateActions from './template-actions';
import TemplateAreas from './template-areas';
import LastRevision from './last-revision';

export default function TemplateCard() {
const {
Expand Down Expand Up @@ -56,12 +54,6 @@ export default function TemplateCard() {
<TemplateAreas />
</div>
</div>
<PanelRow
header={ __( 'Editing history' ) }
className="edit-site-template-revisions"
>
<LastRevision />
</PanelRow>
</>
);
}
1 change: 1 addition & 0 deletions packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ export function reinitializeEditor() {
export { default as PluginSidebar } from './components/sidebar-edit-mode/plugin-sidebar';
export { default as PluginSidebarMoreMenuItem } from './components/header-edit-mode/plugin-sidebar-more-menu-item';
export { default as PluginMoreMenuItem } from './components/header-edit-mode/plugin-more-menu-item';
export { default as PluginTemplateSettingPanel } from './components/plugin-template-setting-panel';