Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed May 21, 2024
1 parent 86eee37 commit a3f8b54
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 107 deletions.
35 changes: 3 additions & 32 deletions packages/patterns/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,9 @@ export function isOverridableBlock( block ) {
*/
export function hasOverridableBlocks( blocks ) {
return blocks.some( ( block ) => {
if ( isOverridableBlock( block ) ) return true;
if ( isOverridableBlock( block ) ) {
return true;
}
return hasOverridableBlocks( block.innerBlocks );
} );
}

/**
* Get the overridable attributes for the give block.
*
* @param {WPBlock} block The block to test.
*
* @return {string[]} The attribute names in an array.
*/
export function getOverridableAttributes( block ) {
const set = new Set();
// get default attributes for the block.
if ( block.attributes.metadata.bindings.__default ) {
PARTIAL_SYNCING_SUPPORTED_BLOCKS[ block.name ].forEach(
( attribute ) => {
set.add( attribute );
}
);
}
// Any additional attributes and overrides.
for ( const [ attributeKey, binding ] of Object.entries(
block.attributes.metadata.bindings
) ) {
if ( attributeKey === '__default' ) continue;
if ( binding.source === 'core/pattern-overrides' ) {
set.add( attributeKey );
} else {
set.delete( attributeKey );
}
}
return Array.from( set );
}
69 changes: 0 additions & 69 deletions packages/patterns/src/api/test/index.js

This file was deleted.

7 changes: 1 addition & 6 deletions packages/patterns/src/private-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import {
default as DuplicatePatternModal,
useDuplicatePatternProps,
} from './components/duplicate-pattern-modal';
import {
isOverridableBlock,
hasOverridableBlocks,
getOverridableAttributes,
} from './api';
import { isOverridableBlock, hasOverridableBlocks } from './api';
import RenamePatternModal from './components/rename-pattern-modal';
import PatternsMenuItems from './components';
import RenamePatternCategoryModal from './components/rename-pattern-category-modal';
Expand All @@ -39,7 +35,6 @@ lock( privateApis, {
DuplicatePatternModal,
isOverridableBlock,
hasOverridableBlocks,
getOverridableAttributes,
useDuplicatePatternProps,
RenamePatternModal,
PatternsMenuItems,
Expand Down

0 comments on commit a3f8b54

Please sign in to comment.