header.tsx 11 KB

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