Skip to content

Commit c8b132e

Browse files
committed
added static values for RTL demo
1 parent 15aeffd commit c8b132e

File tree

2 files changed

+90
-104
lines changed

2 files changed

+90
-104
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ export const PaginatedTableAction: React.FunctionComponent = () => {
8282
translation.table.columns.url
8383
];
8484

85+
const generateRowsFromTranslation = (translation: Translation): Row[] =>
86+
rows.map((row, index) => ({
87+
name: `${translation.table.rows.node}${index + 1}`,
88+
status: translation.table.rows.status[row.status],
89+
location: translation.table.rows.locations[row.location],
90+
lastModified: translation.table.rows.lastModified[row.lastModified],
91+
url: row.url
92+
}));
93+
8594
const [paginatedRows, setPaginatedRows] = useState<Row[]>(rows.slice(0, 10));
8695
const [isDirRTL, setIsDirRTL] = useState<boolean>(false);
8796

@@ -93,7 +102,8 @@ export const PaginatedTableAction: React.FunctionComponent = () => {
93102
};
94103

95104
useEffect(() => {
96-
setPaginatedRows(rows.slice((page - 1) * perPage, page * perPage));
105+
const fullRows = generateRowsFromTranslation(translation);
106+
setPaginatedRows(fullRows.slice((page - 1) * perPage, page * perPage));
97107
}, [translation]);
98108

