Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Don't render the Transform Into panel if there are no patterns #59217

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const CARD_ICONS = {

function TemplatesList( { availableTemplates, onSelect } ) {
const shownTemplates = useAsyncList( availableTemplates );
if ( ! availableTemplates || availableTemplates?.length < 2 ) {
if ( ! availableTemplates || availableTemplates?.length === 0 ) {
return null;
}

Expand Down Expand Up @@ -105,22 +105,25 @@ export default function TemplatePanel() {
<TemplateAreas />
</SidebarCard>
</PanelBody>
<PanelBody
title={ __( 'Transform into:' ) }
initialOpen={ postType === TEMPLATE_PART_POST_TYPE }
>
<PanelRow>
<p>
{ __(
'Choose a predefined pattern to switch up the look of your template.' // TODO - make this dynamic?
) }
</p>
</PanelRow>
<TemplatesList
availableTemplates={ availablePatterns }
onSelect={ onTemplateSelect }
/>
</PanelBody>
{ availablePatterns?.length > 0 && (
<PanelBody
title={ __( 'Transform into:' ) }
initialOpen={ postType === TEMPLATE_PART_POST_TYPE }
>
<PanelRow>
<p>
{ __(
'Choose a predefined pattern to switch up the look of your template.' // TODO - make this dynamic?
) }
</p>
</PanelRow>

<TemplatesList
availableTemplates={ availablePatterns }
onSelect={ onTemplateSelect }
/>
</PanelBody>
) }
<PostLastRevisionPanel />
<PostTaxonomiesPanel />
<PostFeaturedImagePanel />
Expand Down
Loading