streamlinedHeader.tsx 6.9 KB

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