diff --git a/packages/block-editor/src/components/inserter/menu.js b/packages/block-editor/src/components/inserter/menu.js index 0d555633d91a96..bb9fcfe48be50f 100644 --- a/packages/block-editor/src/components/inserter/menu.js +++ b/packages/block-editor/src/components/inserter/menu.js @@ -7,6 +7,7 @@ import { findIndex, flow, groupBy, + size, isEmpty, map, some, @@ -27,6 +28,7 @@ import { PanelBody, withSpokenMessages, Tip, + Button, } from '@wordpress/components'; import { getCategories, @@ -253,7 +255,7 @@ export class InserterMenu extends Component { } render() { - const { instanceId, onSelect, rootClientId, showInserterHelpPanel } = this.props; + const { instanceId, onSelect, rootClientId, showInserterHelpPanel, numberOfHiddenBlocks, openModal } = this.props; const { childItems, hoveredItem, @@ -356,7 +358,32 @@ export class InserterMenu extends Component { ) } { isEmpty( suggestedItems ) && isEmpty( reusableItems ) && isEmpty( itemsPerCategory ) && ( -

{ __( 'No blocks found.' ) }

+

+ { numberOfHiddenBlocks > 0 ? __( 'No active blocks found.' ) : __( 'No blocks found.' ) } + { numberOfHiddenBlocks > 0 && ( + <> +
+ { + sprintf( + _n( + '%1$d block is disabled.', + '%1$d blocks are disabled.', + numberOfHiddenBlocks + ), + numberOfHiddenBlocks + ) + } +
+ + + ) } +

) } @@ -429,6 +456,9 @@ export default compose( const { getChildBlockNames, } = select( 'core/blocks' ); + const { + getPreference, + } = select( 'core/edit-post' ); let destinationRootClientId = rootClientId; if ( ! destinationRootClientId && ! clientId && ! isAppender ) { @@ -438,12 +468,15 @@ export default compose( } } const destinationRootBlockName = getBlockName( destinationRootClientId ); + const hiddenBlockTypes = getPreference( 'hiddenBlockTypes' ); + const numberOfHiddenBlocks = size( hiddenBlockTypes ); return { rootChildBlocks: getChildBlockNames( destinationRootBlockName ), items: getInserterItems( destinationRootClientId ), showInserterHelpPanel: getSettings().showInserterHelpPanel, destinationRootClientId, + numberOfHiddenBlocks, }; } ), withDispatch( ( dispatch, ownProps, { select } ) => { @@ -457,6 +490,10 @@ export default compose( __experimentalFetchReusableBlocks: fetchReusableBlocks, } = dispatch( 'core/editor' ); + const { + openModal, + } = dispatch( 'core/edit-post' ); + // To avoid duplication, getInsertionIndex is extracted and used in two event handlers // This breaks the withDispatch not containing any logic rule. // Since it's a function only called when the event handlers are called, @@ -516,6 +553,7 @@ export default compose( ownProps.onSelect(); }, + openModal, }; } ), withSpokenMessages, diff --git a/packages/block-editor/src/components/inserter/style.scss b/packages/block-editor/src/components/inserter/style.scss index b8834e5233ac12..c75fb7c942adb2 100644 --- a/packages/block-editor/src/components/inserter/style.scss +++ b/packages/block-editor/src/components/inserter/style.scss @@ -123,9 +123,13 @@ $block-inserter-search-height: 38px; } .block-editor-inserter__no-results { - font-style: italic; padding: 24px; text-align: center; + line-height: 1.75; +} + +.block-editor-inserter__block-manager-button { + margin-top: 24px; } .block-editor-inserter__child-blocks {