Skip to content

Commit

Permalink
Restore PostTrash button
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 13, 2024
1 parent a09ad82 commit b80f5c6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 39 deletions.
2 changes: 2 additions & 0 deletions packages/editor/src/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(),
};
Expand Down
69 changes: 30 additions & 39 deletions packages/editor/src/components/sidebar/post-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';

Expand All @@ -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 ) {
Expand All @@ -72,22 +60,18 @@ export default function PostSummary() {
<PluginPostStatusInfo.Slot>
{ ( fills ) => (
<>
{ showPostContentPanels && (
<VStack
spacing={ 3 }
// TODO: this needs to be consolidated with the panel in site editor, when we unify them.
style={ { marginBlockEnd: '24px' } }
>
<PostFeaturedImagePanel
withPanelBody={ false }
/>
<PostExcerptPanel />
<VStack spacing={ 1 }>
<PostContentInformation />
<PostLastEditedPanel />
</VStack>
<VStack
spacing={ 3 }
// TODO: this needs to be consolidated with the panel in site editor, when we unify them.
style={ { marginBlockEnd: '24px' } }
>
<PostFeaturedImagePanel withPanelBody={ false } />
<PostExcerptPanel />
<VStack spacing={ 1 }>
<PostContentInformation />
<PostLastEditedPanel />
</VStack>
) }
</VStack>
<VStack
spacing={ 1 }
style={ { marginBlockEnd: '12px' } }
Expand All @@ -103,6 +87,13 @@ export default function PostSummary() {
<PostSlugPanel />
<PostAuthorPanel />
{ fills }
<HStack
style={ {
marginTop: '16px',
} }
>
<PostTrashPanel />
</HStack>
</>
) }
</PluginPostStatusInfo.Slot>
Expand Down

0 comments on commit b80f5c6

Please sign in to comment.