domainCell.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 {OverflowEllipsisTextContainer} from 'sentry/views/insights/common/components/textAlign';
  7. import {useModuleURL} from 'sentry/views/insights/common/utils/useModuleURL';
  8. import {NULL_DOMAIN_DESCRIPTION} from 'sentry/views/insights/http/settings';
  9. interface Props {
  10. domain?: string[];
  11. projectId?: string;
  12. }
  13. export function DomainCell({projectId, domain}: Props) {
  14. const moduleURL = useModuleURL('http');
  15. const location = useLocation();
  16. const queryString = {
  17. ...location.query,
  18. project: projectId,
  19. 'span.domain': undefined,
  20. domain,
  21. };
  22. return (
  23. <DomainDescription>
  24. <OverflowEllipsisTextContainer>
  25. <Link to={`${moduleURL}/domains/?${qs.stringify(queryString)}`}>
  26. {domain && domain.length > 0 ? domain : NULL_DOMAIN_DESCRIPTION}
  27. </Link>
  28. </OverflowEllipsisTextContainer>
  29. </DomainDescription>
  30. );
  31. }
  32. const DomainDescription = styled('div')`
  33. display: flex;
  34. flex-wrap: nowrap;
  35. gap: ${space(1)};
  36. align-items: center;
  37. `;