1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 13:55:21 +02:00

fix(ui/datatables): sync page count with filtering [EE-5890] (#10010)

This commit is contained in:
Chaim Lev-Ari 2023-08-22 09:36:31 +03:00 committed by GitHub
parent bb646162d1
commit 5586910e9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 78 additions and 63 deletions

View file

@ -51,10 +51,10 @@ export function EdgeGroupAssociationTable({
onClickRow: (env: Environment) => void;
} & AutomationTestingProps) {
const tableState = useTableStateWithoutStorage('Name');
const [page, setPage] = useState(1);
const [page, setPage] = useState(0);
const environmentsQuery = useEnvironmentList({
pageLimit: tableState.pageSize,
page,
page: page + 1,
search: tableState.search,
sort: tableState.sortBy.id as 'Group' | 'Name',
order: tableState.sortBy.desc ? 'desc' : 'asc',
@ -87,8 +87,10 @@ export function EdgeGroupAssociationTable({
columns={columns}
settingsManager={tableState}
dataset={environments}
isServerSidePagination
page={page}
onPageChange={setPage}
pageCount={Math.ceil(totalCount / tableState.pageSize)}
totalCount={totalCount}
renderRow={(row) => (
<TableRow<DecoratedEnvironment>
cells={row.getVisibleCells()}
@ -98,7 +100,6 @@ export function EdgeGroupAssociationTable({
emptyContentLabel={emptyContentLabel}
data-cy={dataCy}
disableSelect
totalCount={totalCount}
/>
);
}

View file

@ -24,8 +24,6 @@ export function Datatable() {
search: tableState.search,
});
const pageCount = Math.ceil(totalCount / tableState.pageSize);
return (
<GenericDatatable
settingsManager={tableState}
@ -37,10 +35,10 @@ export function Datatable() {
<TableActions selectedRows={selectedRows} />
)}
isLoading={isLoading}
totalCount={totalCount}
pageCount={pageCount}
isServerSidePagination
page={page}
onPageChange={setPage}
totalCount={totalCount}
description={<Filter />}
/>
);

View file

@ -40,7 +40,7 @@ export function EnvironmentsDatatable() {
(value) => (value ? parseInt(value, 10) : undefined)
);
const tableState = useTableStateWithoutStorage('name');
const endpointsQuery = useEnvironmentList({
const environmentsQuery = useEnvironmentList({
pageLimit: tableState.pageSize,
page: page + 1,
search: tableState.search,
@ -56,7 +56,7 @@ export function EnvironmentsDatatable() {
const gitConfigCommitHash = edgeStackQuery.data?.GitConfig?.ConfigHash || '';
const environments: Array<EdgeStackEnvironment> = useMemo(
() =>
endpointsQuery.environments.map(
environmentsQuery.environments.map(
(env) =>
({
...env,
@ -72,7 +72,7 @@ export function EnvironmentsDatatable() {
[
currentFileVersion,
edgeStackQuery.data?.Status,
endpointsQuery.environments,
environmentsQuery.environments,
gitConfigCommitHash,
gitConfigURL,
]
@ -81,13 +81,15 @@ export function EnvironmentsDatatable() {
return (
<Datatable
columns={columns}
isLoading={endpointsQuery.isLoading}
isLoading={environmentsQuery.isLoading}
dataset={environments}
settingsManager={tableState}
title="Environments Status"
titleIcon={HardDrive}
isServerSidePagination
page={page}
onPageChange={setPage}
totalCount={endpointsQuery.totalCount}
totalCount={environmentsQuery.totalCount}
emptyContentLabel="No environment available."
disableSelect
description={