Skip to content

Commit

Permalink
Editor: Use the same PostTemplatePanel between post and site editors (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Dec 7, 2023
1 parent cb3bb3d commit a66cf2a
Show file tree
Hide file tree
Showing 36 changed files with 641 additions and 716 deletions.
5 changes: 1 addition & 4 deletions packages/base-styles/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ $z-layers: (
".block-editor-block-rename-modal": 1000001,
".edit-site-list__rename-modal": 1000001,
".dataviews-action-modal": 1000001,
".edit-site-swap-template-modal": 1000001,
".editor-post-template__swap-template-modal": 1000001,
".edit-site-template-panel__replace-template-modal": 1000001,

// Note: The ConfirmDialog component's z-index is being set to 1000001 in packages/components/src/confirm-dialog/styles.ts
Expand Down Expand Up @@ -156,9 +156,6 @@ $z-layers: (
// Show tooltips above NUX tips, wp-admin menus, submenus, and sidebar:
".components-tooltip": 1000002,

// Keep template popover underneath 'Create custom template' modal overlay.
".edit-post-post-template__dialog": 99999,

// Make sure corner handles are above side handles for ResizableBox component
".components-resizable-box__handle": 2,
".components-resizable-box__side-handle": 2,
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function Header( {
select( blockEditorStore ).getBlockSelectionStart(),
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
isEditingTemplate:
select( editorStore ).getRenderingMode() !== 'post-only',
select( editorStore ).getRenderingMode() === 'template-only',
isPublishSidebarOpened:
select( editPostStore ).isPublishSidebarOpened(),
hasFixedToolbar: getPreference( 'core/edit-post', 'fixedToolbar' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function ModeSwitcher() {
isCodeEditingEnabled:
select( editorStore ).getEditorSettings().codeEditingEnabled,
isEditingTemplate:
select( editorStore ).getRenderingMode() !== 'post-only',
select( editorStore ).getRenderingMode() === 'template-only',
mode: select( editPostStore ).getEditorMode(),
} ),
[]
Expand Down
8 changes: 4 additions & 4 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,16 @@ function Layout() {
showIconLabels,
isDistractionFree,
showBlockBreadcrumbs,
isTemplateMode,
showMetaBoxes,
documentLabel,
} = useSelect( ( select ) => {
const { getEditorSettings, getPostTypeLabel } = select( editorStore );
const editorSettings = getEditorSettings();
const postTypeLabel = getPostTypeLabel();

return {
isTemplateMode:
select( editorStore ).getRenderingMode() !== 'post-only',
showMetaBoxes:
select( editorStore ).getRenderingMode() === 'post-only',
hasFixedToolbar:
select( editPostStore ).isFeatureActive( 'fixedToolbar' ),
sidebarIsOpened: !! (
Expand Down Expand Up @@ -349,7 +349,7 @@ function Layout() {
{ isRichEditingEnabled && mode === 'visual' && (
<VisualEditor styles={ styles } />
) }
{ ! isDistractionFree && ! isTemplateMode && (
{ ! isDistractionFree && showMetaBoxes && (
<div className="edit-post-layout__metaboxes">
<MetaBoxes location="normal" />
<MetaBoxes location="advanced" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
PostSwitchToDraftButton,
PostSyncStatus,
PostURLPanel,
PostTemplatePanel,
} from '@wordpress/editor';

/**
Expand All @@ -26,7 +27,6 @@ import PostFormat from '../post-format';
import PostPendingStatus from '../post-pending-status';
import PluginPostStatusInfo from '../plugin-post-status-info';
import { store as editPostStore } from '../../../store';
import PostTemplate from '../post-template';

/**
* Module Constants
Expand Down Expand Up @@ -62,7 +62,7 @@ export default function PostStatus() {
<>
<PostVisibility />
<PostSchedulePanel />
<PostTemplate />
<PostTemplatePanel />
<PostURLPanel />
<PostSyncStatus />
<PostSticky />
Expand Down
141 changes: 0 additions & 141 deletions packages/edit-post/src/components/sidebar/post-template/form.js

This file was deleted.

120 changes: 0 additions & 120 deletions packages/edit-post/src/components/sidebar/post-template/index.js

This file was deleted.

22 changes: 0 additions & 22 deletions packages/edit-post/src/components/sidebar/post-template/style.scss

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const SettingsHeader = ( { sidebarName } ) => {
return {
// translators: Default label for the Document sidebar tab, not selected.
documentLabel: getPostTypeLabel() || _x( 'Document', 'noun' ),
isTemplateMode: getRenderingMode() !== 'post-only',
isTemplateMode: getRenderingMode() === 'template-only',
};
}, [] );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const SettingsSidebar = () => {
sidebarName: sidebar,
keyboardShortcut: shortcut,
isTemplateMode:
select( editorStore ).getRenderingMode() !== 'post-only',
select( editorStore ).getRenderingMode() ===
'template-only',
};
},
[]
Expand Down
Loading

1 comment on commit a66cf2a

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in a66cf2a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7125830667
📝 Reported issues:

Please sign in to comment.