import React from 'react'; import { HoverablePopover, Markdown } from '../../../presentation'; import type { QueryGitMetadata } from '../types'; import { tooltipShowHideProps } from '../../utils/defaults'; import { useLogEvent } from '../../utils/logging'; import './GitLink.less'; interface IGitLinkProps { gitMetadata: NonNullable; asLink?: boolean; } export const GitLink = ({ gitMetadata: { commit, commitInfo, pullRequest }, asLink = true }: IGitLinkProps) => { const link = pullRequest?.link || commitInfo?.link; let message = commitInfo?.message || commit; message = (commit ? `[${commit}] ` : ``) + message?.split('\n')[0]; const logEvent = useLogEvent('Artifact', 'OpenCommit'); return (
(
{commit && !asLink && ( { logEvent(); }} > Open commit {commit} )} {commitInfo?.message && }
)} > {asLink ? ( { logEvent(); }} > {message} ) : ( {message} )}
); };