Skip to content

Commit

Permalink
Pull request update/240925
Browse files Browse the repository at this point in the history
9f5e100 OS-7794. Fix totalRows value in getPaginationSettings
91c08b6 OS-7791. Replace `getFilteredSelectedRowModel` with `getSelectedRowModel` to count all selected rows
0103e97 OS-7790. Add total counter for the resources table
  • Loading branch information
stanfra authored Sep 25, 2024
2 parents c434719 + 9f5e100 commit 1a1f2cd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
11 changes: 9 additions & 2 deletions ngui/ui/src/components/CleanExpensesTable/CleanExpensesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ const CleanExpensesTable = ({
isDownloadingResources = false,
startDateTimestamp,
endDateTimestamp,
assignmentRuleCreationLinkParameters
assignmentRuleCreationLinkParameters,
totalResourcesCount
}) => {
const dispatch = useDispatch();
const { organizationId } = useOrganizationInfo();
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ const CleanExpensesTableGroup = ({
downloadResources,
isDownloadingResources = false,
startDateTimestamp,
endDateTimestamp
endDateTimestamp,
totalResourcesCount
}) => {
const {
[GROUP_TYPE_PARAM_NAME]: groupTypeQueryParameter = "",
Expand Down Expand Up @@ -285,6 +286,7 @@ const CleanExpensesTableGroup = ({
expenses={expenses}
downloadResources={downloadResources}
isDownloadingResources={isDownloadingResources}
totalResourcesCount={totalResourcesCount}
/>
)}
</Grid>
Expand Down
16 changes: 8 additions & 8 deletions ngui/ui/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down Expand Up @@ -205,9 +207,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();

Expand All @@ -227,7 +227,7 @@ const Table = ({
pageIndex: table.getState().pagination.pageIndex,
pageSize: table.getState().pagination.pageSize,
onPageIndexChange: table.setPageIndex,
totalRows: data.length
totalRows: totalRowsCount
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -76,6 +76,7 @@ const CleanExpensesBreakdownContainer = ({ requestParams }) => {
}
downloadResources={downloadResources}
isDownloadingResources={isFileDownloading}
totalResourcesCount={totalResourcesCount}
/>
</>
);
Expand Down

0 comments on commit 1a1f2cd

Please sign in to comment.