issueListTable.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. organizationSavedSearches: SavedSearch[];
  29. pageLinks: string;
  30. paginationAnalyticsEvent: (direction: string) => void;
  31. paginationCaption: React.ReactNode;
  32. personalSavedSearches: SavedSearch[];
  33. query: string;
  34. queryCount: number;
  35. refetchGroups: (fetchAllCounts?: boolean) => void;
  36. selectedProjectIds: number[];
  37. selection: PageFilters;
  38. sort: string;
  39. statsPeriod: string;
  40. }
  41. function IssueListTable({
  42. allResultsVisible,
  43. displayReprocessingActions,
  44. groupIds,
  45. onDelete,
  46. onSelectStatsPeriod,
  47. onSortChange,
  48. query,
  49. queryCount,
  50. selection,
  51. sort,
  52. statsPeriod,
  53. onActionTaken,
  54. issuesLoading,
  55. memberList,
  56. refetchGroups,
  57. error,
  58. paginationCaption,
  59. pageLinks,
  60. onCursor,
  61. paginationAnalyticsEvent,
  62. personalSavedSearches,
  63. organizationSavedSearches,
  64. }: IssueListTableProps) {
  65. const {newViewActive} = useContext(NewTabContext);
  66. return newViewActive ? (
  67. <AddViewPage
  68. personalSavedSearches={personalSavedSearches}
  69. organizationSavedSearches={organizationSavedSearches}
  70. />
  71. ) : (
  72. <Fragment>
  73. <Panel>
  74. {groupIds.length !== 0 && (
  75. <IssueListActions
  76. selection={selection}
  77. query={query}
  78. queryCount={queryCount}
  79. onSelectStatsPeriod={onSelectStatsPeriod}
  80. onActionTaken={onActionTaken}
  81. onDelete={onDelete}
  82. statsPeriod={statsPeriod}
  83. groupIds={groupIds}
  84. allResultsVisible={allResultsVisible}
  85. displayReprocessingActions={displayReprocessingActions}
  86. sort={sort}
  87. onSortChange={onSortChange}
  88. />
  89. )}
  90. <PanelBody>
  91. <VisuallyCompleteWithData
  92. hasData={groupIds.length > 0}
  93. id="IssueList-Body"
  94. isLoading={issuesLoading}
  95. >
  96. <GroupListBody
  97. memberList={memberList}
  98. groupStatsPeriod={statsPeriod}
  99. groupIds={groupIds}
  100. displayReprocessingLayout={displayReprocessingActions}
  101. query={query}
  102. selectedProjectIds={selection.projects}
  103. loading={issuesLoading}
  104. error={error}
  105. refetchGroups={refetchGroups}
  106. onActionTaken={onActionTaken}
  107. />
  108. </VisuallyCompleteWithData>
  109. </PanelBody>
  110. </Panel>
  111. <StyledPagination
  112. caption={paginationCaption}
  113. pageLinks={pageLinks}
  114. onCursor={onCursor}
  115. paginationAnalyticsEvent={paginationAnalyticsEvent}
  116. />
  117. </Fragment>
  118. );
  119. }
  120. const StyledPagination = styled(Pagination)`
  121. margin-top: 0;
  122. `;
  123. export default IssueListTable;