title.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import styled from '@emotion/styled';
  2. import {CopyToClipboardButton} from 'sentry/components/copyToClipboardButton';
  3. import ProjectBadge from 'sentry/components/idBadge/projectBadge';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import {Tooltip} from 'sentry/components/tooltip';
  6. import {t, tct} from 'sentry/locale';
  7. import {space} from 'sentry/styles/space';
  8. import useProjects from 'sentry/utils/useProjects';
  9. import type {TraceTree} from '../traceModels/traceTree';
  10. interface TitleProps {
  11. representativeTransaction: TraceTree.Transaction | null;
  12. traceSlug: string;
  13. }
  14. export function Title({traceSlug, representativeTransaction}: TitleProps) {
  15. const traceTitle = representativeTransaction
  16. ? {
  17. op: representativeTransaction['transaction.op'],
  18. transaction: representativeTransaction.transaction,
  19. }
  20. : null;
  21. const {projects} = useProjects();
  22. const project = projects.find(p => p.slug === representativeTransaction?.project_slug);
  23. return (
  24. <div>
  25. {traceTitle ? (
  26. traceTitle.transaction ? (
  27. <TitleWrapper>
  28. {project && (
  29. <ProjectBadge
  30. hideName
  31. project={project}
  32. avatarSize={20}
  33. avatarProps={{
  34. hasTooltip: true,
  35. tooltip: representativeTransaction?.project_slug,
  36. }}
  37. />
  38. )}
  39. <TitleText>
  40. <strong>{traceTitle.op} - </strong>
  41. {traceTitle.transaction}
  42. </TitleText>
  43. </TitleWrapper>
  44. ) : (
  45. '\u2014'
  46. )
  47. ) : (
  48. <Tooltip
  49. title={tct(
  50. 'Might be due to sampling, ad blockers, permissions or more.[break][link:Read the docs]',
  51. {
  52. break: <br />,
  53. link: (
  54. <ExternalLink href="https://docs.sentry.io/concepts/key-terms/tracing/trace-view/#troubleshooting" />
  55. ),
  56. }
  57. )}
  58. showUnderline
  59. position="right"
  60. isHoverable
  61. >
  62. <strong>{t('Missing Trace Root')}</strong>
  63. </Tooltip>
  64. )}
  65. <SubtitleText>
  66. Trace ID: {traceSlug}
  67. <CopyToClipboardButton borderless size="zero" iconSize="xs" text={traceSlug} />
  68. </SubtitleText>
  69. </div>
  70. );
  71. }
  72. const TitleWrapper = styled('div')`
  73. display: flex;
  74. gap: ${space(0.5)};
  75. align-items: center;
  76. `;
  77. const TitleText = styled('div')`
  78. font-size: ${p => p.theme.fontSizeExtraLarge};
  79. ${p => p.theme.overflowEllipsis};
  80. `;
  81. const SubtitleText = styled('div')`
  82. font-size: ${p => p.theme.fontSizeMedium};
  83. color: ${p => p.theme.subText};
  84. `;