From 88883a3ea23f5b3d8aff563f6a8447e4133b9e55 Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Tue, 23 Nov 2021 16:36:16 +0800 Subject: [PATCH] Add per_page=-1 to templates entity API (#36761) --- lib/full-site-editing/edit-site-page.php | 2 +- .../src/components/add-new-template/new-template.js | 3 ++- packages/edit-site/src/components/list/table.js | 5 ++++- packages/edit-site/src/store/selectors.js | 7 +++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/full-site-editing/edit-site-page.php b/lib/full-site-editing/edit-site-page.php index a6da5c9f6ed3e..c1a363667bed7 100644 --- a/lib/full-site-editing/edit-site-page.php +++ b/lib/full-site-editing/edit-site-page.php @@ -97,7 +97,7 @@ function gutenberg_edit_site_list_init( $settings ) { '/', "/wp/v2/types/$post_type->name?context=edit", '/wp/v2/types?context=edit', - "/wp/v2/$post_type->rest_base?context=edit", + "/wp/v2/$post_type->rest_base?context=edit&per_page=-1", ), 'rest_preload_api_request', array() diff --git a/packages/edit-site/src/components/add-new-template/new-template.js b/packages/edit-site/src/components/add-new-template/new-template.js index d678ae3fed986..f311b656ef65f 100644 --- a/packages/edit-site/src/components/add-new-template/new-template.js +++ b/packages/edit-site/src/components/add-new-template/new-template.js @@ -33,7 +33,8 @@ export default function NewTemplate( { postType } ) { ( select ) => ( { templates: select( coreStore ).getEntityRecords( 'postType', - 'wp_template' + 'wp_template', + { per_page: -1 } ), defaultTemplateTypes: select( editorStore diff --git a/packages/edit-site/src/components/list/table.js b/packages/edit-site/src/components/list/table.js index db543f809a8e1..d9f6832366b54 100644 --- a/packages/edit-site/src/components/list/table.js +++ b/packages/edit-site/src/components/list/table.js @@ -46,10 +46,13 @@ export default function Table( { templateType } ) { } = select( coreStore ); return { - templates: getEntityRecords( 'postType', templateType ), + templates: getEntityRecords( 'postType', templateType, { + per_page: -1, + } ), isLoading: ! hasFinishedResolution( 'getEntityRecords', [ 'postType', templateType, + { per_page: -1 }, ] ), postType: getPostType( templateType ), }; diff --git a/packages/edit-site/src/store/selectors.js b/packages/edit-site/src/store/selectors.js index a6f46f455b05f..c93f4a2f945f5 100644 --- a/packages/edit-site/src/store/selectors.js +++ b/packages/edit-site/src/store/selectors.js @@ -309,10 +309,9 @@ export const getCurrentTemplateTemplateParts = createRegistrySelector( templateId ); - const templateParts = select( coreDataStore ).getEntityRecords( - 'postType', - 'wp_template_part' - ); + const templateParts = select( + coreDataStore + ).getEntityRecords( 'postType', 'wp_template_part', { per_page: -1 } ); const templatePartsById = keyBy( templateParts, ( templatePart ) => templatePart.id