Skip to content

Commit

Permalink
feat: bump max number of items per list from 20 to 50 (#97)
Browse files Browse the repository at this point in the history
* feat: bump max number of items per list from 20 to 50

* fix(curated-list-block): maxItems param handling

* chore: remove unneeded maxItems check

Co-authored-by: Adam Borowski <adam@adamboro.com>
  • Loading branch information
dkoo and adekbadek authored Jul 19, 2021
1 parent cab16aa commit 009deab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
37 changes: 15 additions & 22 deletions src/blocks/curated-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const CuratedListEditorComponent = ( {
setError( null );
const posts = await apiFetch( {
path: addQueryArgs( '/newspack-listings/v1/listings', {
query: { ...query, maxItems: MAX_EDITOR_ITEMS }, // Get up to MAX_EDITOR_ITEMS listings in the editor so we can show all locations.
query: { maxItems: MAX_EDITOR_ITEMS, ...query }, // Get up to MAX_EDITOR_ITEMS listings in the editor so we can show all locations.
_fields: 'id,title,author,category,tags,excerpt,media,meta,type,sponsors',
} ),
} );
Expand Down Expand Up @@ -307,27 +307,20 @@ const CuratedListEditorComponent = ( {
* @param {Object} listing Post object for listing to show.
* @param {number} index Index of the item in the array.
*/
const renderQueriedListings = ( listing, index ) => {
// Only display up to the maxItems setting.
if ( index >= queryOptions.maxItems ) {
return null;
}

return (
<div key={ index } className="newspack-listings__listing-editor newspack-listings__listing">
<Listing attributes={ attributes } error={ error } post={ listing } />
{
<Button
isLink
href={ `/wp-admin/post.php?post=${ listing.id }&action=edit` }
target="_blank"
>
{ __( 'Edit this listing', 'newspack-listing' ) }
</Button>
}
</div>
);
};
const renderQueriedListings = ( listing, index ) => (
<div key={ index } className="newspack-listings__listing-editor newspack-listings__listing">
<Listing attributes={ attributes } error={ error } post={ listing } />
{
<Button
isLink
href={ `/wp-admin/post.php?post=${ listing.id }&action=edit` }
target="_blank"
>
{ __( 'Edit this listing', 'newspack-listing' ) }
</Button>
}
</div>
);

/**
* Validate location data.
Expand Down
2 changes: 1 addition & 1 deletion src/components/sidebar-query-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class QueryControls extends Component {
setAttributes( { queryOptions: { ...queryOptions, maxItems: value } } )
}
min={ 1 }
max={ 20 }
max={ 50 }
required
/>,
<ToggleControl
Expand Down

0 comments on commit 009deab

Please sign in to comment.