Skip to content

Commit

Permalink
Only core variations should be editable
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Dec 20, 2022
1 parent 3002e42 commit 97b9d3f
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { useSelect } from '@wordpress/data';
import { NavigationButtonAsItem } from './navigation-button';
import ContextMenu from './context-menu';

function getCoreBlockStyles( blockStyles ) {
return blockStyles?.filter( ( style ) => style.source === 'block' );
}

export function useHasVariationsPanel( name, parentMenu = '' ) {
const isInsideVariationsPanel = parentMenu.includes( 'variations' );
const blockStyles = useSelect(
Expand All @@ -20,7 +24,8 @@ export function useHasVariationsPanel( name, parentMenu = '' ) {
},
[ name ]
);
return !! blockStyles?.length && ! isInsideVariationsPanel;
const coreBlockStyles = getCoreBlockStyles( blockStyles );
return !! coreBlockStyles?.length && ! isInsideVariationsPanel;
}

export function VariationsPanel( { name } ) {
Expand All @@ -31,10 +36,11 @@ export function VariationsPanel( { name } ) {
},
[ name ]
);
const coreBlockStyles = getCoreBlockStyles( blockStyles );

return (
<>
{ blockStyles.map( ( style, index ) => (
{ coreBlockStyles.map( ( style, index ) => (
<NavigationButtonAsItem
key={ index }
icon={ '+' }
Expand Down

1 comment on commit 97b9d3f

@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.
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/3737544095
📝 Reported issues:

Please sign in to comment.