header.tsx 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. import {Fragment, useMemo} from 'react';
  2. import styled from '@emotion/styled';
  3. import Feature from 'sentry/components/acl/feature';
  4. import {Breadcrumbs} from 'sentry/components/breadcrumbs';
  5. import EventOrGroupTitle from 'sentry/components/eventOrGroupTitle';
  6. import EventMessage from 'sentry/components/events/eventMessage';
  7. import {
  8. AssigneeSelector,
  9. useHandleAssigneeChange,
  10. } from 'sentry/components/group/assigneeSelector';
  11. import {GroupSummaryHeader} from 'sentry/components/group/groupSummary';
  12. import ParticipantList from 'sentry/components/group/streamlinedParticipantList';
  13. import Version from 'sentry/components/version';
  14. import VersionHoverCard from 'sentry/components/versionHoverCard';
  15. import {t} from 'sentry/locale';
  16. import ConfigStore from 'sentry/stores/configStore';
  17. import {space} from 'sentry/styles/space';
  18. import type {Event} from 'sentry/types/event';
  19. import type {Group, TeamParticipant, UserParticipant} from 'sentry/types/group';
  20. import type {Project} from 'sentry/types/project';
  21. import type {Release} from 'sentry/types/release';
  22. import {useApiQuery} from 'sentry/utils/queryClient';
  23. import {useLocation} from 'sentry/utils/useLocation';
  24. import useOrganization from 'sentry/utils/useOrganization';
  25. import GroupActions from 'sentry/views/issueDetails/actions/index';
  26. import {Divider} from 'sentry/views/issueDetails/divider';
  27. import GroupPriority from 'sentry/views/issueDetails/groupPriority';
  28. import {GroupHeaderTabs} from 'sentry/views/issueDetails/header';
  29. import {useIssueDetailsHeader} from 'sentry/views/issueDetails/useIssueDetailsHeader';
  30. import type {ReprocessingStatus} from 'sentry/views/issueDetails/utils';
  31. interface GroupRelease {
  32. firstRelease: Release;
  33. lastRelease: Release;
  34. }
  35. interface GroupHeaderProps {
  36. baseUrl: string;
  37. group: Group;
  38. groupReprocessingStatus: ReprocessingStatus;
  39. project: Project;
  40. event?: Event;
  41. }
  42. export default function StreamlinedGroupHeader({
  43. group,
  44. project,
  45. baseUrl,
  46. groupReprocessingStatus,
  47. event,
  48. }: GroupHeaderProps) {
  49. const location = useLocation();
  50. const organization = useOrganization();
  51. const {sort: _sort, ...query} = location.query;
  52. const {data: groupReleaseData} = useApiQuery<GroupRelease>(
  53. [`/organizations/${organization.slug}/issues/${group.id}/first-last-release/`],
  54. {
  55. staleTime: 30000,
  56. cacheTime: 30000,
  57. }
  58. );
  59. const {firstRelease, lastRelease} = groupReleaseData || {};
  60. const {handleAssigneeChange, assigneeLoading} = useHandleAssigneeChange({
  61. organization,
  62. group,
  63. });
  64. const {disabledTabs, message, eventRoute, disableActions, shortIdBreadcrumb} =
  65. useIssueDetailsHeader({
  66. group,
  67. groupReprocessingStatus,
  68. baseUrl,
  69. project,
  70. });
  71. const activeUser = ConfigStore.get('user');
  72. const {userParticipants, teamParticipants, displayUsers} = useMemo(() => {
  73. return {
  74. userParticipants: group.participants.filter(
  75. (p): p is UserParticipant => p.type === 'user'
  76. ),
  77. teamParticipants: group.participants.filter(
  78. (p): p is TeamParticipant => p.type === 'team'
  79. ),
  80. displayUsers: group.seenBy.filter(user => activeUser.id !== user.id),
  81. };
  82. }, [group, activeUser.id]);
  83. return (
  84. <Header>
  85. <StyledBreadcrumbs
  86. crumbs={[
  87. {
  88. label: 'Issues',
  89. to: {
  90. pathname: `/organizations/${organization.slug}/issues/`,
  91. query: query,
  92. },
  93. },
  94. {label: shortIdBreadcrumb},
  95. ]}
  96. />
  97. <TitleHeading>
  98. <TitleWrapper>
  99. <StyledEventOrGroupTitle data={group} />
  100. </TitleWrapper>
  101. </TitleHeading>
  102. <MessageWrapper>
  103. <EventMessage
  104. message={message}
  105. type={group.type}
  106. level={group.level}
  107. showUnhandled={group.isUnhandled}
  108. />
  109. {firstRelease && lastRelease && (
  110. <Fragment>
  111. <Divider />
  112. <ReleaseWrapper>
  113. {firstRelease.id === lastRelease.id ? t('Release') : t('Releases')}
  114. <VersionHoverCard
  115. organization={organization}
  116. projectSlug={project.slug}
  117. releaseVersion={firstRelease.version}
  118. >
  119. <Version version={firstRelease.version} projectId={project.id} truncate />
  120. </VersionHoverCard>
  121. {firstRelease.id === lastRelease.id ? null : (
  122. <Fragment>
  123. -
  124. <VersionHoverCard
  125. organization={organization}
  126. projectSlug={project.slug}
  127. releaseVersion={lastRelease.version}
  128. >
  129. <Version
  130. version={lastRelease.version}
  131. projectId={project.id}
  132. truncate
  133. />
  134. </VersionHoverCard>
  135. </Fragment>
  136. )}
  137. </ReleaseWrapper>
  138. </Fragment>
  139. )}
  140. </MessageWrapper>
  141. <Feature features={['organizations:ai-summary']}>
  142. <GroupSummaryHeader groupId={group.id} />
  143. </Feature>
  144. <StyledBreak />
  145. <InfoWrapper
  146. isResolvedOrIgnored={group.status === 'resolved' || group.status === 'ignored'}
  147. >
  148. <GroupActions
  149. group={group}
  150. project={project}
  151. disabled={disableActions}
  152. event={event}
  153. query={location.query}
  154. />
  155. <PriorityWorkflowWrapper>
  156. <Wrapper>
  157. {t('Priority')}
  158. <GroupPriority group={group} />
  159. </Wrapper>
  160. <Wrapper>
  161. {t('Assignee')}
  162. <AssigneeSelector
  163. group={group}
  164. assigneeLoading={assigneeLoading}
  165. handleAssigneeChange={handleAssigneeChange}
  166. />
  167. </Wrapper>
  168. {group.participants.length > 0 && (
  169. <Wrapper>
  170. {t('Participants')}
  171. <ParticipantList users={userParticipants} teams={teamParticipants} />
  172. </Wrapper>
  173. )}
  174. {displayUsers.length > 0 && (
  175. <Wrapper>
  176. {t('Viewers')}
  177. <ParticipantList users={displayUsers} />
  178. </Wrapper>
  179. )}
  180. </PriorityWorkflowWrapper>
  181. </InfoWrapper>
  182. <div>
  183. <GroupHeaderTabs {...{baseUrl, disabledTabs, eventRoute, group, project}} />
  184. </div>
  185. </Header>
  186. );
  187. }
  188. const StyledEventOrGroupTitle = styled(EventOrGroupTitle)`
  189. font-size: inherit;
  190. `;
  191. const TitleWrapper = styled('h3')`
  192. font-size: ${p => p.theme.headerFontSize};
  193. margin: 0 0 8px;
  194. text-overflow: ellipsis;
  195. white-space: nowrap;
  196. overflow: hidden;
  197. color: ${p => p.theme.headingColor};
  198. & em {
  199. font-weight: ${p => p.theme.fontWeightNormal};
  200. color: ${p => p.theme.textColor};
  201. font-size: 90%;
  202. }
  203. `;
  204. const TitleHeading = styled('div')`
  205. display: flex;
  206. line-height: 2;
  207. gap: ${space(1)};
  208. padding-top: ${space(1)};
  209. `;
  210. const StyledBreak = styled('hr')`
  211. margin-top: ${space(2)};
  212. margin-bottom: 0;
  213. margin-right: 0;
  214. border-color: ${p => p.theme.border};
  215. `;
  216. const MessageWrapper = styled('div')`
  217. display: flex;
  218. color: ${p => p.theme.gray300};
  219. gap: ${space(1)};
  220. `;
  221. const InfoWrapper = styled('div')<{isResolvedOrIgnored: boolean}>`
  222. display: flex;
  223. justify-content: space-between;
  224. gap: ${space(1)};
  225. background: ${p =>
  226. p.isResolvedOrIgnored
  227. ? 'linear-gradient(to right, rgba(235, 250, 246, 0.2) , rgb(235, 250, 246))'
  228. : p.theme.background};
  229. color: ${p => p.theme.gray300};
  230. padding: ${space(1)} 24px;
  231. margin-right: 0;
  232. margin-left: 0;
  233. flex-wrap: wrap;
  234. `;
  235. const PriorityWorkflowWrapper = styled('div')`
  236. display: flex;
  237. column-gap: ${space(2)};
  238. flex-wrap: wrap;
  239. `;
  240. const Wrapper = styled('div')`
  241. display: flex;
  242. align-items: center;
  243. gap: ${space(0.5)};
  244. `;
  245. const ReleaseWrapper = styled('div')`
  246. display: flex;
  247. align-items: center;
  248. max-width: 40%;
  249. gap: ${space(0.25)};
  250. a {
  251. color: ${p => p.theme.gray300};
  252. text-decoration: underline;
  253. text-decoration-style: dotted;
  254. }
  255. `;
  256. const Header = styled('div')`
  257. background-color: ${p => p.theme.background};
  258. display: flex;
  259. flex-direction: column;
  260. border-bottom: 1px solid ${p => p.theme.border};
  261. > * {
  262. margin-right: 24px;
  263. margin-left: 24px;
  264. }
  265. `;
  266. const StyledBreadcrumbs = styled(Breadcrumbs)`
  267. margin-top: ${space(2)};
  268. `;