groupEventHeader.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import styled from '@emotion/styled';
  2. import {DataSection} from 'sentry/components/events/styles';
  3. import GlobalAppStoreConnectUpdateAlert from 'sentry/components/globalAppStoreConnectUpdateAlert';
  4. import {space} from 'sentry/styles/space';
  5. import type {Event} from 'sentry/types/event';
  6. import type {Group} from 'sentry/types/group';
  7. import type {Project} from 'sentry/types/project';
  8. import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
  9. import useOrganization from 'sentry/utils/useOrganization';
  10. import {GroupEventCarousel} from 'sentry/views/issueDetails/groupEventCarousel';
  11. import {TraceLink} from 'sentry/views/issueDetails/traceTimeline/traceLink';
  12. import {TraceTimeline} from 'sentry/views/issueDetails/traceTimeline/traceTimeline';
  13. import {useTraceTimelineEvents} from 'sentry/views/issueDetails/traceTimeline/useTraceTimelineEvents';
  14. type GroupEventHeaderProps = {
  15. event: Event;
  16. group: Group;
  17. project: Project;
  18. };
  19. function GroupEventHeader({event, group, project}: GroupEventHeaderProps) {
  20. const organization = useOrganization();
  21. const issueTypeConfig = getConfigForIssueType(group, group.project);
  22. const isRelatedIssuesEnabled = organization.features.includes(
  23. 'related-issues-issue-details-page'
  24. );
  25. // This is also called within the TraceTimeline component but caching will save a second call
  26. const {isError, isLoading, oneOtherIssueEvent} = useTraceTimelineEvents({
  27. event,
  28. });
  29. const readyToShow = !isLoading && !isError;
  30. return (
  31. <StyledDataSection>
  32. <GroupEventCarousel group={group} event={event} projectSlug={project.slug} />
  33. {isRelatedIssuesEnabled && readyToShow && oneOtherIssueEvent === undefined && (
  34. <TraceLink event={event} />
  35. )}
  36. {isRelatedIssuesEnabled && oneOtherIssueEvent && (
  37. <StyledTraceLink>
  38. One other issue appears in the same trace.
  39. {readyToShow && <TraceLink event={event} />}
  40. </StyledTraceLink>
  41. )}
  42. {issueTypeConfig.traceTimeline && <TraceTimeline event={event} />}
  43. <StyledGlobalAppStoreConnectUpdateAlert
  44. project={project}
  45. organization={organization}
  46. />
  47. </StyledDataSection>
  48. );
  49. }
  50. const StyledGlobalAppStoreConnectUpdateAlert = styled(GlobalAppStoreConnectUpdateAlert)`
  51. margin: ${space(0.5)} 0;
  52. `;
  53. const StyledDataSection = styled(DataSection)`
  54. padding: ${space(1)} ${space(2)} 0;
  55. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  56. padding: ${space(1.5)} ${space(4)} 0;
  57. }
  58. `;
  59. const StyledTraceLink = styled('div')`
  60. display: flex;
  61. white-space: nowrap;
  62. overflow: hidden;
  63. gap: ${space(0.25)};
  64. `;
  65. export default GroupEventHeader;