import {Component} from 'react'; import styled from '@emotion/styled'; import {trimPackage} from 'sentry/components/events/interfaces/frame/utils'; import {STACKTRACE_PREVIEW_TOOLTIP_DELAY} from 'sentry/components/stacktracePreview'; import Tooltip from 'sentry/components/tooltip'; import space from 'sentry/styles/space'; import {defined} from 'sentry/utils'; type Props = { includeSystemFrames: boolean; onClick: (event: React.MouseEvent) => void; packagePath: string | null; withLeadHint: boolean; isClickable?: boolean; /** * Is the stack trace being previewed in a hovercard? */ isHoverPreviewed?: boolean; }; class PackageLink extends Component { handleClick = (event: React.MouseEvent) => { const {isClickable, onClick} = this.props; if (isClickable) { onClick(event); } }; render() { const { packagePath, isClickable, withLeadHint, children, includeSystemFrames, isHoverPreviewed, } = this.props; return ( {defined(packagePath) ? ( {trimPackage(packagePath)} ) : ( {''} )} {children} ); } } export const Package = styled('a')>` font-size: 13px; font-weight: bold; padding: 0 0 0 ${space(0.5)}; color: ${p => p.theme.textColor}; :hover { color: ${p => p.theme.textColor}; } cursor: ${p => (p.isClickable ? 'pointer' : 'default')}; display: flex; align-items: center; ${p => p.withLeadHint && (p.includeSystemFrames ? `max-width: 89px;` : `max-width: 76px;`)} @media (min-width: ${p => p.theme.breakpoints.large}) and (max-width: ${p => p.theme.breakpoints.xlarge}) { ${p => p.withLeadHint && (p.includeSystemFrames ? `max-width: 76px;` : `max-width: 63px;`)} } `; export const PackageName = styled('span')< Pick >` max-width: ${p => p.withLeadHint && p.isClickable && !p.includeSystemFrames ? '45px' : '104px'}; ${p => p.theme.overflowEllipsis} `; export default PackageLink;