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

feat: bump max number of items per list from 20 to 50 #97

Merged
merged 3 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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