123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import Link from 'sentry/components/links/link';
- import Tag from 'sentry/components/tag';
- import {IconOpen} from 'sentry/icons';
- import {t} from 'sentry/locale';
- import {Deploy} from 'sentry/types';
- import {MutableSearch} from 'sentry/utils/tokenizeSearch';
- type Props = {
- deploy: Deploy;
- className?: string;
- orgSlug?: string;
- projectId?: number;
- version?: string;
- };
- const DeployBadge = ({deploy, orgSlug, projectId, version, className}: Props) => {
- const shouldLinkToIssues = !!orgSlug && !!version;
- const badge = (
- <Tag
- className={className}
- type="highlight"
- icon={shouldLinkToIssues && <IconOpen data-test-id="deploy-open-icon" />}
- textMaxWidth={80}
- tooltipText={shouldLinkToIssues ? t('Open In Issues') : undefined}
- >
- {deploy.environment}
- </Tag>
- );
- if (!shouldLinkToIssues) {
- return badge;
- }
- return (
- <Link
- to={{
- pathname: `/organizations/${orgSlug}/issues/`,
- query: {
- project: projectId ?? null,
- environment: deploy.environment,
- query: new MutableSearch([`release:${version!}`]).formatString(),
- },
- }}
- >
- {badge}
- </Link>
- );
- };
- export default DeployBadge;
|