Skip to content

Commit

Permalink
Block Bindings: Add connection icon to list view (#59331)
Browse files Browse the repository at this point in the history
* Add connection icon to list view

* Remove extraneous string
  • Loading branch information
artemiomorales committed Feb 28, 2024
1 parent 752dcc3 commit bbdd7bf
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import {
Tooltip,
} from '@wordpress/components';
import { forwardRef } from '@wordpress/element';
import { Icon, lockSmall as lock, pinSmall } from '@wordpress/icons';
import {
Icon,
connection,
lockSmall as lock,
pinSmall,
} from '@wordpress/icons';
import { SPACE, ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';
import { useSelect, useDispatch } from '@wordpress/data';
import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';
Expand Down Expand Up @@ -66,6 +71,7 @@ function ListViewBlockSelectButton(
getBlockRootClientId,
getBlockOrder,
getBlocksByClientId,
getBlockAttributes,
canRemoveBlocks,
} = useSelect( blockEditorStore );
const { duplicateBlocks, multiSelect, removeBlocks } =
Expand All @@ -75,6 +81,8 @@ function ListViewBlockSelectButton(
const images = useListViewImages( { clientId, isExpanded } );
const { rootClientId } = useListViewContext();

const isConnected = getBlockAttributes( clientId )?.metadata?.bindings;

const positionLabel = blockInformation?.positionLabel
? sprintf(
// translators: 1: Position of selected block, e.g. "Sticky" or "Fixed".
Expand Down Expand Up @@ -278,6 +286,7 @@ function ListViewBlockSelectButton(
</Truncate>
</span>
) }
{ isConnected && <Icon icon={ connection } /> }
{ positionLabel && isSticky && (
<Tooltip text={ positionLabel }>
<Icon icon={ pinSmall } />
Expand Down

0 comments on commit bbdd7bf

Please sign in to comment.