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

Make usage of the settings icon more consistent #63020

Merged
merged 7 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
65 changes: 65 additions & 0 deletions packages/block-library/src/query/edit/inspector-controls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Notice,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
__experimentalNumberControl as NumberControl,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
Expand Down Expand Up @@ -190,6 +191,70 @@ export default function QueryInspectorControls( props ) {
) }
</>
) }
{ ! inherit && (
<>
<NumberControl
__unstableInputWidth="60px"
label={ __( 'Items per Page' ) }
labelPosition="edge"
min={ 1 }
max={ 100 }
onChange={ ( value ) => {
if (
isNaN( value ) ||
value < 1 ||
value > 100
) {
return;
}
setQuery( {
perPage: value,
} );
} }
step="1"
value={ query.perPage }
isDragEnabled={ false }
/>
<NumberControl
__unstableInputWidth="60px"
label={ __( 'Offset' ) }
labelPosition="edge"
min={ 0 }
max={ 100 }
onChange={ ( value ) => {
if (
isNaN( value ) ||
value < 0 ||
value > 100
) {
return;
}
setQuery( { offset: value } );
} }
step="1"
value={ query.offset }
isDragEnabled={ false }
/>
<NumberControl
__unstableInputWidth="60px"
label={ __( 'Max pages to show' ) }
labelPosition="edge"
min={ 0 }
onChange={ ( value ) => {
if ( isNaN( value ) || value < 0 ) {
return;
}
setQuery( { pages: value } );
} }
step="1"
value={ query.pages }
isDragEnabled={ false }
help={ __(
'Limit the pages you want to show, even if the query has more results. To show all pages use 0 (zero).'
) }
/>
</>
) }
{ showOrderControl && (
<OrderControl
{ ...{ order, orderBy } }
Expand Down
103 changes: 1 addition & 102 deletions packages/block-library/src/query/edit/query-toolbar.js
Original file line number Diff line number Diff line change
@@ -1,124 +1,23 @@
/**
* WordPress dependencies
*/
import {
ToolbarGroup,
Dropdown,
ToolbarButton,
BaseControl,
__experimentalNumberControl as NumberControl,
} from '@wordpress/components';
import { useInstanceId } from '@wordpress/compose';
import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { settings } from '@wordpress/icons';

/**
* Internal dependencies
*/
import { usePatterns } from '../utils';

export default function QueryToolbar( {
attributes: { query },
setQuery,
openPatternSelectionModal,
name,
clientId,
} ) {
const hasPatterns = !! usePatterns( clientId, name ).length;
const maxPageInputId = useInstanceId(
QueryToolbar,
'blocks-query-pagination-max-page-input'
);

return (
<>
{ ! query.inherit && (
<ToolbarGroup>
<Dropdown
contentClassName="block-library-query-toolbar__popover"
renderToggle={ ( { onToggle } ) => (
<ToolbarButton
icon={ settings }
label={ __( 'Display settings' ) }
onClick={ onToggle }
/>
) }
renderContent={ () => (
<>
<BaseControl>
<NumberControl
__unstableInputWidth="60px"
label={ __( 'Items per Page' ) }
labelPosition="edge"
min={ 1 }
max={ 100 }
onChange={ ( value ) => {
if (
isNaN( value ) ||
value < 1 ||
value > 100
) {
return;
}
setQuery( {
perPage: value,
} );
} }
step="1"
value={ query.perPage }
isDragEnabled={ false }
/>
</BaseControl>
<BaseControl>
<NumberControl
__unstableInputWidth="60px"
label={ __( 'Offset' ) }
labelPosition="edge"
min={ 0 }
max={ 100 }
onChange={ ( value ) => {
if (
isNaN( value ) ||
value < 0 ||
value > 100
) {
return;
}
setQuery( { offset: value } );
} }
step="1"
value={ query.offset }
isDragEnabled={ false }
/>
</BaseControl>
<BaseControl
id={ maxPageInputId }
help={ __(
'Limit the pages you want to show, even if the query has more results. To show all pages use 0 (zero).'
) }
>
<NumberControl
id={ maxPageInputId }
__unstableInputWidth="60px"
label={ __( 'Max page to show' ) }
labelPosition="edge"
min={ 0 }
onChange={ ( value ) => {
if ( isNaN( value ) || value < 0 ) {
return;
}
setQuery( { pages: value } );
} }
step="1"
value={ query.pages }
isDragEnabled={ false }
/>
</BaseControl>
</>
) }
/>
</ToolbarGroup>
) }
{ hasPatterns && (
<ToolbarGroup className="wp-block-template-part__block-control-group">
<ToolbarButton onClick={ openPatternSelectionModal }>
Expand Down
4 changes: 2 additions & 2 deletions packages/dataviews/src/view-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { memo } from '@wordpress/element';
import { settings } from '@wordpress/icons';
import { cog } from '@wordpress/icons';

/**
* Internal dependencies
Expand Down Expand Up @@ -314,7 +314,7 @@ function _ViewActions< Item >( {
trigger={
<Button
size="compact"
icon={ settings }
icon={ cog }
label={ __( 'View options' ) }
/>
}
Expand Down
32 changes: 0 additions & 32 deletions test/e2e/specs/editor/various/is-typing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,4 @@ test.describe( 'isTyping', () => {
// Toolbar Popover is hidden again
await expect( blockToolbarPopover ).toBeHidden();
} );

test( 'should not close the dropdown when typing in it', async ( {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ellatrix do you think we should update this test to something like typing in the link dialog or something instead of removing it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should be kept for sure now, that you have reverted the Query Loop changes..

editor,
page,
} ) => {
// Add a block with a dropdown in the toolbar that contains an input.
await editor.insertBlock( { name: 'core/query' } );

await editor.canvas
.getByRole( 'document', { name: 'Block: Query Loop' } )
.getByRole( 'button', { name: 'Start blank' } )
.click();

await editor.canvas
.getByRole( 'button', { name: 'Title & Date' } )
.click();

// Moving the mouse shows the toolbar.
await editor.showBlockToolbar();
// Open the dropdown.
const displaySettings = page.getByRole( 'button', {
name: 'Display settings',
} );
await displaySettings.click();
const itemsPerPageInput = page.getByLabel( 'Items per Page' );
// Make sure we're where we think we are
await expect( itemsPerPageInput ).toBeFocused();
// Type inside the dropdown's input
await page.keyboard.type( '00' );
// The input should still be visible.
await expect( itemsPerPageInput ).toBeVisible();
} );
} );
Loading