From 5586910e9d935eb9b3d84879f003508008d6b494 Mon Sep 17 00:00:00 2001 From: Chaim Lev-Ari Date: Tue, 22 Aug 2023 09:36:31 +0300 Subject: [PATCH] fix(ui/datatables): sync page count with filtering [EE-5890] (#10010) --- .../PaginationControls/PageSelector.tsx | 15 ++----- .../PaginationControls/PaginationControls.tsx | 7 ++- .../PaginationControls/generatePagesArray.ts | 4 +- app/react/components/datatables/Datatable.tsx | 45 +++++++++++++------ .../components/datatables/DatatableFooter.tsx | 6 +-- .../datatables/ExpandableDatatable.tsx | 8 +++- app/react/components/datatables/NameCell.tsx | 1 - .../components/EdgeGroupAssociationTable.tsx | 9 ++-- .../WaitingRoomView/Datatable/Datatable.tsx | 6 +-- .../EnvironmentsDatatable.tsx | 12 ++--- .../EventsDatatable/EventsDatatable.tsx | 1 - .../AMTButton/AssociateAMTDialog.tsx | 2 +- .../EnvironmentList/EnvironmentList.tsx | 2 +- .../KubeconfigButton/KubeconfigPrompt.tsx | 2 +- .../ListView/EnvironmentsDatatable.tsx | 9 +++- .../AssociatedEnvironmentsSelector.tsx | 1 + .../components/GroupAssociationTable.tsx | 9 ++-- .../update-schedules/ListView/ListView.tsx | 1 - .../notifications/NotificationsView.tsx | 1 - 19 files changed, 78 insertions(+), 63 deletions(-) diff --git a/app/react/components/PaginationControls/PageSelector.tsx b/app/react/components/PaginationControls/PageSelector.tsx index 6fa3af1fd..4099610f8 100644 --- a/app/react/components/PaginationControls/PageSelector.tsx +++ b/app/react/components/PaginationControls/PageSelector.tsx @@ -8,29 +8,22 @@ interface Props { boundaryLinks?: boolean; currentPage: number; directionLinks?: boolean; - itemsPerPage: number; onPageChange(page: number): void; - totalCount: number; + pageCount: number; maxSize: number; isInputVisible?: boolean; } export function PageSelector({ currentPage, - totalCount, - itemsPerPage, + pageCount, onPageChange, maxSize = 5, directionLinks = true, boundaryLinks = false, isInputVisible = false, }: Props) { - const pages = generatePagesArray( - currentPage, - totalCount, - itemsPerPage, - maxSize - ); + const pages = generatePagesArray(currentPage, pageCount, maxSize); const last = pages[pages.length - 1]; if (pages.length <= 1) { @@ -42,7 +35,7 @@ export function PageSelector({ {isInputVisible && ( onPageChange(page)} - totalPages={Math.ceil(totalCount / itemsPerPage)} + totalPages={pageCount} /> )}