groupListBody.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import {IndexedMembersByProject} from 'sentry/actionCreators/members';
  2. import LoadingError from 'sentry/components/loadingError';
  3. import LoadingIndicator from 'sentry/components/loadingIndicator';
  4. import {PanelBody} from 'sentry/components/panels';
  5. import StreamGroup from 'sentry/components/stream/group';
  6. import GroupStore from 'sentry/stores/groupStore';
  7. import {Group} from 'sentry/types';
  8. import theme from 'sentry/utils/theme';
  9. import useApi from 'sentry/utils/useApi';
  10. import useMedia from 'sentry/utils/useMedia';
  11. import useOrganization from 'sentry/utils/useOrganization';
  12. import NoGroupsHandler from './noGroupsHandler';
  13. import {IssueSortOptions} from './utils';
  14. type GroupListBodyProps = {
  15. displayReprocessingLayout: boolean;
  16. error: string | null;
  17. groupIds: string[];
  18. groupStatsPeriod: string;
  19. isSavedSearchesOpen: boolean;
  20. loading: boolean;
  21. memberList: IndexedMembersByProject;
  22. query: string;
  23. refetchGroups: () => void;
  24. selectedProjectIds: number[];
  25. sort: string;
  26. };
  27. type GroupListProps = {
  28. displayReprocessingLayout: boolean;
  29. groupIds: string[];
  30. groupStatsPeriod: string;
  31. isSavedSearchesOpen: boolean;
  32. memberList: IndexedMembersByProject;
  33. query: string;
  34. sort: string;
  35. };
  36. function GroupListBody({
  37. groupIds,
  38. memberList,
  39. query,
  40. sort,
  41. displayReprocessingLayout,
  42. groupStatsPeriod,
  43. loading,
  44. error,
  45. refetchGroups,
  46. selectedProjectIds,
  47. isSavedSearchesOpen,
  48. }: GroupListBodyProps) {
  49. const api = useApi();
  50. const organization = useOrganization();
  51. if (loading) {
  52. return <LoadingIndicator hideMessage />;
  53. }
  54. if (error) {
  55. return <LoadingError message={error} onRetry={refetchGroups} />;
  56. }
  57. if (!groupIds.length) {
  58. return (
  59. <NoGroupsHandler
  60. api={api}
  61. organization={organization}
  62. query={query}
  63. selectedProjectIds={selectedProjectIds}
  64. groupIds={groupIds}
  65. />
  66. );
  67. }
  68. return (
  69. <GroupList
  70. {...{
  71. groupIds,
  72. memberList,
  73. query,
  74. sort,
  75. displayReprocessingLayout,
  76. groupStatsPeriod,
  77. source: 'group-list',
  78. isSavedSearchesOpen,
  79. }}
  80. />
  81. );
  82. }
  83. function GroupList({
  84. groupIds,
  85. memberList,
  86. query,
  87. sort,
  88. displayReprocessingLayout,
  89. groupStatsPeriod,
  90. isSavedSearchesOpen,
  91. }: GroupListProps) {
  92. const topIssue = groupIds[0];
  93. const showInboxTime = sort === IssueSortOptions.INBOX;
  94. const canSelect = !useMedia(
  95. `(max-width: ${
  96. isSavedSearchesOpen ? theme.breakpoints.large : theme.breakpoints.small
  97. })`
  98. );
  99. return (
  100. <PanelBody>
  101. {groupIds.map((id, index) => {
  102. const hasGuideAnchor = id === topIssue;
  103. const group = GroupStore.get(id) as Group | undefined;
  104. return (
  105. <StreamGroup
  106. index={index}
  107. key={id}
  108. id={id}
  109. statsPeriod={groupStatsPeriod}
  110. query={query}
  111. hasGuideAnchor={hasGuideAnchor}
  112. memberList={group?.project ? memberList[group.project.slug] : undefined}
  113. displayReprocessingLayout={displayReprocessingLayout}
  114. useFilteredStats
  115. showInboxTime={showInboxTime}
  116. canSelect={canSelect}
  117. narrowGroups={isSavedSearchesOpen}
  118. />
  119. );
  120. })}
  121. </PanelBody>
  122. );
  123. }
  124. export default GroupListBody;