groupListBody.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. }}
  75. />
  76. );
  77. }
  78. function GroupList({
  79. groupIds,
  80. memberList,
  81. query,
  82. sort,
  83. displayReprocessingLayout,
  84. groupStatsPeriod,
  85. }: GroupListProps) {
  86. const topIssue = groupIds[0];
  87. const showInboxTime = sort === IssueSortOptions.INBOX;
  88. const canSelect = !useMedia(`(max-width: ${theme.breakpoints.small})`);
  89. return (
  90. <PanelBody>
  91. {groupIds.map((id, index) => {
  92. const hasGuideAnchor = id === topIssue;
  93. const group = GroupStore.get(id) as Group | undefined;
  94. return (
  95. <StreamGroup
  96. index={index}
  97. key={id}
  98. id={id}
  99. statsPeriod={groupStatsPeriod}
  100. query={query}
  101. hasGuideAnchor={hasGuideAnchor}
  102. memberList={group?.project ? memberList[group.project.slug] : undefined}
  103. displayReprocessingLayout={displayReprocessingLayout}
  104. useFilteredStats
  105. showInboxTime={showInboxTime}
  106. canSelect={canSelect}
  107. />
  108. );
  109. })}
  110. </PanelBody>
  111. );
  112. }
  113. export default GroupListBody;