domainCell.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import styled from '@emotion/styled';
  2. import * as qs from 'query-string';
  3. import Link from 'sentry/components/links/link';
  4. import {space} from 'sentry/styles/space';
  5. import {useLocation} from 'sentry/utils/useLocation';
  6. import useOrganization from 'sentry/utils/useOrganization';
  7. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  8. import {NULL_DOMAIN_DESCRIPTION} from 'sentry/views/performance/http/settings';
  9. import {OverflowEllipsisTextContainer} from 'sentry/views/starfish/components/textAlign';
  10. interface Props {
  11. domain?: string[];
  12. projectId?: string;
  13. }
  14. export function DomainCell({projectId, domain}: Props) {
  15. const location = useLocation();
  16. const organization = useOrganization();
  17. const queryString = {
  18. ...location.query,
  19. project: projectId,
  20. 'span.domain': undefined,
  21. domain,
  22. };
  23. return (
  24. <DomainDescription>
  25. <OverflowEllipsisTextContainer>
  26. <Link
  27. to={normalizeUrl(
  28. `/organizations/${organization.slug}/performance/http/domains/?${qs.stringify(queryString)}`
  29. )}
  30. >
  31. {domain && domain.length > 0 ? domain : NULL_DOMAIN_DESCRIPTION}
  32. </Link>
  33. </OverflowEllipsisTextContainer>
  34. </DomainDescription>
  35. );
  36. }
  37. const DomainDescription = styled('div')`
  38. display: flex;
  39. flex-wrap: nowrap;
  40. gap: ${space(1)};
  41. align-items: center;
  42. `;