groupEventHeader.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 {isLoading, oneOtherIssueEvent} = useTraceTimelineEvents({
  27. event,
  28. });
  29. const showTraceLink = isRelatedIssuesEnabled && !isLoading;
  30. return (
  31. <StyledDataSection>
  32. <GroupEventCarousel group={group} event={event} projectSlug={project.slug} />
  33. {/* XXX: Remove TraceLink from groupEventCarousel when we GA. */}
  34. {showTraceLink && (
  35. <StyledTraceLink>
  36. {oneOtherIssueEvent && <span>One other issue appears in the same trace.</span>}
  37. <TraceLink event={event} />
  38. </StyledTraceLink>
  39. )}
  40. {issueTypeConfig.traceTimeline && <TraceTimeline event={event} />}
  41. <StyledGlobalAppStoreConnectUpdateAlert
  42. project={project}
  43. organization={organization}
  44. />
  45. </StyledDataSection>
  46. );
  47. }
  48. const StyledGlobalAppStoreConnectUpdateAlert = styled(GlobalAppStoreConnectUpdateAlert)`
  49. margin: ${space(0.5)} 0;
  50. `;
  51. const StyledDataSection = styled(DataSection)`
  52. padding: ${space(1)} ${space(2)} 0;
  53. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  54. padding: ${space(1.5)} ${space(4)} 0;
  55. }
  56. `;
  57. const StyledTraceLink = styled('div')`
  58. display: flex;
  59. white-space: nowrap;
  60. overflow: hidden;
  61. gap: ${space(0.25)};
  62. `;
  63. export default GroupEventHeader;