Skip to content

Commit 423d463

Browse files
committed
added static values for RTL demo
1 parent 0e7a70f commit 423d463

File tree

3 files changed

+191
-45
lines changed

3 files changed

+191
-45
lines changed

packages/react-core/src/demos/RTL/RTL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
1818
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
1919
import HandPaperIcon from '@patternfly/react-icons/dist/esm/icons/hand-paper-icon';
2020
import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg';
21+
import { rows } from '@patternfly/react-core/dist/esm/demos/sampleData2';
2122

2223
import './examples/PaginatedTable.css';
2324

packages/react-core/src/demos/RTL/examples/PaginatedTable.tsx

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
5555
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
5656
import HandPaperIcon from '@patternfly/react-icons/dist/esm/icons/hand-paper-icon';
5757
import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg';
58+
import { rows } from '@patternfly/react-core/dist/esm/demos/sampleData2';
5859

5960
interface Row {
6061
name: string;
@@ -81,45 +82,6 @@ export const PaginatedTableAction: React.FunctionComponent = () => {
8182
translation.table.columns.url
8283
];
8384

84-
const numRows: number = 25;
85-
const getRandomInteger = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1)) + min;
86-
const createRows = () => {
87-
const rows: Row[] = [];
88-
for (let i = 0; i < numRows; i++) {
89-
const num = i + 1;
90-
const rowObj: Row = {
91-
name: translation.table.rows.node + num,
92-
status: [
93-
translation.table.rows.status.stopped,
94-
translation.table.rows.status.running,
95-
translation.table.rows.status.down,
96-
translation.table.rows.status.needsMaintenance
97-
][getRandomInteger(0, 3)],
98-
location: [
99-
translation.table.rows.locations.raleigh,
100-
translation.table.rows.locations.boston,
101-
translation.table.rows.locations.atlanta,
102-
translation.table.rows.locations.sanFrancisco
103-
][getRandomInteger(0, 3)],
104-
lastModified: [
105-
translation.table.rows.lastModified.oneHr,
106-
translation.table.rows.lastModified.threeHrs,
107-
translation.table.rows.lastModified.fiveHrs,
108-
translation.table.rows.lastModified.sevenMins,
109-
translation.table.rows.lastModified.fortyTwoMins,
110-
translation.table.rows.lastModified.twoDays,
111-
translation.table.rows.lastModified.oneMonth
112-
][getRandomInteger(0, 6)],
113-
url: 'http://www.redhat.com/en/office-locations/node' + num
114-
};
115-
rows.push(rowObj);
116-
}
117-
118-
return rows;
119-
};
120-
121-
const rows = createRows();
122-
const [managedRows, setManagedRows] = useState(rows);
12385
const [paginatedRows, setPaginatedRows] = useState<Row[]>(rows.slice(0, 10));
12486
const [isDirRTL, setIsDirRTL] = useState<boolean>(false);
12587

@@ -131,9 +93,7 @@ export const PaginatedTableAction: React.FunctionComponent = () => {
13193
};
13294

13395
useEffect(() => {
134-
const newRows = createRows();
135-
setManagedRows(newRows);
136-
setPaginatedRows(newRows.slice((page - 1) * perPage, page * perPage));
96+
setPaginatedRows(rows.slice((page - 1) * perPage, page * perPage));
13797
}, [translation]);
13898

