spanDescriptionLink.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import {Link} from 'react-router';
  2. import * as qs from 'query-string';
  3. import {useLocation} from 'sentry/utils/useLocation';
  4. import {OverflowEllipsisTextContainer} from 'sentry/views/starfish/components/textAlign';
  5. import {extractRoute} from 'sentry/views/starfish/utils/extractRoute';
  6. import {useRoutingContext} from 'sentry/views/starfish/utils/routingContext';
  7. interface Props {
  8. description: React.ReactNode;
  9. projectId: number;
  10. endpoint?: string;
  11. endpointMethod?: string;
  12. group?: string;
  13. }
  14. export function SpanDescriptionLink({
  15. group,
  16. projectId,
  17. endpoint,
  18. endpointMethod,
  19. description,
  20. }: Props) {
  21. const location = useLocation();
  22. const routingContext = useRoutingContext();
  23. const queryString = {
  24. ...location.query,
  25. project: projectId,
  26. endpoint,
  27. endpointMethod,
  28. };
  29. return (
  30. <OverflowEllipsisTextContainer>
  31. {group ? (
  32. <Link
  33. to={`${routingContext.baseURL}/${
  34. extractRoute(location) ?? 'spans'
  35. }/span/${group}?${qs.stringify(queryString)}`}
  36. >
  37. {description}
  38. </Link>
  39. ) : (
  40. description
  41. )}
  42. </OverflowEllipsisTextContainer>
  43. );
  44. }