diff --git a/packages/edit-site/src/components/editor/use-editor-title.js b/packages/edit-site/src/components/editor/use-editor-title.js index 91a56f9fbd4929..727b190117e02a 100644 --- a/packages/edit-site/src/components/editor/use-editor-title.js +++ b/packages/edit-site/src/components/editor/use-editor-title.js @@ -28,10 +28,7 @@ function useEditorTitle( postType, postId ) { postId ); - const { - default_template_part_areas: templateAreas = [], - default_template_types: templateTypes = [], - } = + const { default_template_types: templateTypes = [] } = select( coreStore ).getEntityRecord( 'root', '__unstableBase' @@ -39,7 +36,6 @@ function useEditorTitle( postType, postId ) { const templateInfo = getTemplateInfo( { template: _record, - templateAreas, templateTypes, } ); diff --git a/packages/editor/src/components/document-bar/index.js b/packages/editor/src/components/document-bar/index.js index 094827019c8751..7b94a6fbeb3be9 100644 --- a/packages/editor/src/components/document-bar/index.js +++ b/packages/editor/src/components/document-bar/index.js @@ -82,15 +82,11 @@ export default function DocumentBar( props ) { _postId ); - const { - default_template_part_areas: templateAreas = [], - default_template_types: templateTypes = [], - } = + const { default_template_types: templateTypes = [] } = select( coreStore ).getEntityRecord( 'root', '__unstableBase' ) ?? {}; const _templateInfo = getTemplateInfo( { - templateAreas, templateTypes, template: _document, } ); diff --git a/packages/editor/src/components/entities-saved-states/entity-record-item.js b/packages/editor/src/components/entities-saved-states/entity-record-item.js index 9c4568dc237bb9..e8219c4cca7ae1 100644 --- a/packages/editor/src/components/entities-saved-states/entity-record-item.js +++ b/packages/editor/src/components/entities-saved-states/entity-record-item.js @@ -35,10 +35,7 @@ export default function EntityRecordItem( { record, checked, onChange } ) { key ); - const { - default_template_part_areas: templateAreas = [], - default_template_types: templateTypes = [], - } = + const { default_template_types: templateTypes = [] } = select( coreStore ).getEntityRecord( 'root', '__unstableBase' @@ -47,7 +44,6 @@ export default function EntityRecordItem( { record, checked, onChange } ) { return { entityRecordTitle: getTemplateInfo( { template, - templateAreas, templateTypes, } ).title, hasPostMetaChanges: unlock( diff --git a/packages/editor/src/components/post-card-panel/index.js b/packages/editor/src/components/post-card-panel/index.js index e7b6b9b325044b..8fcca6c6bd6d40 100644 --- a/packages/editor/src/components/post-card-panel/index.js +++ b/packages/editor/src/components/post-card-panel/index.js @@ -38,10 +38,7 @@ export default function PostCardPanel( { postId ); - const { - default_template_part_areas: templateAreas = [], - default_template_types: templateTypes = [], - } = + const { default_template_types: templateTypes = [] } = select( coreStore ).getEntityRecord( 'root', '__unstableBase' @@ -53,7 +50,6 @@ export default function PostCardPanel( { ].includes( postType ) ? getTemplateInfo( { template: _record, - templateAreas, templateTypes, } ) : {}; diff --git a/packages/editor/src/utils/get-template-info.js b/packages/editor/src/utils/get-template-info.js index a6bc4c2d8dc461..bc84c06c9399d4 100644 --- a/packages/editor/src/utils/get-template-info.js +++ b/packages/editor/src/utils/get-template-info.js @@ -12,7 +12,7 @@ const EMPTY_OBJECT = {}; * Helper function to retrieve the corresponding template info for a given template. * @param {Object} params * @param {Array} params.templateTypes - * @param {Array} params.templateAreas + * @param {Array} [params.templateAreas] * @param {Object} params.template */ export const getTemplateInfo = ( params ) => { @@ -32,13 +32,13 @@ export const getTemplateInfo = ( params ) => { const templateDescription = typeof description === 'string' ? description : description?.raw; - const templateAreasWithIcon = templateAreas.map( ( item ) => ( { + const templateAreasWithIcon = templateAreas?.map( ( item ) => ( { ...item, icon: getTemplatePartIcon( item.icon ), } ) ); const templateIcon = - templateAreasWithIcon.find( ( item ) => area === item.area )?.icon || + templateAreasWithIcon?.find( ( item ) => area === item.area )?.icon || layout; return {