import { useCallback } from 'react' ; import styled , { css } from 'reshadow' ; import { Link } from '@cloudbeaver/core-blocks' ; import { useService } from '@cloudbeaver/core-di' ; import { NavigationTreeService } from '../../NavigationTree/NavigationTreeService' ; import { parseNodeParentId } from './NavNodeManagerService' ; const style = css `
  Link {
    cursor: pointer;
  }
` ; interface Props { name : string ; nodeId ? : string ; } export const NodeLink = function NodeLink ( { children , name , nodeId } ) { const navigationTreeService = useService ( NavigationTreeService ) ; const handleClick = useCallback ( ( ) => { if ( nodeId ) { navigationTreeService . navToNode ( nodeId , parseNodeParentId ( nodeId ) ) ; } } , [ nodeId , navigationTreeService ] ) ; if ( nodeId ) { return styled ( style ) ( < Link onClick = { handleClick } > { children } < /Link>); } return < > { children } < />; } ;