Skip to content

Commit

Permalink
Restore PostSummary for pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 13, 2024
1 parent 22e2ed0 commit 12d2b9c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
2 changes: 0 additions & 2 deletions packages/editor/src/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ 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 @@ -174,7 +173,6 @@ 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
58 changes: 36 additions & 22 deletions packages/editor/src/components/sidebar/post-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/
import { __ } from '@wordpress/i18n';
import {
__experimentalVStack as VStack,
__experimentalHStack as HStack,
__experimentalVStack as VStack,
PanelBody,
} from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
Expand All @@ -28,21 +28,29 @@ import PostTemplatePanel from '../post-template/panel';
import PostTrashPanel from '../post-trash/panel';
import PostURLPanel from '../post-url/panel';
import { store as editorStore } from '../../store';
import { PATTERN_POST_TYPE } from '../../store/constants';

/**
* Module Constants
*/
const PANEL_NAME = 'post-status';

export default function PostSummary() {
const { isOpened, isRemoved } = useSelect( ( select ) => {
const { isOpened, isRemoved, isPattern } = 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 );
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.
isPattern: postType === PATTERN_POST_TYPE,
};
}, [] );
const { toggleEditorPanelOpened } = useDispatch( editorStore );
Expand All @@ -60,18 +68,22 @@ export default function PostSummary() {
<PluginPostStatusInfo.Slot>
{ ( fills ) => (
<>
<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 />
{ ! isPattern && (
<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>
) }
<VStack
spacing={ 1 }
style={ { marginBlockEnd: '12px' } }
Expand All @@ -87,13 +99,15 @@ export default function PostSummary() {
<PostSlugPanel />
<PostAuthorPanel />
{ fills }
<HStack
style={ {
marginTop: '16px',
} }
>
<PostTrashPanel />
</HStack>
{ ! isPattern && (
<HStack
style={ {
marginTop: '16px',
} }
>
<PostTrashPanel />
</HStack>
) }
</>
) }
</PluginPostStatusInfo.Slot>
Expand Down

0 comments on commit 12d2b9c

Please sign in to comment.