import React from 'react'; import { Group } from '@vx/group'; import styled from 'styled-components'; import { EntityType } from '../../types.generated'; import { NodeData, Direction } from './types'; function truncate(input, length) { if (!input) return ''; if (input.length > length) { return `${input.substring(0, length)}...`; } return input; } export const width = 140; export const height = 80; const centerX = -width / 2; const centerY = -height / 2; const PointerGroup = styled(Group)` cursor: pointer; `; export default function LineageEntityNode({ node, isSelected, isHovered, onEntityClick, onHover, onExpandClick, direction, isCenterNode, }: { node: { x: number; y: number; data: Omit }; isSelected: boolean; isHovered: boolean; isCenterNode: boolean; onEntityClick: (EntitySelectParams) => void; onHover: (EntitySelectParams) => void; onExpandClick: (LineageExpandParams) => void; direction: Direction; }) { return ( {node.data.unexploredChildren && ( { onExpandClick({ urn: node.data.urn, type: EntityType.Dataset, direction }); }} > )} { onEntityClick({ urn: node.data.urn, type: EntityType.Dataset }); }} onMouseOver={() => { onHover({ urn: node.data.urn, type: EntityType.Dataset }); }} onMouseOut={() => { onHover(undefined); }} > {truncate(node.data.name?.split('.').slice(-1)[0], 16)} ); }