sharedGroupHeader.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. data={group}
  62. />
  63. </Details>
  64. </Wrapper>
  65. );
  66. }
  67. export default SharedGroupHeader;
  68. const Wrapper = styled('div')`
  69. padding: ${space(3)} ${space(4)} ${space(3)} ${space(4)};
  70. border-bottom: 1px solid ${p => p.theme.border};
  71. position: relative;
  72. `;
  73. const Details = styled('div')`
  74. max-width: 960px;
  75. margin: 0 auto;
  76. `;
  77. const ShortIdWrapper = styled('div')`
  78. display: flex;
  79. `;
  80. const TitleWrap = styled('div')`
  81. display: grid;
  82. grid-template-columns: 1fr max-content;
  83. align-items: center;
  84. margin-bottom: ${space(1)};
  85. `;
  86. const Title = styled('h3')`
  87. color: ${p => p.theme.headingColor};
  88. font-size: ${p => p.theme.fontSizeExtraLarge};
  89. line-height: ${p => p.theme.text.lineHeightHeading};
  90. margin-right: ${space(2)};
  91. margin-bottom: 0;
  92. ${p => p.theme.overflowEllipsis};
  93. @media (min-width: ${props => props.theme.breakpoints.small}) {
  94. font-size: ${p => p.theme.headerFontSize};
  95. }
  96. `;
  97. const TimeStamp = styled('div')`
  98. color: ${p => p.theme.headingColor};
  99. font-size: ${p => p.theme.fontSizeMedium};
  100. line-height: ${p => p.theme.text.lineHeightHeading};
  101. margin-top: ${space(0.25)};
  102. `;
  103. const EventTimeLabel = styled('span')`
  104. color: ${p => p.theme.subText};
  105. margin-left: ${space(0.25)};
  106. `;