Skip to content

Commit

Permalink
Hide query block toolbar settings if query is inherited (#28290)
Browse files Browse the repository at this point in the history
* Hide block toolbar settings if query is inherited

* cs
  • Loading branch information
aristath authored Jan 19, 2021
1 parent 56dd57d commit 8fe2ec8
Showing 1 changed file with 61 additions and 57 deletions.
118 changes: 61 additions & 57 deletions packages/block-library/src/query/edit/query-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,63 +34,67 @@ export default function QueryToolbar( {
];
return (
<>
<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 ) =>
setQuery( { perPage: +value ?? -1 } )
}
step="1"
value={ query.perPage }
isDragEnabled={ false }
/>
</BaseControl>
<BaseControl>
<NumberControl
__unstableInputWidth="60px"
label={ __( 'Offset' ) }
labelPosition="edge"
min={ 0 }
max={ 100 }
onChange={ ( value ) =>
setQuery( { offset: +value } )
}
step="1"
value={ query.offset }
isDragEnabled={ false }
/>
</BaseControl>
<BaseControl>
<RangeControl
label={ __( 'Number of Pages' ) }
min={ 1 }
allowReset
value={ query.pages }
onChange={ ( value ) =>
setQuery( { pages: value ?? -1 } )
}
/>
</BaseControl>
</>
) }
/>
</ToolbarGroup>
{ ! 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 ) =>
setQuery( {
perPage: +value ?? -1,
} )
}
step="1"
value={ query.perPage }
isDragEnabled={ false }
/>
</BaseControl>
<BaseControl>
<NumberControl
__unstableInputWidth="60px"
label={ __( 'Offset' ) }
labelPosition="edge"
min={ 0 }
max={ 100 }
onChange={ ( value ) =>
setQuery( { offset: +value } )
}
step="1"
value={ query.offset }
isDragEnabled={ false }
/>
</BaseControl>
<BaseControl>
<RangeControl
label={ __( 'Number of Pages' ) }
min={ 1 }
allowReset
value={ query.pages }
onChange={ ( value ) =>
setQuery( { pages: value ?? -1 } )
}
/>
</BaseControl>
</>
) }
/>
</ToolbarGroup>
) }
<ToolbarGroup controls={ layoutControls } />
</>
);
Expand Down

0 comments on commit 8fe2ec8

Please sign in to comment.