header.tsx 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import Color from 'color';
  4. import {Breadcrumbs} from 'sentry/components/breadcrumbs';
  5. import {Flex} from 'sentry/components/container/flex';
  6. import Count from 'sentry/components/count';
  7. import ErrorLevel from 'sentry/components/events/errorLevel';
  8. import {getBadgeProperties} from 'sentry/components/group/inboxBadges/statusBadge';
  9. import UnhandledTag from 'sentry/components/group/inboxBadges/unhandledTag';
  10. import Link from 'sentry/components/links/link';
  11. import {Tooltip} from 'sentry/components/tooltip';
  12. import {t} from 'sentry/locale';
  13. import {space} from 'sentry/styles/space';
  14. import type {Event} from 'sentry/types/event';
  15. import type {Group} from 'sentry/types/group';
  16. import type {Project} from 'sentry/types/project';
  17. import {getMessage, getTitle} from 'sentry/utils/events';
  18. import {useLocation} from 'sentry/utils/useLocation';
  19. import useOrganization from 'sentry/utils/useOrganization';
  20. import GroupActions from 'sentry/views/issueDetails/actions/index';
  21. import {NewIssueExperienceButton} from 'sentry/views/issueDetails/actions/newIssueExperienceButton';
  22. import {Divider} from 'sentry/views/issueDetails/divider';
  23. import GroupPriority from 'sentry/views/issueDetails/groupPriority';
  24. import {ShortIdBreadcrumb} from 'sentry/views/issueDetails/shortIdBreadcrumb';
  25. import {GroupHeaderAssigneeSelector} from 'sentry/views/issueDetails/streamline/assigneeSelector';
  26. import {AttachmentsBadge} from 'sentry/views/issueDetails/streamline/attachmentsBadge';
  27. import {ReplayBadge} from 'sentry/views/issueDetails/streamline/replayBadge';
  28. import {UserFeedbackBadge} from 'sentry/views/issueDetails/streamline/userFeedbackBadge';
  29. import {useGroupDetailsRoute} from 'sentry/views/issueDetails/useGroupDetailsRoute';
  30. import {ReprocessingStatus} from 'sentry/views/issueDetails/utils';
  31. interface GroupHeaderProps {
  32. event: Event | null;
  33. group: Group;
  34. groupReprocessingStatus: ReprocessingStatus;
  35. project: Project;
  36. }
  37. export default function StreamlinedGroupHeader({
  38. event,
  39. group,
  40. groupReprocessingStatus,
  41. project,
  42. }: GroupHeaderProps) {
  43. const location = useLocation();
  44. const organization = useOrganization();
  45. const {baseUrl} = useGroupDetailsRoute();
  46. const {sort: _sort, ...query} = location.query;
  47. const {count: eventCount, userCount} = group;
  48. const {title: primaryTitle, subtitle} = getTitle(group);
  49. const secondaryTitle = getMessage(group);
  50. const isComplete = group.status === 'resolved' || group.status === 'ignored';
  51. const disableActions = [
  52. ReprocessingStatus.REPROCESSING,
  53. ReprocessingStatus.REPROCESSED_AND_HASNT_EVENT,
  54. ].includes(groupReprocessingStatus);
  55. const statusProps = getBadgeProperties(group.status, group.substatus);
  56. return (
  57. <Fragment>
  58. <Header>
  59. <Flex justify="space-between">
  60. <Breadcrumbs
  61. crumbs={[
  62. {
  63. label: 'Issues',
  64. to: {
  65. pathname: `/organizations/${organization.slug}/issues/`,
  66. query,
  67. },
  68. },
  69. {
  70. label: (
  71. <ShortIdBreadcrumb
  72. organization={organization}
  73. project={project}
  74. group={group}
  75. />
  76. ),
  77. },
  78. ]}
  79. />
  80. <NewIssueExperienceButton />
  81. </Flex>
  82. <HeaderGrid>
  83. <Flex gap={space(0.75)} align="baseline">
  84. <PrimaryTitle
  85. title={primaryTitle}
  86. isHoverable
  87. showOnlyOnOverflow
  88. delay={1000}
  89. >
  90. {primaryTitle}
  91. </PrimaryTitle>
  92. <SecondaryTitle
  93. title={secondaryTitle}
  94. isHoverable
  95. showOnlyOnOverflow
  96. delay={1000}
  97. isDefault={!secondaryTitle}
  98. >
  99. {secondaryTitle ?? t('No error message')}
  100. </SecondaryTitle>
  101. </Flex>
  102. <StatTitle>{t('Events')}</StatTitle>
  103. <StatTitle>
  104. {userCount === 0 ? (
  105. t('Users')
  106. ) : (
  107. <StatLink to={`${baseUrl}tags/user/${location.search}`}>
  108. {t('Users')}
  109. </StatLink>
  110. )}
  111. </StatTitle>
  112. <Flex gap={space(1)} align="center" justify="flex-start">
  113. <ErrorLevel level={group.level} size={'10px'} />
  114. {group.isUnhandled && <UnhandledTag />}
  115. {statusProps?.status ? (
  116. <Fragment>
  117. <Divider />
  118. <Tooltip title={statusProps?.tooltip}>
  119. <Subtext>{statusProps?.status}</Subtext>
  120. </Tooltip>
  121. </Fragment>
  122. ) : null}
  123. {subtitle && (
  124. <Fragment>
  125. <Divider />
  126. <Subtitle title={subtitle} isHoverable showOnlyOnOverflow delay={1000}>
  127. <Subtext>{subtitle}</Subtext>
  128. </Subtitle>
  129. </Fragment>
  130. )}
  131. <AttachmentsBadge group={group} />
  132. <UserFeedbackBadge group={group} project={project} />
  133. <ReplayBadge group={group} project={project} />
  134. </Flex>
  135. <StatCount value={eventCount} />
  136. <StatCount value={userCount} />
  137. </HeaderGrid>
  138. </Header>
  139. <ActionBar isComplete={isComplete}>
  140. <GroupActions
  141. group={group}
  142. project={project}
  143. disabled={disableActions}
  144. event={event}
  145. query={location.query}
  146. />
  147. <WorkflowActions>
  148. <Workflow>
  149. {t('Priority')}
  150. <GroupPriority group={group} />
  151. </Workflow>
  152. <Workflow>
  153. {t('Assignee')}
  154. <GroupHeaderAssigneeSelector group={group} project={project} event={event} />
  155. </Workflow>
  156. </WorkflowActions>
  157. </ActionBar>
  158. </Fragment>
  159. );
  160. }
  161. const Header = styled('div')`
  162. background-color: ${p => p.theme.background};
  163. padding: ${space(1)} 24px;
  164. `;
  165. const HeaderGrid = styled('div')`
  166. display: grid;
  167. grid-template-columns: minmax(150px, 1fr) auto auto;
  168. column-gap: ${space(2)};
  169. align-items: center;
  170. `;
  171. const PrimaryTitle = styled(Tooltip)`
  172. overflow-x: hidden;
  173. text-overflow: ellipsis;
  174. white-space: nowrap;
  175. font-size: 20px;
  176. font-weight: ${p => p.theme.fontWeightBold};
  177. flex-shrink: 0;
  178. `;
  179. const SecondaryTitle = styled(Tooltip)<{isDefault: boolean}>`
  180. overflow-x: hidden;
  181. text-overflow: ellipsis;
  182. white-space: nowrap;
  183. font-style: ${p => (p.isDefault ? 'italic' : 'initial')};
  184. `;
  185. const StatTitle = styled('div')`
  186. display: block;
  187. color: ${p => p.theme.subText};
  188. font-size: ${p => p.theme.fontSizeSmall};
  189. font-weight: ${p => p.theme.fontWeightBold};
  190. line-height: 1;
  191. justify-self: flex-end;
  192. `;
  193. const StatLink = styled(Link)`
  194. color: ${p => p.theme.subText};
  195. text-decoration: ${p => (p['aria-disabled'] ? 'none' : 'underline')};
  196. text-decoration-style: dotted;
  197. `;
  198. const StatCount = styled(Count)`
  199. display: block;
  200. font-size: 20px;
  201. line-height: 1;
  202. text-align: right;
  203. `;
  204. const Subtext = styled('span')`
  205. color: ${p => p.theme.subText};
  206. `;
  207. const Subtitle = styled(Tooltip)`
  208. overflow: hidden;
  209. text-overflow: ellipsis;
  210. white-space: nowrap;
  211. `;
  212. const ActionBar = styled('div')<{isComplete: boolean}>`
  213. display: flex;
  214. justify-content: space-between;
  215. gap: ${space(1)};
  216. flex-wrap: wrap;
  217. padding: ${space(1)} 24px;
  218. border-bottom: 1px solid ${p => p.theme.translucentBorder};
  219. position: relative;
  220. transition: background 0.3s ease-in-out;
  221. background: ${p => (p.isComplete ? 'transparent' : p.theme.background)};
  222. &:before {
  223. z-index: -1;
  224. position: absolute;
  225. inset: 0;
  226. content: '';
  227. background: linear-gradient(
  228. to right,
  229. ${p => p.theme.background},
  230. ${p => Color(p.theme.success).lighten(0.5).alpha(0.15).string()}
  231. );
  232. }
  233. &:after {
  234. content: '';
  235. position: absolute;
  236. top: 0;
  237. right: 0;
  238. left: 24px;
  239. bottom: unset;
  240. height: 1px;
  241. background: ${p => p.theme.translucentBorder};
  242. }
  243. `;
  244. const WorkflowActions = styled('div')`
  245. display: flex;
  246. justify-content: flex-end;
  247. column-gap: ${space(2)};
  248. flex-wrap: wrap;
  249. @media (max-width: ${p => p.theme.breakpoints.large}) {
  250. justify-content: flex-start;
  251. }
  252. `;
  253. const Workflow = styled('div')`
  254. display: flex;
  255. gap: ${space(0.5)};
  256. color: ${p => p.theme.subText};
  257. align-items: center;
  258. `;