-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Move Posts Per Page, Offset, and Pages controls from the block toolbar into Inspector Controls #58207
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
Merged
ryanwelcher
merged 16 commits into
trunk
from
feature/add-post-count-controls-to-query-loop-block
Aug 6, 2024
Merged
Move Posts Per Page, Offset, and Pages controls from the block toolbar into Inspector Controls #58207
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b9daa7b
Add Per Page Controls to the Query Loop block.
ryanwelcher b75431f
Update changelog.
ryanwelcher 9395aca
Update the max posts per page to match the toolbar control.
ryanwelcher 728d3ed
Wrap per page, offset, and max pages controls to Inspector controls i…
ryanwelcher 5b36598
Remove per page, offset and pages controls from block toolbar.
ryanwelcher 402acb3
Rename ToolsPanel to "Display"
ryanwelcher b1eaf83
Fix leftover for incorrect dropdownMenuProps value.
afercia 44c61da
Convert RangeControl value to number.
afercia fe9857e
Merge branch 'trunk' into feature/add-post-count-controls-to-query-lo…
ryanwelcher d6b5f8a
Add missing value checks for perPage, offset, and max pages controls.
ryanwelcher f5b43e2
Update e2e test
Mamaduka 02c4579
Fix PHPCS
Mamaduka 1dd54df
large and minor label tweak
af64535
"posts per page"
7b6e79c
Merge branch 'trunk' into feature/add-post-count-controls-to-query-lo…
ryanwelcher 49ff394
Add __nextHasNoMarginBottom to the Per Page RangeControl component.
ryanwelcher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Wrap per page, offset, and max pages controls to Inspector controls i…
…nside a ToolsPanel and move them to the Inspector Controls for the block.
- Loading branch information
commit 728d3ed28b9b1881f3758ec822979c5f49905db7
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/block-library/src/query/edit/inspector-controls/offset-controls.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { __experimentalNumberControl as NumberControl } from '@wordpress/components'; | ||
| import { __ } from '@wordpress/i18n'; | ||
|
|
||
| export const OffsetControl = ( { offset = 0, onChange } ) => { | ||
| return ( | ||
| <NumberControl | ||
| label={ __( 'Offset' ) } | ||
| value={ offset } | ||
| min={ 0 } | ||
| onChange={ ( newOffset ) => { | ||
| onChange( { offset: newOffset } ); | ||
| } } | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export default OffsetControl; |
23 changes: 23 additions & 0 deletions
23
packages/block-library/src/query/edit/inspector-controls/pages-control.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { __experimentalNumberControl as NumberControl } from '@wordpress/components'; | ||
| import { __ } from '@wordpress/i18n'; | ||
|
|
||
| export const PagesControl = ( { pages, onChange } ) => { | ||
| return ( | ||
| <NumberControl | ||
| label={ __( 'Max Pages to Show' ) } | ||
| value={ pages } | ||
| min={ 0 } | ||
| onChange={ ( newPages ) => { | ||
| onChange( { pages: newPages } ); | ||
| } } | ||
| help={ __( | ||
| 'Limit the pages you want to show, even if the query has more results. To show all pages use 0 (zero).' | ||
| ) } | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export default PagesControl; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (non-blocking): There is probably no need to create wrappers for simple components like -
PerPageControl,OffsetControlandPagesControl.This is mostly my personal preference. Feel free to ignore it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with wrappers to reduce the size of the
index.jsfor this section. I guess its number of files vs lines of code. I'm happy either way, but if these components get more complicated, it would be nice to abstract that out of the main file.