diff --git a/packages/block-library/src/query/edit/index.js b/packages/block-library/src/query/edit/index.js index 3cb7996aa2690..bc9175db6cafd 100644 --- a/packages/block-library/src/query/edit/index.js +++ b/packages/block-library/src/query/edit/index.js @@ -104,6 +104,7 @@ export function QueryContent( { return ( <> - - setQuery( { inherit: !! value } ) } - /> - { ! inherit && ( - + + + + setQuery( { inherit: !! value } ) + } /> - ) } - { displayLayout?.type === 'flex' && ( - <> - - setDisplayLayout( { columns: value } ) - } - min={ 2 } - max={ Math.max( 6, displayLayout.columns ) } + { ! inherit && ( + - { displayLayout.columns > 6 && ( - - { __( - 'This column count exceeds the recommended amount and may cause visual breakage.' - ) } - - ) } - - ) } - { ! inherit && ( - - ) } - { ! inherit && showSticky && ( - setQuery( { sticky: value } ) } - /> - ) } - - { ! inherit && ( - - - - - { isPostTypeHierarchical && ( - + + setDisplayLayout( { columns: value } ) + } + min={ 2 } + max={ Math.max( 6, displayLayout.columns ) } + /> + { displayLayout.columns > 6 && ( + + { __( + 'This column count exceeds the recommended amount and may cause visual breakage.' + ) } + + ) } + + ) } + { ! inherit && ( + ) } + { ! inherit && showSticky && ( + + setQuery( { sticky: value } ) + } + /> + ) } + + { ! inherit && ( + + { + setQuery( { + author: '', + parents: [], + search: '', + taxQuery: null, + } ); + } } + // key={ panelId } // TODO: do I need this? + panelId={ clientId } + > + { /* // TODO: probably have a hook for available taxonomies and add conditionally */ } + true } + onDeselect={ () => setQuery( { taxQuery: null } ) } + panelId={ clientId } + isShownByDefault + > + + + !! authorIds } + label={ __( 'Authors' ) } + onDeselect={ () => setQuery( { author: '' } ) } + panelId={ clientId } + > + + + !! querySearch } + label={ __( 'Keyword' ) } + onDeselect={ () => setQuerySearch( '' ) } + panelId={ clientId } + > + + + { isPostTypeHierarchical && ( + !! parents?.length } + label={ __( 'Parents' ) } + onDeselect={ () => setQuery( { parents: [] } ) } + panelId={ clientId } + > + + + ) } + + ) } - + ); } diff --git a/packages/block-library/src/query/variations.js b/packages/block-library/src/query/variations.js index fb15645760f29..7ae775754ed16 100644 --- a/packages/block-library/src/query/variations.js +++ b/packages/block-library/src/query/variations.js @@ -2,7 +2,7 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { postList } from '@wordpress/icons'; +import { postList, preformatted } from '@wordpress/icons'; /** * Internal dependencies @@ -31,6 +31,42 @@ const QUERY_DEFAULT_ATTRIBUTES = { }; const variations = [ + { + // This variation is just for testing purposes and will not be merged.. + name: 'products-list', + title: __( 'Products List' ), + description: __( 'Display a list of your products.' ), + icon: preformatted, + attributes: { + query: { + perPage: null, + pages: 0, + offset: 0, + postType: 'product', + order: 'desc', + orderBy: 'date', + author: '', + search: '', + exclude: [], + sticky: '', + inherit: false, + taxQuery: null, + parents: [], + }, + }, + innerBlocks: [ + [ + 'core/post-template', + {}, + [ [ 'core/post-title' ], [ 'core/post-date' ] ], + ], + [ 'core/query-pagination' ], + [ 'core/query-no-results' ], + ], + isActive: ( blockAttributes ) => + blockAttributes?.query?.postType === 'product', + scope: [ 'inserter' ], + }, { name: 'posts-list', title: __( 'Posts List' ),