Skip to content

Commit

Permalink
Hide summary and trash buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 10, 2024
1 parent f0f85ea commit 6d81094
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function PostTypeSupportCheck( { children, supportKeys } ) {
const { getPostType } = select( coreStore );
return getPostType( getEditedPostAttribute( 'type' ) );
}, [] );
let isSupported = true;
let isSupported = !! postType;
if ( postType ) {
isSupported = (
Array.isArray( supportKeys ) ? supportKeys : [ supportKeys ]
Expand Down
27 changes: 18 additions & 9 deletions packages/editor/src/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ import useAutoSwitchEditorSidebars from '../provider/use-auto-switch-editor-side
import { sidebars } from './constants';
import { unlock } from '../../lock-unlock';
import { store as editorStore } from '../../store';
import {
NAVIGATION_POST_TYPE,
TEMPLATE_PART_POST_TYPE,
TEMPLATE_POST_TYPE,
} from '../../store/constants';

const { Tabs } = unlock( componentsPrivateApis );

Expand All @@ -50,10 +55,10 @@ const SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {
const SidebarContent = ( {
tabName,
keyboardShortcut,
isEditingTemplate,
renderingMode,
onActionPerformed,
extraPanels,
showSummary = true,
} ) => {
const tabListRef = useRef( null );
// Because `PluginSidebar` renders a `ComplementaryArea`, we
Expand Down Expand Up @@ -117,7 +122,7 @@ const SidebarContent = ( {
/>
}
/>
{ ! isEditingTemplate && <PostSummary /> }
{ showSummary && <PostSummary /> }
<PluginDocumentSettingPanel.Slot />
{ renderingMode !== 'post-only' && (
<TemplateContentPanel />
Expand All @@ -140,8 +145,8 @@ const SidebarContent = ( {

const Sidebar = ( { extraPanels, onActionPerformed } ) => {
useAutoSwitchEditorSidebars();
const { tabName, keyboardShortcut, isEditingTemplate, renderingMode } =
useSelect( ( select ) => {
const { tabName, keyboardShortcut, showSummary, renderingMode } = useSelect(
( select ) => {
const shortcut = select(
keyboardShortcutsStore
).getShortcutRepresentation( 'core/editor/toggle-sidebar' );
Expand All @@ -164,12 +169,16 @@ const Sidebar = ( { extraPanels, onActionPerformed } ) => {
return {
tabName: _tabName,
keyboardShortcut: shortcut,
isEditingTemplate:
select( editorStore ).getCurrentPostType() ===
'wp_template',
showSummary: ! [
TEMPLATE_POST_TYPE,
TEMPLATE_PART_POST_TYPE,
NAVIGATION_POST_TYPE,
].includes( select( editorStore ).getCurrentPostType() ),
renderingMode: select( editorStore ).getRenderingMode(),
};
}, [] );
},
[]
);

const { enableComplementaryArea } = useDispatch( interfaceStore );

Expand All @@ -191,7 +200,7 @@ const Sidebar = ( { extraPanels, onActionPerformed } ) => {
<SidebarContent
tabName={ tabName }
keyboardShortcut={ keyboardShortcut }
isEditingTemplate={ isEditingTemplate }
showSummary={ showSummary }
renderingMode={ renderingMode }
onActionPerformed={ onActionPerformed }
extraPanels={ extraPanels }
Expand Down
9 changes: 0 additions & 9 deletions packages/editor/src/components/sidebar/post-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import { __ } from '@wordpress/i18n';
import {
__experimentalHStack as HStack,
__experimentalVStack as VStack,
PanelBody,
} from '@wordpress/components';
Expand All @@ -25,7 +24,6 @@ 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 Down Expand Up @@ -105,13 +103,6 @@ export default function PostSummary() {
<PostSlugPanel />
<PostAuthorPanel />
{ fills }
<HStack
style={ {
marginTop: '16px',
} }
>
<PostTrashPanel />
</HStack>
</>
) }
</PluginPostStatusInfo.Slot>
Expand Down

0 comments on commit 6d81094

Please sign in to comment.