-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
index.js
36 lines (33 loc) · 869 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* WordPress dependencies
*/
import { ToolbarButton } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { connection } from '@wordpress/icons';
import { _x } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';
export default function BlockBindingsButton( { clientId } ) {
const { blockAttributes } = useSelect(
( select ) => {
const { getBlockAttributes } = select( blockEditorStore );
return {
blockAttributes: getBlockAttributes( clientId ),
};
},
[ clientId ]
);
return blockAttributes?.metadata?.bindings ? (
<ToolbarButton
icon={ connection }
label={ _x(
// TODO: Let's get this naming right
'Connected to a block bindings source',
'block toolbar button label'
) }
iconSize={ 24 }
></ToolbarButton>
) : null;
}