Fleet UI: Manage Host Page disable next on pagination of if on last page of results (#7356)

This commit is contained in:
RachelElysia 2022-08-23 10:29:44 -07:00 committed by GitHub
parent 1f149a7d8d
commit 5e8f46da73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View file

@ -0,0 +1 @@
* Disable next buton for manage host page when next page has 0 results

View file

@ -78,6 +78,7 @@ import {
LABEL_SLUG_PREFIX,
DEFAULT_SORT_HEADER,
DEFAULT_SORT_DIRECTION,
DEFAULT_PAGE_SIZE,
HOST_SELECT_STATUSES,
} from "./constants";
import { isAcceptableStatus, getNextLocationPath } from "./helpers";
@ -563,6 +564,12 @@ const ManageHostsPage = ({
}
}, [availableTeams, currentTeam, location, labels]);
const isLastPage =
tableQueryData &&
!!filteredHostCount &&
DEFAULT_PAGE_SIZE * tableQueryData.pageIndex + (hosts?.length || 0) >=
filteredHostCount;
const handleLabelChange = ({ slug }: ILabel): boolean => {
if (!slug) {
return false;
@ -1889,6 +1896,7 @@ const ManageHostsPage = ({
onPrimarySelectActionClick={onDeleteHostsClick}
onQueryChange={onTableQueryChange}
toggleAllPagesSelected={toggleAllMatchingHosts}
disableNextPage={isLastPage}
/>
);
};

View file

@ -5,6 +5,7 @@ export const LABEL_SLUG_PREFIX = "labels/";
export const DEFAULT_SORT_HEADER = "hostname";
export const DEFAULT_SORT_DIRECTION = "asc";
export const DEFAULT_PAGE_SIZE = 20;
export const HOST_SELECT_STATUSES = [
{