99109
useEffect(() => {
@@ -110,7 +120,8 @@ export const PaginatedTableAction: React.FunctionComponent = () => {
110120
startIdx: number | undefined,
111121
endIdx: number | undefined
112122
) => {
113-
setPaginatedRows(rows.slice(startIdx, endIdx));
123+
const fullRows = generateRowsFromTranslation(translation);
124+
setPaginatedRows(fullRows.slice(startIdx, endIdx));
114125
setPage(newPage);
115126
};
116127

@@ -121,7 +132,8 @@ export const PaginatedTableAction: React.FunctionComponent = () => {
121132
startIdx: number | undefined,
122133
endIdx: number | undefined
123134
) => {
124-
setPaginatedRows(rows.slice(startIdx, endIdx));
135+
const fullRows = generateRowsFromTranslation(translation);
136+
setPaginatedRows(fullRows.slice(startIdx, endIdx));
125137
setPerPage(newPerPage);
126138
};
127139

Lines changed: 75 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export interface SampleRowData {
2-
name: string;
32
status: string;
43
location: string;
54
lastModified: string;
@@ -8,178 +7,153 @@ export interface SampleRowData {
87

98
export const rows: SampleRowData[] = [
109
{
11-
name: `Node1`,
12-
status: 'Running',
13-
location: 'Raleigh',
14-
lastModified: '1 hour ago',
10+
status: 'running',
11+
location: 'raleigh',
12+
lastModified: 'oneHr',
1513
url: 'http://www.redhat.com/en/office-locations/node1'
1614
},
1715
{
18-
name: `Node2`,
19-
status: 'Stopped',
20-
location: 'Boston',
21-
lastModified: '3 hours ago',
16+
status: 'stopped',
17+
location: 'boston',
18+
lastModified: 'threeHrs',
2219
url: 'http://www.redhat.com/en/office-locations/node2'
2320
},
2421
{
25-
name: `Node3`,
26-
status: 'Down',
27-
location: 'Atlanta',
28-
lastModified: '5 hours ago',
22+
status: 'down',
23+
location: 'atlanta',
24+
lastModified: 'fiveHrs',
2925
url: 'http://www.redhat.com/en/office-locations/node3'
3026
},
3127
{
32-
name: `Node4`,
33-
status: 'Needs maintenance',
34-
location: 'San Francisco',
35-
lastModified: '7 minutes ago',
28+
status: 'needsMaintenance',
29+
location: 'sanFrancisco',
30+
lastModified: 'sevenMins',
3631
url: 'http://www.redhat.com/en/office-locations/node4'
3732
},
3833
{
39-
name: `Node5`,
40-
status: 'Running',
41-
location: 'Raleigh',
42-
lastModified: '42 minutes ago',
34+
status: 'running',
35+
location: 'raleigh',
36+
lastModified: 'fortyTwoMins',
4337
url: 'http://www.redhat.com/en/office-locations/node5'
4438
},
4539
{
46-
name: `Node6`,
47-
status: 'Stopped',
48-
location: 'Boston',
49-
lastModified: '2 days ago',
40+
status: 'stopped',
41+
location: 'boston',
42+
lastModified: 'twoDays',
5043
url: 'http://www.redhat.com/en/office-locations/node6'
5144
},
5245
{
53-
name: `Node7`,
54-
status: 'Down',
55-
location: 'Atlanta',
56-
lastModified: '1 month ago',
46+
status: 'down',
47+
location: 'atlanta',
48+
lastModified: 'oneMonth',
5749
url: 'http://www.redhat.com/en/office-locations/node7'
5850
},
5951
{
60-
name: `Node8`,
61-
status: 'Needs maintenance',
62-
location: 'San Francisco',
63-
lastModified: '1 hour ago',
52+
status: 'needsMaintenance',
53+
location: 'sanFrancisco',
54+
lastModified: 'oneHr',
6455
url: 'http://www.redhat.com/en/office-locations/node8'
6556
},
6657
{
67-
name: `Node9`,
68-
status: 'Running',
69-
location: 'Raleigh',
70-
lastModified: '3 hours ago',
58+
status: 'running',
59+
location: 'raleigh',
60+
lastModified: 'threeHrs',
7161
url: 'http://www.redhat.com/en/office-locations/node9'
7262
},
7363
{
74-
name: `Node10`,
75-
status: 'Stopped',
76-
location: 'Boston',
77-
lastModified: '5 hours ago',
64+
status: 'stopped',
65+
location: 'boston',
66+
lastModified: 'fiveHrs',
7867
url: 'http://www.redhat.com/en/office-locations/node10'
7968
},
8069
{
81-
name: `Node11`,
82-
status: 'Down',
83-
location: 'Atlanta',
84-
lastModified: '7 minutes ago',
70+
status: 'down',
71+
location: 'atlanta',
72+
lastModified: 'sevenMins',
8573
url: 'http://www.redhat.com/en/office-locations/node11'
8674
},
8775
{
88-
name: `Node12`,
89-
status: 'Needs maintenance',
90-
location: 'San Francisco',
91-
lastModified: '42 minutes ago',
76+
status: 'needsMaintenance',
77+
location: 'sanFrancisco',
78+
lastModified: 'fortyTwoMins',
9279
url: 'http://www.redhat.com/en/office-locations/node12'
9380
},
9481
{
95-
name: `Node13`,
96-
status: 'Running',
97-
location: 'Raleigh',
98-
lastModified: '2 days ago',
82+
status: 'running',
83+
location: 'raleigh',
84+
lastModified: 'twoDays',
9985
url: 'http://www.redhat.com/en/office-locations/node13'
10086
},
10187
{
102-
name: `Node14`,
103-
status: 'Stopped',
104-
location: 'Boston',
105-
lastModified: '1 month ago',
88+
status: 'stopped',
89+
location: 'boston',
90+
lastModified: 'oneMonth',
10691
url: 'http://www.redhat.com/en/office-locations/node14'
10792
},
10893
{
109-
name: `Node15`,
110-
status: 'Down',
111-
location: 'Atlanta',
112-
lastModified: '1 hour ago',
94+
status: 'down',
95+
location: 'atlanta',
96+
lastModified: 'oneHr',
11397
url: 'http://www.redhat.com/en/office-locations/node15'
11498
},
11599
{
116-
name: `Node16`,
117-
status: 'Needs maintenance',
118-
location: 'San Francisco',
119-
lastModified: '3 hours ago',
100+
status: 'needsMaintenance',
101+
location: 'sanFrancisco',
102+
lastModified: 'threeHrs',
120103
url: 'http://www.redhat.com/en/office-locations/node16'
121104
},
122105
{
123-
name: `Node17`,
124-
status: 'Running',
125-
location: 'Raleigh',
126-
lastModified: '5 hours ago',
106+
status: 'running',
107+
location: 'raleigh',
108+
lastModified: 'fiveHrs',
127109
url: 'http://www.redhat.com/en/office-locations/node17'
128110
},
129111
{
130-
name: `Node18`,
131-
status: 'Stopped',
132-
location: 'Boston',
133-
lastModified: '7 minutes ago',
112+
status: 'stopped',
113+
location: 'boston',
114+
lastModified: 'sevenMins',
134115
url: 'http://www.redhat.com/en/office-locations/node18'
135116
},
136117
{
137-
name: `Node19`,
138-
status: 'Down',
139-
location: 'Atlanta',
140-
lastModified: '42 minutes ago',
118+
status: 'down',
119+
location: 'atlanta',
120+
lastModified: 'fortyTwoMins',
141121
url: 'http://www.redhat.com/en/office-locations/node19'
142122
},
143123
{
144-
name: `Node20`,
145-
status: 'Needs maintenance',
146-
location: 'San Francisco',
147-
lastModified: '2 days ago',
124+
status: 'needsMaintenance',
125+
location: 'sanFrancisco',
126+
lastModified: 'twoDays',
148127
url: 'http://www.redhat.com/en/office-locations/node20'
149128
},
150129
{
151-
name: `Node21`,
152-
status: 'Running',
153-
location: 'Raleigh',
154-
lastModified: '1 month ago',
130+
status: 'running',
131+
location: 'raleigh',
132+
lastModified: 'oneMonth',
155133
url: 'http://www.redhat.com/en/office-locations/node21'
156134
},
157135
{
158-
name: `Node22`,
159-
status: 'Stopped',
160-
location: 'Boston',
161-
lastModified: '1 hour ago',
136+
status: 'stopped',
137+
location: 'boston',
138+
lastModified: 'oneHr',
162139
url: 'http://www.redhat.com/en/office-locations/node22'
163140
},
164141
{
165-
name: `Node23`,
166-
status: 'Down',
167-
location: 'Atlanta',
168-
lastModified: '3 hours ago',
142+
status: 'down',
143+
location: 'atlanta',
144+
lastModified: 'threeHrs',
169145
url: 'http://www.redhat.com/en/office-locations/node23'
170146
},
171147
{
172-
name: `Node24`,
173-
status: 'Needs maintenance',
174-
location: 'San Francisco',
175-
lastModified: '5 hours ago',
148+
status: 'needsMaintenance',
149+
location: 'sanFrancisco',
150+
lastModified: 'fiveHrs',
176151
url: 'http://www.redhat.com/en/office-locations/node24'
177152
},
178153
{
179-
name: `Node25`,
180-
status: 'Running',
181-
location: 'Raleigh',
182-
lastModified: '7 minutes ago',
154+
status: 'running',
155+
location: 'raleigh',
156+
lastModified: 'sevenMins',
183157
url: 'http://www.redhat.com/en/office-locations/node25'
184158
}
185159
];

0 commit comments

Comments
 (0)