import styled from '@emotion/styled'; import Button from 'sentry/components/button'; import ExternalLink from 'sentry/components/links/externalLink'; import {IconBitbucket, IconGithub, IconGitlab} from 'sentry/icons'; import space from 'sentry/styles/space'; import {PullRequest, Repository} from 'sentry/types'; function renderIcon(repo: Repository) { if (!repo.provider) { return null; } const {id} = repo.provider; const providerId = id.includes(':') ? id.split(':').pop() : id; switch (providerId) { case 'github': return ; case 'gitlab': return ; case 'bitbucket': return ; default: return null; } } type Props = { pullRequest: PullRequest; repository: Repository; inline?: boolean; }; function PullRequestLink({pullRequest, repository, inline}: Props) { const displayId = `${repository.name} #${pullRequest.id}: ${pullRequest.title}`; if (!pullRequest.externalUrl) { return {displayId}; } return !inline ? ( ) : ( {renderIcon(repository)} {displayId} ); } const ExternalPullLink = styled(ExternalLink)` display: inline-flex; align-items: center; gap: ${space(0.5)}; `; export default PullRequestLink;