Skip to content

Commit

Permalink
Site Editor: Use the correct icon for Patterns in sidebar card (#52931)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed 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

1 comment on commit 563402f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 563402f.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5657690358
📝 Reported issues:

Please sign in to comment.