groupListBody.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. loading: boolean;
  20. memberList: IndexedMembersByProject;
  21. query: string;
  22. refetchGroups: () => void;
  23. selectedProjectIds: number[];
  24. sort: string;
  25. };
  26. type GroupListProps = {
  27. displayReprocessingLayout: boolean;
  28. groupIds: string[];
  29. groupStatsPeriod: string;
  30. memberList: IndexedMembersByProject;
  31. query: string;
  32. sort: string;
  33. };
  34. function GroupListBody({
  35. groupIds,
  36. memberList,
  37. query,
  38. sort,
  39. displayReprocessingLayout,
  40. groupStatsPeriod,
  41. loading,
  42. error,
  43. refetchGroups,
  44. selectedProjectIds,
  45. }: GroupListBodyProps) {
  46. const api = useApi();
  47. const organization = useOrganization();
  48. if (loading) {
  49. return <LoadingIndicator hideMessage />;
  50. }
  51. if (error) {
  52. return <LoadingError message={error} onRetry={refetchGroups} />;
  53. }
  54. if (!groupIds.length) {
  55. return (
  56. <NoGroupsHandler
  57. api={api}
  58. organization={organization}
  59. query={query}
  60. selectedProjectIds={selectedProjectIds}
  61. groupIds={groupIds}
  62. />
  63. );
  64. }
  65. return (
  66. <GroupList
  67. {...{
  68. groupIds,
  69. memberList,
  70. query,
  71. sort,
  72. displayReprocessingLayout,
  73. groupStatsPeriod,
  74. source: 'group-list',
  75. }}
  76. />
  77. );
  78. }
  79. function GroupList({
  80. groupIds,
  81. memberList,
  82. query,
  83. sort,
  84. displayReprocessingLayout,
  85. groupStatsPeriod,
  86. }: GroupListProps) {
  87. const topIssue = groupIds[0];
  88. const showInboxTime = sort === IssueSortOptions.INBOX;
  89. const canSelect = !useMedia(`(max-width: ${theme.breakpoints.small})`);
  90. return (
  91. <PanelBody>
  92. {groupIds.map((id, index) => {
  93. const hasGuideAnchor = id === topIssue;
  94. const group = GroupStore.get(id) as Group | undefined;
  95. return (
  96. <StreamGroup
  97. index={index}
  98. key={id}
  99. id={id}
  100. statsPeriod={groupStatsPeriod}
  101. query={query}
  102. hasGuideAnchor={hasGuideAnchor}
  103. memberList={group?.project ? memberList[group.project.slug] : undefined}
  104. displayReprocessingLayout={displayReprocessingLayout}
  105. useFilteredStats
  106. showInboxTime={showInboxTime}
  107. canSelect={canSelect}
  108. />
  109. );
  110. })}
  111. </PanelBody>
  112. );
  113. }
  114. export default GroupListBody;