Skip to content

Commit 9868d7c

Browse files
tvijay-akamaigrevanak-akamaiabailly-akamai
authored
feat: [UIE-9441] implemented pagination for Plans table (#13055)
* feat: [UIE-9441] implemented pagination for Plans table * feat: [UIE-9441] addressed review comments * feat: [UIE-9441] added changeset * feat: [UIE-9441] review comments * feat: [UIE-9441] review comments * feat: [UIE-9441] review comments * Self feedback --------- Co-authored-by: grevanak-akamai <[email protected]> Co-authored-by: Alban Bailly <[email protected]> Co-authored-by: Alban Bailly <[email protected]>
1 parent aae562d commit 9868d7c

File tree

8 files changed

+535
-206
lines changed

8 files changed

+535
-206
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Added
3+
---
4+
5+
Implement pagination for Plans table ([#13055](https://github.com/linode/manager/pull/13055))

packages/manager/src/components/PaginationFooter/PaginationFooter.test.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import { screen } from '@testing-library/react';
2+
import userEvent from '@testing-library/user-event';
3+
import React from 'react';
4+
5+
import { renderWithTheme } from 'src/utilities/testHelpers';
6+
7+
import { PaginationFooter } from './PaginationFooter';
18
import { PAGE_SIZES } from './PaginationFooter.constants';
29
import { getMinimumPageSizeForNumberOfItems } from './PaginationFooter.utils';
310

@@ -13,3 +20,27 @@ describe('getMinimumPageSizeForNumberOfItems', () => {
1320
expect(getMinimumPageSizeForNumberOfItems(100, [25, 50])).toBe(Infinity);
1421
});
1522
});
23+
24+
describe('PaginationFooter component', () => {
25+
it('renders custom page size options when provided', async () => {
26+
renderWithTheme(
27+
<PaginationFooter
28+
count={150}
29+
customOptions={[
30+
{ label: 'Show 15', value: 15 },
31+
{ label: 'Show 25', value: 25 },
32+
]}
33+
handlePageChange={vi.fn()}
34+
handleSizeChange={vi.fn()}
35+
page={1}
36+
pageSize={15}
37+
/>
38+
);
39+
40+
const select = screen.getByLabelText('Number of items to show');
41+
await userEvent.click(select);
42+
43+
expect(screen.getByRole('option', { name: 'Show 15' })).toBeVisible();
44+
expect(screen.getByRole('option', { name: 'Show 25' })).toBeVisible();
45+
});
46+
});

packages/manager/src/components/PaginationFooter/PaginationFooter.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ export interface PaginationProps {
1717
sx?: SxProps;
1818
}
1919

20+
interface PaginationOption {
21+
label: string;
22+
value: number;
23+
}
24+
2025
interface Props extends PaginationProps {
26+
customOptions?: PaginationOption[];
2127
handlePageChange: (page: number) => void;
2228
handleSizeChange: (pageSize: number) => void;
2329
}
@@ -33,6 +39,7 @@ export const PaginationFooter = (props: Props) => {
3339
const theme = useTheme();
3440
const {
3541
count,
42+
customOptions,
3643
fixedSize,
3744
handlePageChange,
3845
handleSizeChange,
@@ -46,7 +53,7 @@ export const PaginationFooter = (props: Props) => {
4653
return null;
4754
}
4855

49-
const finalOptions = [...baseOptions];
56+
const finalOptions = [...(customOptions ?? baseOptions)];
5057

5158
// Add "Show All" to the list of options if the consumer has so specified.
5259
if (showAll) {

0 commit comments

Comments
 (0)