Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Aug 29, 2024
1 parent f968cd5 commit 09b5a08
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions packages/block-editor/src/components/block-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '@wordpress/blocks';
import { PanelBody, __unstableMotion as motion } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { useMemo } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -34,37 +35,36 @@ import { unlock } from '../../lock-unlock';

function BlockStylesPanel( { clientId } ) {
return (
<div>
<PanelBody title={ __( 'Styles' ) }>
<BlockStyles clientId={ clientId } />
</PanelBody>
</div>
<PanelBody title={ __( 'Styles' ) }>
<BlockStyles clientId={ clientId } />
</PanelBody>
);
}

function BlockInspectorLockedBlocks( { topLevelLockedBlock } ) {
const { getBlockName, getBlockEditingMode } = useSelect( blockEditorStore );
const { contentClientIds, hasBlockStyles } = useSelect(
( select ) => {
const {
getClientIdsOfDescendants,
getBlockName,
getBlockEditingMode,
} = select( blockEditorStore );
const { getClientIdsOfDescendants } = select( blockEditorStore );
const { getBlockStyles } = select( blocksStore );
return {
contentClientIds: getClientIdsOfDescendants(
topLevelLockedBlock
).filter(
( clientId ) =>
getBlockName( clientId ) !== 'core/list-item' &&
getBlockEditingMode( clientId ) === 'contentOnly'
),
contentClientIds:
getClientIdsOfDescendants( topLevelLockedBlock ),
hasBlockStyles: !! getBlockStyles(
getBlockName( topLevelLockedBlock )
)?.length,
};
},
[ topLevelLockedBlock ]
[ topLevelLockedBlock, getBlockName ]
);
const eligibleContentClientIds = useMemo(
() =>
contentClientIds.filter(
( clientId ) =>
getBlockName( clientId ) !== 'core/list-item' &&
getBlockEditingMode( clientId ) === 'contentOnly'
),
[ contentClientIds, getBlockName, getBlockEditingMode ]
);
const blockInformation = useBlockDisplayInformation( topLevelLockedBlock );
return (
Expand All @@ -78,9 +78,11 @@ function BlockInspectorLockedBlocks( { topLevelLockedBlock } ) {
{ hasBlockStyles && (
<BlockStylesPanel clientId={ topLevelLockedBlock } />
) }
{ contentClientIds.length > 0 && (
{ eligibleContentClientIds.length > 0 && (
<PanelBody title={ __( 'Content' ) }>
<BlockQuickNavigation clientIds={ contentClientIds } />
<BlockQuickNavigation
clientIds={ eligibleContentClientIds }
/>
</PanelBody>
) }
</div>
Expand Down

0 comments on commit 09b5a08

Please sign in to comment.