Skip to content

Commit

Permalink
Block Bindings: Add warning in attributes connected to invalid sources (
Browse files Browse the repository at this point in the history
#65002)

* Add warning with invalid sources

* Change variable name

Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>

* Use `isSourceInvalid` variable

---------

Co-authored-by: SantosGuillamot <santosguillamot@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
  • Loading branch information
5 people authored Sep 3, 2024
1 parent 7b7196f commit 66eeb38
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/block-editor/src/hooks/block-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,20 @@ function BlockBindingsAttribute( { attribute, binding } ) {
const { source: sourceName, args } = binding || {};
const sourceProps =
unlock( blocksPrivateApis ).getBlockBindingsSource( sourceName );
const isSourceInvalid = ! sourceProps;
return (
<VStack>
<Truncate>{ attribute }</Truncate>
{ !! binding && (
<Text
variant="muted"
variant={ ! isSourceInvalid && 'muted' }
className="block-editor-bindings__item-explanation"
isDestructive={ isSourceInvalid }
>
<Truncate>
{ args?.key || sourceProps?.label || sourceName }
{ isSourceInvalid
? __( 'Invalid source' )
: args?.key || sourceProps?.label || sourceName }
</Truncate>
</Text>
) }
Expand Down

1 comment on commit 66eeb38

@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 66eeb38.
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/10684418180
📝 Reported issues:

Please sign in to comment.