sharedGroupHeader.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import styled from '@emotion/styled';
  2. import FeatureBadge from 'sentry/components/badge/featureBadge';
  3. import {DateTime} from 'sentry/components/dateTime';
  4. import EventMessage from 'sentry/components/events/eventMessage';
  5. import ProjectBadge from 'sentry/components/idBadge/projectBadge';
  6. import ShortId from 'sentry/components/shortId';
  7. import {Tooltip} from 'sentry/components/tooltip';
  8. import {t} from 'sentry/locale';
  9. import {space} from 'sentry/styles/space';
  10. import type {Group} from 'sentry/types/group';
  11. import {IssueCategory} from 'sentry/types/group';
  12. import EventCreatedTooltip from 'sentry/views/issueDetails/eventCreatedTooltip';
  13. type Props = {
  14. group: Group;
  15. };
  16. function SharedGroupHeader({group}: Props) {
  17. const date = new Date(
  18. (group.latestEvent?.dateCreated ?? group.latestEvent?.dateReceived) as string
  19. );
  20. const event = group.latestEvent;
  21. return (
  22. <Wrapper>
  23. <Details>
  24. <TitleWrap>
  25. <Title>{group.title}</Title>
  26. <ShortIdWrapper>
  27. <ShortId
  28. shortId={group.shortId}
  29. avatar={<ProjectBadge project={group.project} avatarSize={20} hideName />}
  30. />
  31. {group.issueCategory === IssueCategory.PERFORMANCE && (
  32. <FeatureBadge
  33. type="beta"
  34. title={t(
  35. 'Not all features have been implemented for shared Performance Issues and these issues may be missing context.'
  36. )}
  37. />
  38. )}
  39. </ShortIdWrapper>
  40. {event && (event.dateCreated ?? event.dateReceived) && (
  41. <TimeStamp data-test-id="sgh-timestamp">
  42. {t('Last seen ')}
  43. <EventTimeLabel>
  44. <Tooltip
  45. isHoverable
  46. showUnderline
  47. title={<EventCreatedTooltip event={event} />}
  48. overlayStyle={{maxWidth: 300}}
  49. >
  50. <DateTime date={date} />
  51. </Tooltip>
  52. </EventTimeLabel>
  53. </TimeStamp>
  54. )}
  55. </TitleWrap>
  56. <EventMessage
  57. showUnhandled={group.isUnhandled}
  58. message={group.culprit}
  59. level={group.level}
  60. type={group.type}
  61. />
  62. </Details>
  63. </Wrapper>
  64. );
  65. }
  66. export default SharedGroupHeader;
  67. const Wrapper = styled('div')`
  68. padding: ${space(3)} ${space(4)} ${space(3)} ${space(4)};
  69. border-bottom: 1px solid ${p => p.theme.border};
  70. position: relative;
  71. `;
  72. const Details = styled('div')`
  73. max-width: 960px;
  74. margin: 0 auto;
  75. `;
  76. const ShortIdWrapper = styled('div')`
  77. display: flex;
  78. `;
  79. const TitleWrap = styled('div')`
  80. display: grid;
  81. grid-template-columns: 1fr max-content;
  82. align-items: center;
  83. margin-bottom: ${space(1)};
  84. `;
  85. const Title = styled('h3')`
  86. color: ${p => p.theme.headingColor};
  87. font-size: ${p => p.theme.fontSizeExtraLarge};
  88. line-height: ${p => p.theme.text.lineHeightHeading};
  89. margin-right: ${space(2)};
  90. margin-bottom: 0;
  91. ${p => p.theme.overflowEllipsis};
  92. @media (min-width: ${props => props.theme.breakpoints.small}) {
  93. font-size: ${p => p.theme.headerFontSize};
  94. }
  95. `;
  96. const TimeStamp = styled('div')`
  97. color: ${p => p.theme.headingColor};
  98. font-size: ${p => p.theme.fontSizeMedium};
  99. line-height: ${p => p.theme.text.lineHeightHeading};
  100. margin-top: ${space(0.25)};
  101. `;
  102. const EventTimeLabel = styled('span')`
  103. color: ${p => p.theme.subText};
  104. margin-left: ${space(0.25)};
  105. `;