From 0103e978b04a10dde2f75a0fbf64cd65ba6d189e Mon Sep 17 00:00:00 2001 From: ek-hystax <33006768+ek-hystax@users.noreply.github.com> Date: Tue, 24 Sep 2024 09:29:27 +0400 Subject: [PATCH 1/3] OS-7790. Add total counter for the resources table The total count is only provided for the 'main' table. The tables that display grouped resources do not show a counter because the API only returns the overall total, and we cannot determine how many resources belong to each specific group. --- .../CleanExpensesTable/CleanExpensesTable.tsx | 11 +++++++++-- .../CleanExpensesTableGroup.tsx | 4 +++- .../CleanExpensesBreakdownContainer.tsx | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ngui/ui/src/components/CleanExpensesTable/CleanExpensesTable.tsx b/ngui/ui/src/components/CleanExpensesTable/CleanExpensesTable.tsx index c90b9e0e5..399a984de 100644 --- a/ngui/ui/src/components/CleanExpensesTable/CleanExpensesTable.tsx +++ b/ngui/ui/src/components/CleanExpensesTable/CleanExpensesTable.tsx @@ -56,7 +56,8 @@ const CleanExpensesTable = ({ isDownloadingResources = false, startDateTimestamp, endDateTimestamp, - assignmentRuleCreationLinkParameters + assignmentRuleCreationLinkParameters, + totalResourcesCount }) => { const dispatch = useDispatch(); const { organizationId } = useOrganizationInfo(); @@ -344,7 +345,13 @@ const CleanExpensesTable = ({ columnsSelectorUID={disableColumnsSelection ? "" : "cleanExpensesTable"} localization={{ emptyMessageId: "noResources" }} queryParamPrefix={CLEAN_EXPENSES_TABLE_QUERY_PARAM_PREFIX} - counters={{ hideTotal: true }} + counters={ + totalResourcesCount + ? { total: totalResourcesCount } + : { + hideTotal: true + } + } dataTestIds={{ infoArea: { displayed: "counter_displayed", diff --git a/ngui/ui/src/components/CleanExpensesTableGroup/CleanExpensesTableGroup.tsx b/ngui/ui/src/components/CleanExpensesTableGroup/CleanExpensesTableGroup.tsx index 79a1434cc..025cea7ee 100644 --- a/ngui/ui/src/components/CleanExpensesTableGroup/CleanExpensesTableGroup.tsx +++ b/ngui/ui/src/components/CleanExpensesTableGroup/CleanExpensesTableGroup.tsx @@ -133,7 +133,8 @@ const CleanExpensesTableGroup = ({ downloadResources, isDownloadingResources = false, startDateTimestamp, - endDateTimestamp + endDateTimestamp, + totalResourcesCount }) => { const { [GROUP_TYPE_PARAM_NAME]: groupTypeQueryParameter = "", @@ -285,6 +286,7 @@ const CleanExpensesTableGroup = ({ expenses={expenses} downloadResources={downloadResources} isDownloadingResources={isDownloadingResources} + totalResourcesCount={totalResourcesCount} /> )} diff --git a/ngui/ui/src/containers/CleanExpensesBreakdownContainer/CleanExpensesBreakdownContainer.tsx b/ngui/ui/src/containers/CleanExpensesBreakdownContainer/CleanExpensesBreakdownContainer.tsx index 3b271f3ed..755b7ae7b 100644 --- a/ngui/ui/src/containers/CleanExpensesBreakdownContainer/CleanExpensesBreakdownContainer.tsx +++ b/ngui/ui/src/containers/CleanExpensesBreakdownContainer/CleanExpensesBreakdownContainer.tsx @@ -51,7 +51,7 @@ const CleanExpensesBreakdownContainer = ({ requestParams }) => { const { useGet } = CleanExpensesService(); const { isLoading, data: apiData } = useGet({ params: requestParams }); - const { clean_expenses: expenses = [] } = apiData; + const { clean_expenses: expenses = [], total_count: totalResourcesCount } = apiData; const startDateTimestamp = Number(requestParams.startDate); const endDateTimestamp = Number(requestParams.endDate); @@ -76,6 +76,7 @@ const CleanExpensesBreakdownContainer = ({ requestParams }) => { } downloadResources={downloadResources} isDownloadingResources={isFileDownloading} + totalResourcesCount={totalResourcesCount} /> ); From 91c08b6ef75169562983e7bf30b314ec428a2ffd Mon Sep 17 00:00:00 2001 From: ek-hystax <33006768+ek-hystax@users.noreply.github.com> Date: Tue, 24 Sep 2024 09:55:29 +0400 Subject: [PATCH 2/3] OS-7791. Replace `getFilteredSelectedRowModel` with `getSelectedRowModel` to count all selected rows --- ngui/ui/src/components/Table/Table.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ngui/ui/src/components/Table/Table.tsx b/ngui/ui/src/components/Table/Table.tsx index 6c24fa3fe..508792b0e 100644 --- a/ngui/ui/src/components/Table/Table.tsx +++ b/ngui/ui/src/components/Table/Table.tsx @@ -205,9 +205,7 @@ const Table = ({ ...tableOptions }); - const { flatRows: filteredSelectedFlatRows } = table.getFilteredSelectedRowModel(); - - const selectedRowsCount = withSelection ? filteredSelectedFlatRows.length : 0; + const selectedRowsCount = withSelection ? table.getSelectedRowModel().flatRows.length : 0; const { rows } = table.getRowModel(); From 9f5e1001fdcb67e8ccaded4f83208d735d9d02d5 Mon Sep 17 00:00:00 2001 From: ek-hystax <33006768+ek-hystax@users.noreply.github.com> Date: Tue, 24 Sep 2024 10:02:10 +0400 Subject: [PATCH 3/3] OS-7794. Fix totalRows value in getPaginationSettings If fixes the "total" value displayed for tables with expandable rows --- ngui/ui/src/components/Table/Table.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ngui/ui/src/components/Table/Table.tsx b/ngui/ui/src/components/Table/Table.tsx index 508792b0e..6c3dde61e 100644 --- a/ngui/ui/src/components/Table/Table.tsx +++ b/ngui/ui/src/components/Table/Table.tsx @@ -130,12 +130,14 @@ const Table = ({ const { state: columnsVisibilityState, tableOptions: columnsVisibilityTableOptions } = useColumnsVisibility(columnsSelectorUID); + const totalRowsCount = getRowsCount(data, { + withExpanded, + getSubRows + }); + const { state: paginationState, tableOptions: paginationTableOptions } = usePaginationTableSettings({ pageSize, - rowsCount: getRowsCount(data, { - withExpanded, - getSubRows - }), + rowsCount: totalRowsCount, queryParamPrefix, enablePaginationQueryParam }); @@ -225,7 +227,7 @@ const Table = ({ pageIndex: table.getState().pagination.pageIndex, pageSize: table.getState().pagination.pageSize, onPageIndexChange: table.setPageIndex, - totalRows: data.length + totalRows: totalRowsCount }; };