Skip to content

Commit

Permalink
Add per_page=-1 to templates entity API (#36761)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 authored Nov 23, 2021
1 parent 98a8d9e commit 88883a3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/full-site-editing/edit-site-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion packages/edit-site/src/components/list/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
};
Expand Down
7 changes: 3 additions & 4 deletions packages/edit-site/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 88883a3

Please sign in to comment.