From b80f5c63331ac46f6fc6faf1d569a842047ff462 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 13 May 2024 10:45:03 +0100 Subject: [PATCH] Restore PostTrash button --- .../editor/src/components/sidebar/index.js | 2 + .../src/components/sidebar/post-summary.js | 69 ++++++++----------- 2 files changed, 32 insertions(+), 39 deletions(-) diff --git a/packages/editor/src/components/sidebar/index.js b/packages/editor/src/components/sidebar/index.js index 7c1f914c725c8a..fd79551741c5f3 100644 --- a/packages/editor/src/components/sidebar/index.js +++ b/packages/editor/src/components/sidebar/index.js @@ -41,6 +41,7 @@ import { unlock } from '../../lock-unlock'; import { store as editorStore } from '../../store'; import { NAVIGATION_POST_TYPE, + PATTERN_POST_TYPE, TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE, } from '../../store/constants'; @@ -173,6 +174,7 @@ const Sidebar = ( { extraPanels, onActionPerformed } ) => { TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE, + PATTERN_POST_TYPE, ].includes( select( editorStore ).getCurrentPostType() ), renderingMode: select( editorStore ).getRenderingMode(), }; diff --git a/packages/editor/src/components/sidebar/post-summary.js b/packages/editor/src/components/sidebar/post-summary.js index ad775f4af9f278..d79bc9161024c0 100644 --- a/packages/editor/src/components/sidebar/post-summary.js +++ b/packages/editor/src/components/sidebar/post-summary.js @@ -4,6 +4,7 @@ import { __ } from '@wordpress/i18n'; import { __experimentalVStack as VStack, + __experimentalHStack as HStack, PanelBody, } from '@wordpress/components'; import { useDispatch, useSelect } from '@wordpress/data'; @@ -24,6 +25,7 @@ import PostStatusPanel from '../post-status'; import PostStickyPanel from '../post-sticky'; import PostSyncStatus from '../post-sync-status'; import PostTemplatePanel from '../post-template/panel'; +import PostTrashPanel from '../post-trash/panel'; import PostURLPanel from '../post-url/panel'; import { store as editorStore } from '../../store'; @@ -33,30 +35,16 @@ import { store as editorStore } from '../../store'; const PANEL_NAME = 'post-status'; export default function PostSummary() { - const { isOpened, isRemoved, showPostContentPanels } = useSelect( - ( select ) => { - // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do - // not use isEditorPanelEnabled since this panel should not be disabled through the UI. - const { - isEditorPanelRemoved, - isEditorPanelOpened, - getCurrentPostType, - } = select( editorStore ); - const postType = getCurrentPostType(); - return { - isRemoved: isEditorPanelRemoved( PANEL_NAME ), - isOpened: isEditorPanelOpened( PANEL_NAME ), - // Post excerpt panel is rendered in different place depending on the post type. - // So we cannot make this check inside the PostExcerpt component based on the current edited entity. - showPostContentPanels: ! [ - 'wp_template', - 'wp_template_part', - 'wp_block', - ].includes( postType ), - }; - }, - [] - ); + const { isOpened, isRemoved } = useSelect( ( select ) => { + // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do + // not use isEditorPanelEnabled since this panel should not be disabled through the UI. + const { isEditorPanelRemoved, isEditorPanelOpened } = + select( editorStore ); + return { + isRemoved: isEditorPanelRemoved( PANEL_NAME ), + isOpened: isEditorPanelOpened( PANEL_NAME ), + }; + }, [] ); const { toggleEditorPanelOpened } = useDispatch( editorStore ); if ( isRemoved ) { @@ -72,22 +60,18 @@ export default function PostSummary() { { ( fills ) => ( <> - { showPostContentPanels && ( - - - - - - - + + + + + + - ) } + { fills } + + + ) }