13999
useEffect(() => {
@@ -150,7 +110,7 @@ export const PaginatedTableAction: React.FunctionComponent = () => {
150110
startIdx: number | undefined,
151111
endIdx: number | undefined
152112
) => {
153-
setPaginatedRows(managedRows.slice(startIdx, endIdx));
113+
setPaginatedRows(rows.slice(startIdx, endIdx));
154114
setPage(newPage);
155115
};
156116

@@ -161,7 +121,7 @@ export const PaginatedTableAction: React.FunctionComponent = () => {
161121
startIdx: number | undefined,
162122
endIdx: number | undefined
163123
) => {
164-
setPaginatedRows(managedRows.slice(startIdx, endIdx));
124+
setPaginatedRows(rows.slice(startIdx, endIdx));
165125
setPerPage(newPerPage);
166126
};
167127

@@ -170,7 +130,7 @@ export const PaginatedTableAction: React.FunctionComponent = () => {
170130

171131
return (
172132
<Pagination
173-
itemCount={managedRows.length}
133+
itemCount={rows.length}
174134
page={page}
175135
perPage={perPage}
176136
onSetPage={handleSetPage}
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
export interface SampleRowData {
2+
name: string;
3+
status: string;
4+
location: string;
5+
lastModified: string;
6+
url: string;
7+
}
8+
9+
export const rows: SampleRowData[] = [
10+
{
11+
name: `Node1`,
12+
status: 'Running',
13+
location: 'Raleigh',
14+
lastModified: '1 hour ago',
15+
url: 'http://www.redhat.com/en/office-locations/node1'
16+
},
17+
{
18+
name: `Node2`,
19+
status: 'Stopped',
20+
location: 'Boston',
21+
lastModified: '3 hours ago',
22+
url: 'http://www.redhat.com/en/office-locations/node2'
23+
},
24+
{
25+
name: `Node3`,
26+
status: 'Down',
27+
location: 'Atlanta',
28+
lastModified: '5 hours ago',
29+
url: 'http://www.redhat.com/en/office-locations/node3'
30+
},
31+
{
32+
name: `Node4`,
33+
status: 'Needs maintenance',
34+
location: 'San Francisco',
35+
lastModified: '7 minutes ago',
36+
url: 'http://www.redhat.com/en/office-locations/node4'
37+
},
38+
{
39+
name: `Node5`,
40+
status: 'Running',
41+
location: 'Raleigh',
42+
lastModified: '42 minutes ago',
43+
url: 'http://www.redhat.com/en/office-locations/node5'
44+
},
45+
{
46+
name: `Node6`,
47+
status: 'Stopped',
48+
location: 'Boston',
49+
lastModified: '2 days ago',
50+
url: 'http://www.redhat.com/en/office-locations/node6'
51+
},
52+
{
53+
name: `Node7`,
54+
status: 'Down',
55+
location: 'Atlanta',
56+
lastModified: '1 month ago',
57+
url: 'http://www.redhat.com/en/office-locations/node7'
58+
},
59+
{
60+
name: `Node8`,
61+
status: 'Needs maintenance',
62+
location: 'San Francisco',
63+
lastModified: '1 hour ago',
64+
url: 'http://www.redhat.com/en/office-locations/node8'
65+
},
66+
{
67+
name: `Node9`,
68+
status: 'Running',
69+
location: 'Raleigh',
70+
lastModified: '3 hours ago',
71+
url: 'http://www.redhat.com/en/office-locations/node9'
72+
},
73+
{
74+
name: `Node10`,
75+
status: 'Stopped',
76+
location: 'Boston',
77+
lastModified: '5 hours ago',
78+
url: 'http://www.redhat.com/en/office-locations/node10'
79+
},
80+
{
81+
name: `Node11`,
82+
status: 'Down',
83+
location: 'Atlanta',
84+
lastModified: '7 minutes ago',
85+
url: 'http://www.redhat.com/en/office-locations/node11'
86+
},
87+
{
88+
name: `Node12`,
89+
status: 'Needs maintenance',
90+
location: 'San Francisco',
91+
lastModified: '42 minutes ago',
92+
url: 'http://www.redhat.com/en/office-locations/node12'
93+
},
94+
{
95+
name: `Node13`,
96+
status: 'Running',
97+
location: 'Raleigh',
98+
lastModified: '2 days ago',
99+
url: 'http://www.redhat.com/en/office-locations/node13'
100+
},
101+
{
102+
name: `Node14`,
103+
status: 'Stopped',
104+
location: 'Boston',
105+
lastModified: '1 month ago',
106+
url: 'http://www.redhat.com/en/office-locations/node14'
107+
},
108+
{
109+
name: `Node15`,
110+
status: 'Down',
111+
location: 'Atlanta',
112+
lastModified: '1 hour ago',
113+
url: 'http://www.redhat.com/en/office-locations/node15'
114+
},
115+
{
116+
name: `Node16`,
117+
status: 'Needs maintenance',
118+
location: 'San Francisco',
119+
lastModified: '3 hours ago',
120+
url: 'http://www.redhat.com/en/office-locations/node16'
121+
},
122+
{
123+
name: `Node17`,
124+
status: 'Running',
125+
location: 'Raleigh',
126+
lastModified: '5 hours ago',
127+
url: 'http://www.redhat.com/en/office-locations/node17'
128+
},
129+
{
130+
name: `Node18`,
131+
status: 'Stopped',
132+
location: 'Boston',
133+
lastModified: '7 minutes ago',
134+
url: 'http://www.redhat.com/en/office-locations/node18'
135+
},
136+
{
137+
name: `Node19`,
138+
status: 'Down',
139+
location: 'Atlanta',
140+
lastModified: '42 minutes ago',
141+
url: 'http://www.redhat.com/en/office-locations/node19'
142+
},
143+
{
144+
name: `Node20`,
145+
status: 'Needs maintenance',
146+
location: 'San Francisco',
147+
lastModified: '2 days ago',
148+
url: 'http://www.redhat.com/en/office-locations/node20'
149+
},
150+
{
151+
name: `Node21`,
152+
status: 'Running',
153+
location: 'Raleigh',
154+
lastModified: '1 month ago',
155+
url: 'http://www.redhat.com/en/office-locations/node21'
156+
},
157+
{
158+
name: `Node22`,
159+
status: 'Stopped',
160+
location: 'Boston',
161+
lastModified: '1 hour ago',
162+
url: 'http://www.redhat.com/en/office-locations/node22'
163+
},
164+
{
165+
name: `Node23`,
166+
status: 'Down',
167+
location: 'Atlanta',
168+
lastModified: '3 hours ago',
169+
url: 'http://www.redhat.com/en/office-locations/node23'
170+
},
171+
{
172+
name: `Node24`,
173+
status: 'Needs maintenance',
174+
location: 'San Francisco',
175+
lastModified: '5 hours ago',
176+
url: 'http://www.redhat.com/en/office-locations/node24'
177+
},
178+
{
179+
name: `Node25`,
180+
status: 'Running',
181+
location: 'Raleigh',
182+
lastModified: '7 minutes ago',
183+
url: 'http://www.redhat.com/en/office-locations/node25'
184+
}
185+
];

0 commit comments

Comments
 (0)