Skip to content

Commit

Permalink
[Block Editor - Inserter]: preload media categories empty check - cli…
Browse files Browse the repository at this point in the history
…ent side (#47503)

* [Block Editor - Inserter]: preload media categories empty client side

* show media tab if `enableOpenverseMediaCategory` setting is `true`
  • Loading branch information
ntsekouras committed Feb 21, 2023
1 parent 8548085 commit 0cbd7ce
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 38 deletions.
23 changes: 0 additions & 23 deletions lib/compat/wordpress-6.2/edit-form-blocks.php

This file was deleted.

1 change: 0 additions & 1 deletion lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/compat/wordpress-6.2/block-template-utils.php';
require __DIR__ . '/compat/wordpress-6.2/get-global-styles-and-settings.php';
require __DIR__ . '/compat/wordpress-6.2/default-filters.php';
require __DIR__ . '/compat/wordpress-6.2/edit-form-blocks.php';
require __DIR__ . '/compat/wordpress-6.2/site-editor.php';
require __DIR__ . '/compat/wordpress-6.2/block-editor.php';
require __DIR__ . '/compat/wordpress-6.2/block-editor-settings.php';
Expand Down
34 changes: 20 additions & 14 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,33 @@ function InserterMenu(
insertionIndex: __experimentalInsertionIndex,
shouldFocusBlock,
} );
const { showPatterns, inserterItems } = useSelect(
( select ) => {
const { __experimentalGetAllowedPatterns, getInserterItems } =
select( blockEditorStore );
return {
showPatterns: !! __experimentalGetAllowedPatterns(
destinationRootClientId
).length,
inserterItems: getInserterItems( destinationRootClientId ),
};
},
[ destinationRootClientId ]
);
const { showPatterns, inserterItems, enableOpenverseMediaCategory } =
useSelect(
( select ) => {
const {
__experimentalGetAllowedPatterns,
getInserterItems,
getSettings,
} = select( blockEditorStore );
return {
showPatterns: !! __experimentalGetAllowedPatterns(
destinationRootClientId
).length,
inserterItems: getInserterItems( destinationRootClientId ),
enableOpenverseMediaCategory:
getSettings().enableOpenverseMediaCategory,
};
},
[ destinationRootClientId ]
);
const hasReusableBlocks = useMemo( () => {
return inserterItems.some(
( { category } ) => category === 'reusable'
);
}, [ inserterItems ] );

const mediaCategories = useMediaCategories( destinationRootClientId );
const showMedia = !! mediaCategories.length;
const showMedia = !! mediaCategories.length || enableOpenverseMediaCategory;

const onInsert = useCallback(
( blocks, meta, shouldForceFocusBlock ) => {
Expand Down

1 comment on commit 0cbd7ce

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 0cbd7ce.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4231588531
📝 Reported issues:

Please sign in to comment.