Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: create centralized Pagination component #10911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 92 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
b4211f3
wip: commit current progress on usePaginatedQuery
Parkreiner Nov 13, 2023
173e823
chore: add cacheTime to users query
Parkreiner Nov 13, 2023
d715d73
chore: update cache logic for UsersPage usersQuery
Parkreiner Nov 13, 2023
8a199b7
wip: commit progress on Pagination
Parkreiner Nov 13, 2023
98ae96d
chore: add function overloads to prepareQuery
Parkreiner Nov 13, 2023
37ea50b
wip: commit progress on usePaginatedQuery
Parkreiner Nov 14, 2023
2c1e9e3
docs: add clarifying comment about implementation
Parkreiner Nov 14, 2023
b3a9ab4
chore: remove optional prefetch property from query options
Parkreiner Nov 15, 2023
39a2ced
chore: redefine queryKey
Parkreiner Nov 15, 2023
4dcfd29
refactor: consolidate how queryKey/queryFn are called
Parkreiner Nov 15, 2023
86f8437
refactor: clean up pagination code more
Parkreiner Nov 15, 2023
f612d8f
fix: remove redundant properties
Parkreiner Nov 15, 2023
5878326
refactor: clean up code
Parkreiner Nov 15, 2023
5cc1c2d
wip: commit progress on usePaginatedQuery
Parkreiner Nov 15, 2023
0138f21
wip: commit current pagination progress
Parkreiner Nov 15, 2023
a38fd30
docs: clean up comments for clarity
Parkreiner Nov 17, 2023
22d6c24
wip: get type signatures compatible (breaks runtime logic slightly)
Parkreiner Nov 20, 2023
e717da1
refactor: clean up type definitions
Parkreiner Nov 20, 2023
7624d94
chore: add support for custom onInvalidPage functions
Parkreiner Nov 20, 2023
2623131
refactor: clean up type definitions more for clarity reasons
Parkreiner Nov 20, 2023
29242e9
chore: delete Pagination component (separate PR)
Parkreiner Nov 20, 2023
5a9aa2d
chore: remove cacheTime fixes (to be resolved in future PR)
Parkreiner Nov 20, 2023
3d67304
docs: add clarifying/intellisense comments for DX
Parkreiner Nov 20, 2023
d977060
refactor: link users queries to same queryKey implementation
Parkreiner Nov 20, 2023
9224624
docs: remove misleading comment
Parkreiner Nov 20, 2023
540c779
docs: more comments
Parkreiner Nov 20, 2023
4b42b6f
chore: update onInvalidPage params for more flexibility
Parkreiner Nov 20, 2023
5bc43c9
fix: remove explicit any
Parkreiner Nov 20, 2023
bd146a1
refactor: clean up type definitions
Parkreiner Nov 20, 2023
983b83f
refactor: rename query params for consistency
Parkreiner Nov 20, 2023
a43e294
refactor: clean up input validation for page changes
Parkreiner Nov 20, 2023
db03f3e
refactor/fix: update hook to be aware of async data
Parkreiner Nov 21, 2023
1b825f1
chore: add contravariance to dictionary
Parkreiner Nov 21, 2023
9631a27
refactor: increase type-safety of usePaginatedQuery
Parkreiner Nov 21, 2023
4ea0cba
docs: more comments
Parkreiner Nov 21, 2023
3f63ec7
chore: move usePaginatedQuery file
Parkreiner Nov 21, 2023
614e4ff
fix: add back cacheTime
Parkreiner Nov 21, 2023
b0c8d48
Merge branch 'main' into mes/pagination-2
Parkreiner Nov 21, 2023
e994532
chore: swap in usePaginatedQuery for users table
Parkreiner Nov 21, 2023
9502044
chore: add goToFirstPage to usePaginatedQuery
Parkreiner Nov 21, 2023
8dbbfd3
fix: make page redirects work properly
Parkreiner Nov 21, 2023
88d0a5f
refactor: clean up clamp logic
Parkreiner Nov 21, 2023
132f5b1
chore: swap in usePaginatedQuery for Audits table
Parkreiner Nov 21, 2023
33bf4e8
refactor: move dependencies around
Parkreiner Nov 21, 2023
218da68
fix: remove deprecated properties from hook
Parkreiner Nov 21, 2023
54f01f1
refactor: clean up code more
Parkreiner Nov 21, 2023
ede2abc
docs: add todo comment
Parkreiner Nov 21, 2023
9ecab16
chore: update testing fixtures
Parkreiner Nov 21, 2023
0c81d1c
wip: commit current progress for tests
Parkreiner Nov 21, 2023
3aa714c
fix: update useEffectEvent to sync via layout effects
Parkreiner Nov 21, 2023
2893630
wip: commit more progress on tests
Parkreiner Nov 21, 2023
ef900d4
wip: stub out all expected test cases
Parkreiner Nov 21, 2023
23dc583
wip: more test progress
Parkreiner Nov 22, 2023
24361d1
wip: more test progress
Parkreiner Nov 22, 2023
755f8c0
wip: commit more test progress
Parkreiner Nov 22, 2023
8bff0d3
wip: AHHHHHHHH
Parkreiner Nov 22, 2023
1fae773
chore: finish two more test cases
Parkreiner Nov 22, 2023
be82728
wip: add in all tests (still need to investigate prefetching
Parkreiner Nov 22, 2023
848fa0f
refactor: clean up code slightly
Parkreiner Nov 22, 2023
c89e8e3
fix: remove math bugs when calculating pages
Parkreiner Nov 22, 2023
3624a6d
fix: wrap up all testing and clean up cases
Parkreiner Nov 22, 2023
13e2f30
docs: update comments for clarity
Parkreiner Nov 22, 2023
8f83673
fix: update error-handling for invalid page handling
Parkreiner Nov 24, 2023
2b111a6
wip: commit progress for auto-scroll container
Parkreiner Nov 24, 2023
e9a99d4
chore: integrate pagination into users table
Parkreiner Nov 24, 2023
5bf5b9c
wip: commit current progress on scroll logic
Parkreiner Nov 24, 2023
9eebb20
wip: more attempts
Parkreiner Nov 25, 2023
3d39835
wip: more progress
Parkreiner Nov 25, 2023
d817cc5
wip: more progress
Parkreiner Nov 25, 2023
d36dca7
refactor: clean up scroll sync logic
Parkreiner Nov 27, 2023
3961ec1
docs: add big comment explainign syncScrollChange
Parkreiner Nov 27, 2023
c7e94dd
fix: make sure effects run properly
Parkreiner Nov 27, 2023
66fc6ba
fix: finalize effect sync logic
Parkreiner Nov 27, 2023
7d660a4
fix: add on-mount logic for effects
Parkreiner Nov 27, 2023
a03e167
fix: remove autoScroll property (not a good enough use case)
Parkreiner Nov 27, 2023
4ffacfb
refactor: clean up code
Parkreiner Nov 27, 2023
e98ab1b
fix: make disabled messages have consistent verbage
Parkreiner Nov 27, 2023
8fb2703
refactor: quarantine useEffect evil
Parkreiner Nov 27, 2023
1fea4bc
refactor: revise Pagination implementation
Parkreiner Nov 27, 2023
12b3790
chore: get Pagination component integrated into users table
Parkreiner Nov 27, 2023
b736e0d
refactor: make updated stories happy
Parkreiner Nov 27, 2023
71cd29f
fix: update renderComponent to support proper re-renders
Parkreiner Nov 28, 2023
d0bd797
wip: commit current test progress
Parkreiner Nov 28, 2023
07097b1
chore: finish Pagination tests
Parkreiner Nov 28, 2023
43cb93a
fix: beef up test to check for every possible user event
Parkreiner Nov 28, 2023
80c88bb
fix: remove stray line of code
Parkreiner Nov 28, 2023
b4abf11
refactor: change timing for Pagination.test (just to improve assurity)
Parkreiner Nov 28, 2023
983915b
fix: update logic for calculating disabled statuses
Parkreiner Nov 28, 2023
beccc68
refactor: split off PaginationHeader into separate file
Parkreiner Nov 28, 2023
982a8c4
fix: switch AuditPage to use Pagination component
Parkreiner Nov 28, 2023
73c24a0
fix: update stories for audit page
Parkreiner Nov 28, 2023
a5fc929
fix: update vertical spacing for workspaces table
Parkreiner Nov 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: remove autoScroll property (not a good enough use case)
  • Loading branch information
Parkreiner committed Nov 27, 2023
commit a03e1673059973fcdbffa41514a518a57697a670
18 changes: 5 additions & 13 deletions site/src/components/PaginationWidget/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type PaginationProps = HTMLAttributes<HTMLDivElement> & {
pageSize: number;
totalRecords: number | undefined;
onPageChange: (newPage: number) => void;
autoScroll?: boolean;

/**
* Meant to interface with useQuery's isPreviousData property.
Expand All @@ -40,7 +39,6 @@ export const Pagination: FC<PaginationProps> = ({
totalRecords,
showingPreviousData,
onPageChange,
autoScroll = true,
...delegatedProps
}) => {
const scrollContainerRef = useRef<HTMLDivElement>(null);
Expand All @@ -49,10 +47,6 @@ export const Pagination: FC<PaginationProps> = ({
// Sets up event handlers for canceling queued scrolls in response to
// literally any user behavior
useEffect(() => {
if (!autoScroll) {
return;
}

const cancelScroll = () => {
isScrollingQueuedRef.current = false;
};
Expand All @@ -66,7 +60,7 @@ export const Pagination: FC<PaginationProps> = ({
window.removeEventListener(event, cancelScroll);
}
};
}, [autoScroll]);
}, []);

/**
* Have to account for for five different triggers to determine when the
Expand All @@ -93,12 +87,10 @@ export const Pagination: FC<PaginationProps> = ({
* this use case doesn't line up that well with useEffect's API
*/
const syncScrollPosition = useEffectEvent(() => {
if (autoScroll) {
scrollContainerRef.current?.scrollIntoView({
block: "start",
behavior: "instant",
});
}
scrollContainerRef.current?.scrollIntoView({
block: "start",
behavior: "instant",
});

isScrollingQueuedRef.current = false;
});
Expand Down