Skip to content

Commit

Permalink
Page List Block: fix empty settings panel (#68756)
Browse files Browse the repository at this point in the history
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
  • Loading branch information
3 people authored Jan 18, 2025
1 parent cb0c989 commit 63523f2
Showing 1 changed file with 52 additions and 50 deletions.
102 changes: 52 additions & 50 deletions packages/block-library/src/page-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,58 +322,60 @@ export default function PageListEdit( {

return (
<>
<InspectorControls>
<ToolsPanel
label={ __( 'Settings' ) }
resetAll={ () => {
setAttributes( { parentPageID: 0 } );
} }
dropdownMenuProps={ dropdownMenuProps }
>
{ pagesTree.length > 0 && (
<ToolsPanelItem
label={ __( 'Parent Page' ) }
hasValue={ () => parentPageID !== 0 }
onDeselect={ () =>
setAttributes( { parentPageID: 0 } )
}
isShownByDefault
>
<ComboboxControl
__nextHasNoMarginBottom
__next40pxDefaultSize
className="editor-page-attributes__parent"
label={ __( 'Parent' ) }
value={ parentPageID }
options={ pagesTree }
onChange={ ( value ) =>
setAttributes( {
parentPageID: value ?? 0,
} )
{ ( pagesTree.length > 0 || allowConvertToLinks ) && (
<InspectorControls>
<ToolsPanel
label={ __( 'Settings' ) }
resetAll={ () => {
setAttributes( { parentPageID: 0 } );
} }
dropdownMenuProps={ dropdownMenuProps }
>
{ pagesTree.length > 0 && (
<ToolsPanelItem
label={ __( 'Parent Page' ) }
hasValue={ () => parentPageID !== 0 }
onDeselect={ () =>
setAttributes( { parentPageID: 0 } )
}
help={ __(
'Choose a page to show only its subpages.'
) }
/>
</ToolsPanelItem>
) }

{ allowConvertToLinks && (
<div style={ { gridColumn: '1 / -1' } }>
<p>{ convertDescription }</p>
<Button
__next40pxDefaultSize
variant="primary"
accessibleWhenDisabled
disabled={ ! hasResolvedPages }
onClick={ convertToNavigationLinks }
isShownByDefault
>
{ __( 'Edit' ) }
</Button>
</div>
) }
</ToolsPanel>
</InspectorControls>
<ComboboxControl
__nextHasNoMarginBottom
__next40pxDefaultSize
className="editor-page-attributes__parent"
label={ __( 'Parent' ) }
value={ parentPageID }
options={ pagesTree }
onChange={ ( value ) =>
setAttributes( {
parentPageID: value ?? 0,
} )
}
help={ __(
'Choose a page to show only its subpages.'
) }
/>
</ToolsPanelItem>
) }

{ allowConvertToLinks && (
<div style={ { gridColumn: '1 / -1' } }>
<p>{ convertDescription }</p>
<Button
__next40pxDefaultSize
variant="primary"
accessibleWhenDisabled
disabled={ ! hasResolvedPages }
onClick={ convertToNavigationLinks }
>
{ __( 'Edit' ) }
</Button>
</div>
) }
</ToolsPanel>
</InspectorControls>
) }
{ allowConvertToLinks && (
<>
<BlockControls group="other">
Expand Down

0 comments on commit 63523f2

Please sign in to comment.