Skip to content

Commit

Permalink
Site Editor: Use the correct icon for Patterns in sidebar card (WordP…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Jul 25, 2023
1 parent cc63991 commit 563402f
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { store as editorStore } from '@wordpress/editor';
import { store as coreStore } from '@wordpress/core-data';
import { decodeEntities } from '@wordpress/html-entities';
import { __ } from '@wordpress/i18n';
import { navigation as navigationIcon } from '@wordpress/icons';
import { navigation, symbol } from '@wordpress/icons';

/**
* Internal dependencies
Expand All @@ -18,11 +18,13 @@ import TemplateAreas from './template-areas';
import LastRevision from './last-revision';
import SidebarCard from '../sidebar-card';

const CARD_ICONS = {
wp_block: symbol,
wp_navigation: navigation,
};

export default function TemplatePanel() {
const {
info: { title, description, icon },
record,
} = useSelect( ( select ) => {
const { title, description, icon, record } = useSelect( ( select ) => {
const { getEditedPostType, getEditedPostId } = select( editSiteStore );
const { getEditedEntityRecord } = select( coreStore );
const { __experimentalGetTemplateInfo: getTemplateInfo } =
Expand All @@ -31,10 +33,14 @@ export default function TemplatePanel() {
const postType = getEditedPostType();
const postId = getEditedPostId();
const _record = getEditedEntityRecord( 'postType', postType, postId );
const info = getTemplateInfo( _record );

const info = _record ? getTemplateInfo( _record ) : {};

return { info, record: _record };
return {
title: info.title,
description: info.description,
icon: info.icon,
record: _record,
};
}, [] );

if ( ! title && ! description ) {
Expand All @@ -46,9 +52,7 @@ export default function TemplatePanel() {
<SidebarCard
className="edit-site-template-card"
title={ decodeEntities( title ) }
icon={
record?.type === 'wp_navigation' ? navigationIcon : icon
}
icon={ CARD_ICONS[ record?.type ] ?? icon }
description={ decodeEntities( description ) }
actions={ <TemplateActions template={ record } /> }
>
Expand Down

0 comments on commit 563402f

Please sign in to comment.