issueListTable.tsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import {Fragment, useContext} from 'react';
  2. import styled from '@emotion/styled';
  3. import type {IndexedMembersByProject} from 'sentry/actionCreators/members';
  4. import type {CursorHandler} from 'sentry/components/pagination';
  5. import Pagination from 'sentry/components/pagination';
  6. import Panel from 'sentry/components/panels/panel';
  7. import PanelBody from 'sentry/components/panels/panelBody';
  8. import type {PageFilters} from 'sentry/types/core';
  9. import type {SavedSearch} from 'sentry/types/group';
  10. import {VisuallyCompleteWithData} from 'sentry/utils/performanceForSentry';
  11. import IssueListActions from 'sentry/views/issueList/actions';
  12. import AddViewPage from 'sentry/views/issueList/addViewPage';
  13. import GroupListBody from 'sentry/views/issueList/groupListBody';
  14. import type {IssueUpdateData} from 'sentry/views/issueList/types';
  15. import {NewTabContext} from 'sentry/views/issueList/utils/newTabContext';
  16. interface IssueListTableProps {
  17. allResultsVisible: boolean;
  18. displayReprocessingActions: boolean;
  19. error: string | null;
  20. groupIds: string[];
  21. issuesLoading: boolean;
  22. memberList: IndexedMembersByProject;
  23. onActionTaken: (itemIds: string[], data: IssueUpdateData) => void;
  24. onCursor: CursorHandler;
  25. onDelete: () => void;
  26. onSelectStatsPeriod: (period: string) => void;
  27. onSortChange: (sort: string) => void;
  28. pageLinks: string;
  29. paginationAnalyticsEvent: (direction: string) => void;
  30. paginationCaption: React.ReactNode;
  31. query: string;
  32. queryCount: number;
  33. refetchGroups: (fetchAllCounts?: boolean) => void;
  34. savedSearches: SavedSearch[];
  35. selectedProjectIds: number[];
  36. selection: PageFilters;
  37. sort: string;
  38. statsPeriod: string;
  39. }
  40. function IssueListTable({
  41. allResultsVisible,
  42. displayReprocessingActions,
  43. groupIds,
  44. onDelete,
  45. onSelectStatsPeriod,
  46. onSortChange,
  47. query,
  48. queryCount,
  49. selection,
  50. sort,
  51. statsPeriod,
  52. onActionTaken,
  53. issuesLoading,
  54. memberList,
  55. refetchGroups,
  56. error,
  57. paginationCaption,
  58. pageLinks,
  59. onCursor,
  60. paginationAnalyticsEvent,
  61. savedSearches,
  62. }: IssueListTableProps) {
  63. const {newViewActive} = useContext(NewTabContext);
  64. return newViewActive ? (
  65. <AddViewPage savedSearches={savedSearches} />
  66. ) : (
  67. <Fragment>
  68. <Panel>
  69. {groupIds.length !== 0 && (
  70. <IssueListActions
  71. selection={selection}
  72. query={query}
  73. queryCount={queryCount}
  74. onSelectStatsPeriod={onSelectStatsPeriod}
  75. onActionTaken={onActionTaken}
  76. onDelete={onDelete}
  77. statsPeriod={statsPeriod}
  78. groupIds={groupIds}
  79. allResultsVisible={allResultsVisible}
  80. displayReprocessingActions={displayReprocessingActions}
  81. sort={sort}
  82. onSortChange={onSortChange}
  83. />
  84. )}
  85. <PanelBody>
  86. <VisuallyCompleteWithData
  87. hasData={groupIds.length > 0}
  88. id="IssueList-Body"
  89. isLoading={issuesLoading}
  90. >
  91. <GroupListBody
  92. memberList={memberList}
  93. groupStatsPeriod={statsPeriod}
  94. groupIds={groupIds}
  95. displayReprocessingLayout={displayReprocessingActions}
  96. query={query}
  97. selectedProjectIds={selection.projects}
  98. loading={issuesLoading}
  99. error={error}
  100. refetchGroups={refetchGroups}
  101. onActionTaken={onActionTaken}
  102. />
  103. </VisuallyCompleteWithData>
  104. </PanelBody>
  105. </Panel>
  106. <StyledPagination
  107. caption={paginationCaption}
  108. pageLinks={pageLinks}
  109. onCursor={onCursor}
  110. paginationAnalyticsEvent={paginationAnalyticsEvent}
  111. />
  112. </Fragment>
  113. );
  114. }
  115. const StyledPagination = styled(Pagination)`
  116. margin-top: 0;
  117. `;
  118. export default IssueListTable;