eventOrGroupExtraDetails.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import styled from '@emotion/styled';
  2. import EventAnnotation from 'sentry/components/events/eventAnnotation';
  3. import GlobalSelectionLink from 'sentry/components/globalSelectionLink';
  4. import InboxReason from 'sentry/components/group/inboxBadges/inboxReason';
  5. import InboxShortId from 'sentry/components/group/inboxBadges/shortId';
  6. import {GroupStatusBadge} from 'sentry/components/group/inboxBadges/statusBadge';
  7. import TimesTag from 'sentry/components/group/inboxBadges/timesTag';
  8. import UnhandledTag from 'sentry/components/group/inboxBadges/unhandledTag';
  9. import IssueReplayCount from 'sentry/components/group/issueReplayCount';
  10. import ProjectBadge from 'sentry/components/idBadge/projectBadge';
  11. import Link from 'sentry/components/links/link';
  12. import Placeholder from 'sentry/components/placeholder';
  13. import {IconChat} from 'sentry/icons';
  14. import {tct} from 'sentry/locale';
  15. import {space} from 'sentry/styles/space';
  16. import type {Group, Organization} from 'sentry/types';
  17. import {Event} from 'sentry/types/event';
  18. import {projectCanLinkToReplay} from 'sentry/utils/replays/projectSupportsReplay';
  19. import withOrganization from 'sentry/utils/withOrganization';
  20. import {useGroupStats} from 'sentry/views/issueList/groupStatsProvider';
  21. type Props = {
  22. data: Event | Group;
  23. organization: Organization;
  24. showAssignee?: boolean;
  25. showInboxTime?: boolean;
  26. };
  27. function EventOrGroupExtraDetails({
  28. data,
  29. showAssignee,
  30. showInboxTime,
  31. organization,
  32. }: Props) {
  33. const {
  34. id,
  35. lastSeen,
  36. firstSeen,
  37. subscriptionDetails,
  38. numComments,
  39. logger,
  40. assignedTo,
  41. annotations,
  42. shortId,
  43. project,
  44. inbox,
  45. status,
  46. substatus,
  47. } = data as Group;
  48. const {lifetime, isUnhandled} = useGroupStats(data as Group);
  49. const issuesPath = `/organizations/${organization.slug}/issues/`;
  50. const showReplayCount =
  51. organization.features.includes('session-replay') && projectCanLinkToReplay(project);
  52. const hasEscalatingIssuesUi = organization.features.includes('escalating-issues');
  53. return (
  54. <GroupExtra>
  55. {!hasEscalatingIssuesUi && inbox && (
  56. <InboxReason inbox={inbox} showDateAdded={showInboxTime} />
  57. )}
  58. {hasEscalatingIssuesUi && (
  59. <GroupStatusBadge status={status} substatus={substatus} />
  60. )}
  61. {shortId && (
  62. <InboxShortId
  63. shortId={shortId}
  64. avatar={
  65. project && (
  66. <ShadowlessProjectBadge project={project} avatarSize={12} hideName />
  67. )
  68. }
  69. />
  70. )}
  71. {isUnhandled && <UnhandledTag />}
  72. {!lifetime && !firstSeen && !lastSeen ? (
  73. <Placeholder height="14px" width="100px" />
  74. ) : (
  75. <TimesTag
  76. lastSeen={lifetime?.lastSeen || lastSeen}
  77. firstSeen={lifetime?.firstSeen || firstSeen}
  78. />
  79. )}
  80. {/* Always display comment count on inbox */}
  81. {numComments > 0 && (
  82. <CommentsLink to={`${issuesPath}${id}/activity/`} className="comments">
  83. <IconChat
  84. size="xs"
  85. color={
  86. subscriptionDetails?.reason === 'mentioned' ? 'successText' : undefined
  87. }
  88. />
  89. <span>{numComments}</span>
  90. </CommentsLink>
  91. )}
  92. {showReplayCount && <IssueReplayCount groupId={id} />}
  93. {logger && (
  94. <LoggerAnnotation>
  95. <GlobalSelectionLink
  96. to={{
  97. pathname: issuesPath,
  98. query: {
  99. query: `logger:${logger}`,
  100. },
  101. }}
  102. >
  103. {logger}
  104. </GlobalSelectionLink>
  105. </LoggerAnnotation>
  106. )}
  107. {annotations?.map((annotation, key) => (
  108. <AnnotationNoMargin
  109. dangerouslySetInnerHTML={{
  110. __html: annotation,
  111. }}
  112. key={key}
  113. />
  114. ))}
  115. {showAssignee && assignedTo && (
  116. <div>{tct('Assigned to [name]', {name: assignedTo.name})}</div>
  117. )}
  118. </GroupExtra>
  119. );
  120. }
  121. const GroupExtra = styled('div')`
  122. display: inline-grid;
  123. grid-auto-flow: column dense;
  124. gap: ${space(1.5)};
  125. justify-content: start;
  126. align-items: center;
  127. color: ${p => p.theme.textColor};
  128. font-size: ${p => p.theme.fontSizeSmall};
  129. position: relative;
  130. min-width: 500px;
  131. white-space: nowrap;
  132. line-height: 1.2;
  133. a {
  134. color: inherit;
  135. }
  136. @media (min-width: ${p => p.theme.breakpoints.xlarge}) {
  137. line-height: 1;
  138. }
  139. `;
  140. const ShadowlessProjectBadge = styled(ProjectBadge)`
  141. * > img {
  142. box-shadow: none;
  143. }
  144. `;
  145. const CommentsLink = styled(Link)`
  146. display: inline-grid;
  147. gap: ${space(0.5)};
  148. align-items: center;
  149. grid-auto-flow: column;
  150. color: ${p => p.theme.textColor};
  151. `;
  152. const AnnotationNoMargin = styled(EventAnnotation)`
  153. margin-left: 0;
  154. padding-left: 0;
  155. border-left: none;
  156. & > a {
  157. color: ${p => p.theme.textColor};
  158. }
  159. `;
  160. const LoggerAnnotation = styled(AnnotationNoMargin)`
  161. color: ${p => p.theme.textColor};
  162. `;
  163. export default withOrganization(EventOrGroupExtraDetails);