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

Site Editor: Remove unnecessary hook from 'PageTemplates' #52903

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 6 additions & 19 deletions packages/edit-site/src/components/page-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import {
__experimentalVStack as VStack,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { store as coreStore, useEntityRecords } from '@wordpress/core-data';
import { useEntityRecords } from '@wordpress/core-data';
import { decodeEntities } from '@wordpress/html-entities';

/**
Expand All @@ -21,7 +20,6 @@ import Link from '../routes/link';
import AddedBy from '../list/added-by';
import TemplateActions from '../template-actions';
import AddNewTemplate from '../add-new-template';
import { store as editSiteStore } from '../../store';

export default function PageTemplates() {
const { records: templates } = useEntityRecords(
Expand All @@ -32,15 +30,6 @@ export default function PageTemplates() {
}
);

const { canCreate } = useSelect( ( select ) => {
const { supportsTemplatePartsMode } =
select( editSiteStore ).getSettings();
return {
postType: select( coreStore ).getPostType( 'wp_template' ),
canCreate: ! supportsTemplatePartsMode,
};
} );

const columns = [
{
header: __( 'Template' ),
Expand Down Expand Up @@ -89,13 +78,11 @@ export default function PageTemplates() {
<Page
title={ __( 'Templates' ) }
actions={
canCreate && (
<AddNewTemplate
templateType={ 'wp_template' }
showIcon={ false }
toggleProps={ { variant: 'primary' } }
/>
)
<AddNewTemplate
templateType={ 'wp_template' }
showIcon={ false }
toggleProps={ { variant: 'primary' } }
/>
}
>
{ templates && <Table data={ templates } columns={ columns } /> }
Expand Down