sidebar.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import {Fragment, useMemo} from 'react';
  2. import styled from '@emotion/styled';
  3. import GuideAnchor from 'sentry/components/assistant/guideAnchor';
  4. import ErrorBoundary from 'sentry/components/errorBoundary';
  5. import {StreamlinedExternalIssueList} from 'sentry/components/group/externalIssuesList/streamlinedExternalIssueList';
  6. import * as Layout from 'sentry/components/layouts/thirds';
  7. import * as SidebarSection from 'sentry/components/sidebarSection';
  8. import {space} from 'sentry/styles/space';
  9. import type {Event} from 'sentry/types/event';
  10. import type {Group, TeamParticipant, UserParticipant} from 'sentry/types/group';
  11. import type {Project} from 'sentry/types/project';
  12. import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
  13. import useOrganization from 'sentry/utils/useOrganization';
  14. import {useUser} from 'sentry/utils/useUser';
  15. import StreamlinedActivitySection from 'sentry/views/issueDetails/streamline/sidebar/activitySection';
  16. import FirstLastSeenSection from 'sentry/views/issueDetails/streamline/sidebar/firstLastSeenSection';
  17. import {MergedIssuesSidebarSection} from 'sentry/views/issueDetails/streamline/sidebar/mergedSidebarSection';
  18. import PeopleSection from 'sentry/views/issueDetails/streamline/sidebar/peopleSection';
  19. import {SimilarIssuesSidebarSection} from 'sentry/views/issueDetails/streamline/sidebar/similarIssuesSidebarSection';
  20. import SolutionsSection from 'sentry/views/issueDetails/streamline/sidebar/solutionsSection';
  21. type Props = {
  22. group: Group;
  23. project: Project;
  24. event?: Event;
  25. };
  26. export default function StreamlinedSidebar({group, event, project}: Props) {
  27. const activeUser = useUser();
  28. const organization = useOrganization();
  29. const {userParticipants, teamParticipants, viewers} = useMemo(() => {
  30. return {
  31. userParticipants: group.participants.filter(
  32. (p): p is UserParticipant => p.type === 'user'
  33. ),
  34. teamParticipants: group.participants.filter(
  35. (p): p is TeamParticipant => p.type === 'team'
  36. ),
  37. viewers: group.seenBy.filter(user => activeUser.id !== user.id),
  38. };
  39. }, [group, activeUser.id]);
  40. const showPeopleSection = group.participants.length > 0 || viewers.length > 0;
  41. const issueTypeConfig = getConfigForIssueType(group, group.project);
  42. return (
  43. <Side>
  44. <GuideAnchor target="issue_sidebar_releases" position="left">
  45. <FirstLastSeenSection group={group} />
  46. </GuideAnchor>
  47. <StyledBreak />
  48. {((organization.features.includes('gen-ai-features') &&
  49. issueTypeConfig.issueSummary.enabled &&
  50. !organization.hideAiFeatures) ||
  51. issueTypeConfig.resources) && (
  52. <ErrorBoundary mini>
  53. <SolutionsSection group={group} project={project} event={event} />
  54. <StyledBreak />
  55. </ErrorBoundary>
  56. )}
  57. {event && (
  58. <ErrorBoundary mini>
  59. <StreamlinedExternalIssueList group={group} event={event} project={project} />
  60. <StyledBreak style={{marginBottom: space(0.5)}} />
  61. </ErrorBoundary>
  62. )}
  63. <StreamlinedActivitySection group={group} />
  64. {showPeopleSection && (
  65. <Fragment>
  66. <StyledBreak />
  67. <PeopleSection
  68. userParticipants={userParticipants}
  69. teamParticipants={teamParticipants}
  70. viewers={viewers}
  71. />
  72. </Fragment>
  73. )}
  74. {issueTypeConfig.similarIssues.enabled && (
  75. <Fragment>
  76. <StyledBreak />
  77. <SimilarIssuesSidebarSection />
  78. </Fragment>
  79. )}
  80. {issueTypeConfig.mergedIssues.enabled && (
  81. <Fragment>
  82. <StyledBreak />
  83. <MergedIssuesSidebarSection />
  84. </Fragment>
  85. )}
  86. </Side>
  87. );
  88. }
  89. const StyledBreak = styled('hr')`
  90. margin-top: ${space(1.5)};
  91. margin-bottom: ${space(1.5)};
  92. border-color: ${p => p.theme.border};
  93. `;
  94. export const SidebarSectionTitle = styled(SidebarSection.Title)`
  95. margin-bottom: ${space(1)};
  96. color: ${p => p.theme.headingColor};
  97. `;
  98. const Side = styled(Layout.Side)`
  99. position: relative;
  100. padding: ${space(1.5)} ${space(2)};
  101. `;