Skip to content

Commit 92daa52

Browse files
committed
chore: rename props for clarity
1 parent 4547519 commit 92daa52

File tree

6 files changed

+36
-38
lines changed

6 files changed

+36
-38
lines changed

site/src/components/PaginationWidget/PaginationNavButtons.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import { useTheme } from "@emotion/react";
1313

1414
type NavProps = {
1515
currentPage: number;
16-
onChange: (newPage: number) => void;
16+
onPageChange: (newPage: number) => void;
1717
};
1818

19-
export function LeftNavButton({ currentPage, onChange }: NavProps) {
19+
export function LeftNavButton({ currentPage, onPageChange }: NavProps) {
2020
const isFirstPage = currentPage <= 1;
2121

2222
return (
@@ -26,7 +26,7 @@ export function LeftNavButton({ currentPage, onChange }: NavProps) {
2626
aria-label="Previous page"
2727
onClick={() => {
2828
if (!isFirstPage) {
29-
onChange(currentPage - 1);
29+
onPageChange(currentPage - 1);
3030
}
3131
}}
3232
>
@@ -35,7 +35,7 @@ export function LeftNavButton({ currentPage, onChange }: NavProps) {
3535
);
3636
}
3737

38-
export function RightNavButton({ currentPage, onChange }: NavProps) {
38+
export function RightNavButton({ currentPage, onPageChange }: NavProps) {
3939
const isLastPage = currentPage <= 1;
4040

4141
return (
@@ -45,7 +45,7 @@ export function RightNavButton({ currentPage, onChange }: NavProps) {
4545
aria-label="Previous page"
4646
onClick={() => {
4747
if (!isLastPage) {
48-
onChange(currentPage + 1);
48+
onPageChange(currentPage + 1);
4949
}
5050
}}
5151
>

site/src/components/PaginationWidget/PaginationWidgetBase.stories.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const meta: Meta<typeof PaginationWidgetBase> = {
55
title: "components/PaginationWidgetBase",
66
component: PaginationWidgetBase,
77
args: {
8-
page: 1,
9-
limit: 12,
10-
count: 200,
8+
currentPage: 1,
9+
pageSize: 12,
10+
totalRecords: 200,
1111
},
1212
};
1313

@@ -17,19 +17,17 @@ type Story = StoryObj<typeof PaginationWidgetBase>;
1717
export const MoreThan8Pages: Story = {};
1818

1919
export const LessThan8Pages: Story = {
20-
args: {
21-
count: 84,
22-
},
20+
args: { totalRecords: 84 },
2321
};
2422

2523
export const MoreThan7PagesWithActivePageCloseToStart: Story = {
26-
args: { page: 2, limit: 12 },
24+
args: { currentPage: 2, pageSize: 12 },
2725
};
2826

2927
export const MoreThan7PagesWithActivePageFarFromBoundaries: Story = {
30-
args: { page: 4, limit: 12 },
28+
args: { currentPage: 4, pageSize: 12 },
3129
};
3230

3331
export const MoreThan7PagesWithActivePageCloseToEnd: Story = {
34-
args: { page: 17, limit: 12 },
32+
args: { currentPage: 17, pageSize: 12 },
3533
};

site/src/components/PaginationWidget/PaginationWidgetBase.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ import { buildPagedList } from "./utils";
66
import { LeftNavButton, RightNavButton } from "./PaginationNavButtons";
77

88
export type PaginationWidgetBaseProps = {
9-
count: number;
10-
page: number;
11-
limit: number;
12-
onChange: (newPage: number) => void;
9+
currentPage: number;
10+
pageSize: number;
11+
totalRecords: number;
12+
onPageChange: (newPage: number) => void;
1313
};
1414

1515
export const PaginationWidgetBase = ({
16-
count,
17-
limit,
18-
onChange,
19-
page: currentPage,
16+
currentPage,
17+
pageSize,
18+
totalRecords,
19+
onPageChange,
2020
}: PaginationWidgetBaseProps) => {
2121
const theme = useTheme();
2222
const isMobile = useMediaQuery(theme.breakpoints.down("md"));
23-
const totalPages = Math.ceil(count / limit);
23+
const totalPages = Math.ceil(totalRecords / pageSize);
2424

2525
if (totalPages < 2) {
2626
return null;
@@ -37,7 +37,7 @@ export const PaginationWidgetBase = ({
3737
columnGap: "6px",
3838
}}
3939
>
40-
<LeftNavButton currentPage={currentPage} onChange={onChange} />
40+
<LeftNavButton currentPage={currentPage} onPageChange={onPageChange} />
4141

4242
{isMobile ? (
4343
<NumberedPageButton
@@ -49,11 +49,11 @@ export const PaginationWidgetBase = ({
4949
<PaginationRow
5050
currentPage={currentPage}
5151
totalPages={totalPages}
52-
onChange={onChange}
52+
onChange={onPageChange}
5353
/>
5454
)}
5555

56-
<RightNavButton currentPage={currentPage} onChange={onChange} />
56+
<RightNavButton currentPage={currentPage} onPageChange={onPageChange} />
5757
</div>
5858
);
5959
};

site/src/pages/AuditPage/AuditPageView.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ export const AuditPageView: FC<AuditPageViewProps> = ({
133133

134134
{count !== undefined && (
135135
<PaginationWidgetBase
136-
count={count}
137-
limit={limit}
138-
onChange={onPageChange}
139-
page={page}
136+
totalRecords={count}
137+
pageSize={limit}
138+
onPageChange={onPageChange}
139+
currentPage={page}
140140
/>
141141
)}
142142
</Cond>

site/src/pages/UsersPage/UsersPageView.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ export const UsersPageView: FC<React.PropsWithChildren<UsersPageViewProps>> = ({
102102

103103
{count && (
104104
<PaginationWidgetBase
105-
count={count}
106-
limit={limit}
107-
onChange={onPageChange}
108-
page={page}
105+
totalRecords={count}
106+
pageSize={limit}
107+
onPageChange={onPageChange}
108+
currentPage={page}
109109
/>
110110
)}
111111
</>

site/src/pages/WorkspacesPage/WorkspacesPageView.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ export const WorkspacesPageView = ({
161161

162162
{count !== undefined && (
163163
<PaginationWidgetBase
164-
count={count}
165-
limit={limit}
166-
onChange={onPageChange}
167-
page={page}
164+
totalRecords={count}
165+
pageSize={limit}
166+
onPageChange={onPageChange}
167+
currentPage={page}
168168
/>
169169
)}
170170
</Margins>

0 commit comments

Comments
 (0)