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

Editor: Move the sidebar component to the editor package #61497

Merged
merged 2 commits into from
May 8, 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
13 changes: 11 additions & 2 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import EditPostKeyboardShortcuts from '../keyboard-shortcuts';
import InitPatternModal from '../init-pattern-modal';
import BrowserURL from '../browser-url';
import Header from '../header';
import SettingsSidebar from '../sidebar/settings-sidebar';
import MetaBoxes from '../meta-boxes';
import WelcomeGuide from '../welcome-guide';
import { store as editPostStore } from '../../store';
Expand All @@ -63,6 +62,7 @@ const {
SavePublishPanels,
InterfaceSkeleton,
interfaceStore,
Sidebar,
} = unlock( editorPrivateApis );
const { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );

Expand Down Expand Up @@ -161,6 +161,7 @@ function Layout( { initialPost } ) {
hasHistory,
hasBlockBreadcrumbs,
blockEditorMode,
isEditingTemplate,
} = useSelect( ( select ) => {
const { get } = select( preferencesStore );
const { getEditorSettings, getPostTypeLabel } = select( editorStore );
Expand Down Expand Up @@ -198,6 +199,8 @@ function Layout( { initialPost } ) {
hasBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),
blockEditorMode:
select( blockEditorStore ).__unstableGetEditorMode(),
isEditingTemplate:
select( editorStore ).getCurrentPostType() === 'wp_template',
};
}, [] );

Expand Down Expand Up @@ -372,7 +375,13 @@ function Layout( { initialPost } ) {
<WelcomeGuide />
<InitPatternModal />
<PluginArea onError={ onPluginAreaError } />
{ ! isDistractionFree && <SettingsSidebar /> }
{ ! isDistractionFree && (
<Sidebar
extraPanels={
! isEditingTemplate && <MetaBoxes location="side" />
}
/>
) }
</>
);
}
Expand Down

This file was deleted.

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions packages/edit-post/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
@import "./components/header/fullscreen-mode-close/style.scss";
@import "./components/layout/style.scss";
@import "./components/meta-boxes/meta-boxes-area/style.scss";
@import "./components/sidebar/style.scss";
@import "./components/sidebar/post-format/style.scss";
@import "./components/sidebar/post-slug/style.scss";
@import "./components/sidebar/post-visibility/style.scss";
@import "./components/text-editor/style.scss";
@import "./components/visual-editor/style.scss";
@import "./components/welcome-guide/style.scss";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
* WordPress dependencies
*/
import { PanelRow } from '@wordpress/components';
import {
PostFormat as PostFormatForm,
PostFormatCheck,
} from '@wordpress/editor';

/**
* Internal dependencies
*/
import PostFormatForm from './';
import PostFormatCheck from './check';

export function PostFormat() {
return (
<PostFormatCheck>
<PanelRow className="edit-post-post-format">
<PanelRow className="editor-post-format__panel">
<PostFormatForm />
</PanelRow>
</PostFormatCheck>
Expand Down
6 changes: 6 additions & 0 deletions packages/editor/src/components/post-format/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[class].editor-post-format__suggestion {
margin: $grid-unit-05 0 0 0;
}

.editor-post-format__panel {
display: flex;
flex-direction: column;
align-items: stretch;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
* WordPress dependencies
*/
import { PanelRow } from '@wordpress/components';
import { PostSlug as PostSlugForm, PostSlugCheck } from '@wordpress/editor';

/**
* Internal dependencies
*/
import PostSlugForm from './';
import PostSlugCheck from './check';

export function PostSlug() {
return (
<PostSlugCheck>
<PanelRow className="edit-post-post-slug">
<PanelRow className="editor-post-slug">
<PostSlugForm />
</PanelRow>
</PostSlugCheck>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.edit-post-post-slug {
.editor-post-slug {
display: flex;
flex-direction: column;
align-items: stretch;
Expand Down
18 changes: 18 additions & 0 deletions packages/editor/src/components/post-sticky/panel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Internal dependencies
*/
import PostPanelRow from '../post-panel-row';
import PostStickyForm from './';
import PostStickyCheck from './check';

export function PostStickyPanel() {
return (
<PostStickyCheck>
<PostPanelRow>
<PostStickyForm />
</PostPanelRow>
</PostStickyCheck>
);
}

export default PostStickyPanel;
13 changes: 13 additions & 0 deletions packages/editor/src/components/post-trash/panel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Internal dependencies
*/
import PostTrashCheck from './check';
import PostTrashLink from './';

export default function PostTrashPanel() {
return (
<PostTrashCheck>
<PostTrashLink />
</PostTrashCheck>
);
}
4 changes: 4 additions & 0 deletions packages/editor/src/components/sidebar/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const sidebars = {
document: 'edit-post/document',
block: 'edit-post/block',
Comment on lines +2 to +3
Copy link
Member

Choose a reason for hiding this comment

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

Are we keeping the old namespace for now? Let's note that we should update these when sidebar-related store actions are also unified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't change these for BC reasons unfortunately. We discussed this with @fabiankaegy in a previous PR and this was the best tradeoff

};
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import { privateApis as componentsPrivateApis } from '@wordpress/components';
import { __, _x } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { forwardRef } from '@wordpress/element';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
*/
import { unlock } from '../../../lock-unlock';
import { sidebars } from '../settings-sidebar';
import { store as editorStore } from '../../store';
import { unlock } from '../../lock-unlock';
import { sidebars } from './constants';

const { Tabs } = unlock( componentsPrivateApis );

const SettingsHeader = ( _, ref ) => {
const SidebarHeader = ( _, ref ) => {
const { documentLabel } = useSelect( ( select ) => {
const { getPostTypeLabel } = select( editorStore );

Expand Down Expand Up @@ -46,4 +46,4 @@ const SettingsHeader = ( _, ref ) => {
);
};

export default forwardRef( SettingsHeader );
export default forwardRef( SidebarHeader );
Loading
Loading