Skip to content

Commit 454420d

Browse files
author
Ahmed Hamouda
committed
feat(storage): add pagination test page for StorageBrowser component
1 parent 59c66c6 commit 454420d

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import React, { useState } from 'react';
2+
import { Amplify } from 'aws-amplify';
3+
4+
import { Flex, View, SelectField, Text, Alert } from '@aws-amplify/ui-react';
5+
import { StorageBrowser } from '@aws-amplify/ui-react-storage';
6+
import config from './aws-exports';
7+
8+
import '@aws-amplify/ui-react-storage/styles.css';
9+
10+
Amplify.configure(config);
11+
12+
function PaginationTest() {
13+
const [pageSize, setPageSize] = useState<number>(10);
14+
const [showPagination, setShowPagination] = useState<boolean>(false);
15+
const [showAlert, setShowAlert] = useState(true);
16+
17+
const pageSizeOptions = [
18+
{ value: 5, label: '5 items per page' },
19+
{ value: 10, label: '10 items per page' },
20+
{ value: 25, label: '25 items per page' },
21+
{ value: 50, label: '50 items per page' },
22+
{ value: 100, label: '100 items per page' },
23+
];
24+
25+
return (
26+
<Flex
27+
direction="column"
28+
width="100vw"
29+
height="100vh"
30+
overflow="hidden"
31+
padding="xl"
32+
>
33+
{showAlert && (
34+
<Alert
35+
variation="info"
36+
isDismissible
37+
onDismiss={() => setShowAlert(false)}
38+
marginBlockEnd="medium"
39+
>
40+
<Text>
41+
<strong>🧪 StorageBrowser Pagination Test</strong>
42+
<br />
43+
Testing the new pageSize prop. Change the page size below and
44+
observe the pagination behavior. Check browser console for
45+
validation warnings when invalid values are used.
46+
</Text>
47+
</Alert>
48+
)}
49+
50+
<Flex
51+
justifyContent="space-between"
52+
alignItems="center"
53+
marginBlockEnd="xl"
54+
wrap="wrap"
55+
gap="medium"
56+
>
57+
<Text fontSize="xl" fontWeight="bold">
58+
StorageBrowser Pagination Test
59+
</Text>
60+
61+
<Flex alignItems="center" gap="medium">
62+
<Text fontWeight="bold">Page Size:</Text>
63+
<SelectField
64+
label=""
65+
value={pageSize.toString()}
66+
onChange={(e) => {
67+
const newPageSize = parseInt(e.target.value);
68+
setPageSize(newPageSize);
69+
console.log(`📄 Page size changed to: ${newPageSize}`);
70+
}}
71+
width="180px"
72+
>
73+
{pageSizeOptions.map(({ value, label }) => (
74+
<option key={value} value={value}>
75+
{label}
76+
</option>
77+
))}
78+
{/* Test invalid values */}
79+
<option value="0">0 (invalid - will use default)</option>
80+
<option value="1001">1001 (invalid - will use default)</option>
81+
</SelectField>
82+
83+
<label>
84+
<input
85+
type="checkbox"
86+
checked={showPagination}
87+
onChange={(e) => setShowPagination(e.target.checked)}
88+
/>
89+
<Text marginLeft="small">Show Pagination</Text>
90+
</label>
91+
</Flex>
92+
</Flex>
93+
94+
<View flex="1" overflow="hidden">
95+
<StorageBrowser
96+
key={`${pageSize}-${showPagination}`}
97+
pageSize={pageSize}
98+
showPagination={showPagination}
99+
displayText={{
100+
LocationsView: {
101+
title: `Pagination Test - ${pageSize} items per page${
102+
showPagination ? ' (with pagination)' : ''
103+
}`,
104+
},
105+
}}
106+
/>
107+
</View>
108+
</Flex>
109+
);
110+
}
111+
112+
export default PaginationTest;

0 commit comments

Comments
 (0)