domainCell.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {Link} from 'react-router';
  2. import * as qs from 'query-string';
  3. import {useLocation} from 'sentry/utils/useLocation';
  4. import useOrganization from 'sentry/utils/useOrganization';
  5. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  6. import {OverflowEllipsisTextContainer} from 'sentry/views/starfish/components/textAlign';
  7. interface Props {
  8. domain?: string;
  9. }
  10. export function DomainCell({domain}: Props) {
  11. const location = useLocation();
  12. const organization = useOrganization();
  13. // NOTE: This is for safety only, the product should not fetch or render rows with missing domains or project IDs
  14. if (!domain) {
  15. return NULL_DESCRIPTION;
  16. }
  17. const queryString = {
  18. ...location.query,
  19. domain,
  20. };
  21. return (
  22. <OverflowEllipsisTextContainer>
  23. <Link
  24. to={normalizeUrl(
  25. `/organizations/${organization.slug}/performance/http/domains/?${qs.stringify(queryString)}`
  26. )}
  27. >
  28. {domain}
  29. </Link>
  30. </OverflowEllipsisTextContainer>
  31. );
  32. }
  33. const NULL_DESCRIPTION = <span>&lt;null&gt;</span>;