@patternfly/react-table 5.0.0-alpha.107 → 5.0.0-alpha.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/js/components/Table/package.json +1 -1
- package/dist/js/components/Table/utils/decorators/package.json +1 -1
- package/dist/js/components/Table/utils/package.json +1 -1
- package/dist/js/components/package.json +1 -1
- package/dist/js/deprecated/components/Table/base/package.json +1 -1
- package/dist/js/deprecated/components/Table/package.json +1 -1
- package/dist/js/deprecated/components/package.json +1 -1
- package/dist/js/deprecated/package.json +1 -1
- package/dist/js/package.json +1 -1
- package/package.json +3 -3
- package/src/docs/demos/Table.md +1 -251
- package/src/docs/demos/table-demos/BulkSelect.jsx +172 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.0.0-alpha.109](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-table@5.0.0-alpha.108...@patternfly/react-table@5.0.0-alpha.109) (2023-05-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @patternfly/react-table
|
|
9
|
+
|
|
10
|
+
# [5.0.0-alpha.108](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-table@5.0.0-alpha.107...@patternfly/react-table@5.0.0-alpha.108) (2023-05-17)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @patternfly/react-table
|
|
13
|
+
|
|
6
14
|
# [5.0.0-alpha.107](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-table@5.0.0-alpha.106...@patternfly/react-table@5.0.0-alpha.107) (2023-05-17)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @patternfly/react-table
|
package/components/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-table-components-esm","main":"index.js","module":"./components/index.js","typings":"index.d.ts","version":"5.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-table-components-esm","main":"index.js","module":"./components/index.js","typings":"index.d.ts","version":"5.0.0-alpha.108"}
|
package/deprecated/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-table-deprecated-deprecated-esm","main":"index.js","module":"./deprecated/index.js","typings":"index.d.ts","version":"5.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-table-deprecated-deprecated-esm","main":"index.js","module":"./deprecated/index.js","typings":"index.d.ts","version":"5.0.0-alpha.108"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-table-table-cjs","main":"index.js","module":"./dist/js/components/Table/index.js","typings":"index.d.ts","version":"5.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-table-table-cjs","main":"index.js","module":"./dist/js/components/Table/index.js","typings":"index.d.ts","version":"5.0.0-alpha.108"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-table-decorators-cjs","main":"index.js","module":"./dist/js/components/Table/utils/decorators/index.js","typings":"index.d.ts","version":"5.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-table-decorators-cjs","main":"index.js","module":"./dist/js/components/Table/utils/decorators/index.js","typings":"index.d.ts","version":"5.0.0-alpha.108"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-table-utils-cjs","main":"index.js","module":"./dist/js/components/Table/utils/index.js","typings":"index.d.ts","version":"5.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-table-utils-cjs","main":"index.js","module":"./dist/js/components/Table/utils/index.js","typings":"index.d.ts","version":"5.0.0-alpha.108"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-table-components-cjs","main":"index.js","module":"./dist/js/components/index.js","typings":"index.d.ts","version":"5.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-table-components-cjs","main":"index.js","module":"./dist/js/components/index.js","typings":"index.d.ts","version":"5.0.0-alpha.108"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-table-base-deprecated-cjs","main":"index.js","module":"./dist/js/deprecated/components/Table/base/index.js","typings":"index.d.ts","version":"5.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-table-base-deprecated-cjs","main":"index.js","module":"./dist/js/deprecated/components/Table/base/index.js","typings":"index.d.ts","version":"5.0.0-alpha.108"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-table-table-deprecated-cjs","main":"index.js","module":"./dist/js/deprecated/components/Table/index.js","typings":"index.d.ts","version":"5.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-table-table-deprecated-cjs","main":"index.js","module":"./dist/js/deprecated/components/Table/index.js","typings":"index.d.ts","version":"5.0.0-alpha.108"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-table-components-deprecated-cjs","main":"index.js","module":"./dist/js/deprecated/components/index.js","typings":"index.d.ts","version":"5.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-table-components-deprecated-cjs","main":"index.js","module":"./dist/js/deprecated/components/index.js","typings":"index.d.ts","version":"5.0.0-alpha.108"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-table-deprecated-deprecated-cjs","main":"index.js","module":"./dist/js/deprecated/index.js","typings":"index.d.ts","version":"5.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-table-deprecated-deprecated-cjs","main":"index.js","module":"./dist/js/deprecated/index.js","typings":"index.d.ts","version":"5.0.0-alpha.108"}
|
package/dist/js/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-table-js-cjs","main":"index.js","module":"./dist/js/index.js","typings":"index.d.ts","version":"5.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-table-js-cjs","main":"index.js","module":"./dist/js/index.js","typings":"index.d.ts","version":"5.0.0-alpha.108"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.109",
|
|
4
4
|
"description": "This library provides a set of React table components for use with the PatternFly 4",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"subpaths": "node scripts/createSubpaths.js"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@patternfly/react-core": "^5.0.0-alpha.
|
|
43
|
+
"@patternfly/react-core": "^5.0.0-alpha.107",
|
|
44
44
|
"@patternfly/react-icons": "^5.0.0-alpha.15",
|
|
45
45
|
"@patternfly/react-styles": "^5.0.0-alpha.11",
|
|
46
46
|
"@patternfly/react-tokens": "^5.0.0-alpha.10",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"react": "^17 || ^18",
|
|
56
56
|
"react-dom": "^17 || ^18"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "2da278eeebfb3475c31e3693435a8c7f04a0edde"
|
|
59
59
|
}
|
package/src/docs/demos/Table.md
CHANGED
|
@@ -56,258 +56,8 @@ import { rows, columns } from '../examples/Data.jsx';
|
|
|
56
56
|
|
|
57
57
|
### Bulk select
|
|
58
58
|
|
|
59
|
-
```js isFullscreen
|
|
60
|
-
import React from 'react';
|
|
61
|
-
import {
|
|
62
|
-
Dropdown,
|
|
63
|
-
DropdownItem,
|
|
64
|
-
DropdownList,
|
|
65
|
-
MenuToggle,
|
|
66
|
-
MenuToggleCheckbox,
|
|
67
|
-
PageSection,
|
|
68
|
-
Pagination,
|
|
69
|
-
Title,
|
|
70
|
-
Toolbar,
|
|
71
|
-
ToolbarContent,
|
|
72
|
-
ToolbarGroup,
|
|
73
|
-
ToolbarItem
|
|
74
|
-
} from '@patternfly/react-core';
|
|
75
|
-
import { Table as TableDeprecated, TableHeader, TableBody } from '@patternfly/react-table/deprecated';
|
|
76
|
-
import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper';
|
|
77
|
-
|
|
78
|
-
class BulkSelectTableDemo extends React.Component {
|
|
79
|
-
constructor(props) {
|
|
80
|
-
super(props);
|
|
81
|
-
this.state = {
|
|
82
|
-
res: [],
|
|
83
|
-
perPage: 20,
|
|
84
|
-
page: 1,
|
|
85
|
-
error: null,
|
|
86
|
-
loading: true,
|
|
87
|
-
selectedItems: [],
|
|
88
|
-
numSelected: 0,
|
|
89
|
-
isDropDownOpen: false,
|
|
90
|
-
isKebabOpen: false,
|
|
91
|
-
searchValue: ''
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
this.onSelect = (event, isSelected, rowId) => {
|
|
95
|
-
const { selectedItems } = this.state;
|
|
96
|
-
const rows = [...this.state.res];
|
|
97
|
-
const id = rows[rowId].id;
|
|
98
|
-
rows[rowId].selected = isSelected;
|
|
99
|
-
this.setState((prevState, props) => {
|
|
100
|
-
return {
|
|
101
|
-
res: rows,
|
|
102
|
-
selectedItems: isSelected
|
|
103
|
-
? [...prevState.selectedItems, id]
|
|
104
|
-
: prevState.selectedItems.filter((itemId) => itemId !== id)
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
this.updateSelected = () => {
|
|
110
|
-
const { res, selectedItems } = this.state;
|
|
111
|
-
let rows = res.map((post) => {
|
|
112
|
-
post.selected = selectedItems.includes(post.id);
|
|
113
|
-
return post;
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
this.setState({
|
|
117
|
-
res: rows
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
this.handleSelectClick = (newState) => {
|
|
122
|
-
if (newState === 'none') {
|
|
123
|
-
this.setState(
|
|
124
|
-
{
|
|
125
|
-
selectedItems: []
|
|
126
|
-
},
|
|
127
|
-
this.updateSelected
|
|
128
|
-
);
|
|
129
|
-
} else if (newState === 'page') {
|
|
130
|
-
let newRows = [];
|
|
131
|
-
let rows = this.state.res.map((post) => {
|
|
132
|
-
const isSelected = post.selected;
|
|
133
|
-
newRows = isSelected ? [...newRows] : [...newRows, post.id];
|
|
134
|
-
post.selected = true;
|
|
135
|
-
return post;
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
this.setState((prevState, props) => {
|
|
139
|
-
return {
|
|
140
|
-
selectedItems: prevState.selectedItems.concat(newRows)
|
|
141
|
-
};
|
|
142
|
-
}, this.updateSelected);
|
|
143
|
-
} else {
|
|
144
|
-
let newRows = [];
|
|
145
|
-
for (var i = 1; i <= 100; i++) newRows = [...newRows, i];
|
|
146
|
-
|
|
147
|
-
this.setState(
|
|
148
|
-
{
|
|
149
|
-
selectedItems: newRows
|
|
150
|
-
},
|
|
151
|
-
this.updateSelected
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
this.onDropDownToggle = (isOpen) => {
|
|
157
|
-
this.setState({
|
|
158
|
-
isDropDownOpen: isOpen
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
this.onDropDownSelect = (event) => {
|
|
163
|
-
this.setState((prevState, props) => {
|
|
164
|
-
return { isDropDownOpen: !prevState.isDropDownOpen };
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
}
|
|
59
|
+
```js isFullscreen file="./table-demos/BulkSelect.jsx"
|
|
168
60
|
|
|
169
|
-
fetch(page, perPage) {
|
|
170
|
-
this.setState({ loading: true });
|
|
171
|
-
fetch(`https://jsonplaceholder.typicode.com/posts?_page=${page}&_limit=${perPage}`)
|
|
172
|
-
.then((resp) => resp.json())
|
|
173
|
-
.then((resp) => this.setState({ res: resp, perPage, page, loading: false }))
|
|
174
|
-
.then(() => this.updateSelected())
|
|
175
|
-
.catch((err) => this.setState({ error: err, loading: false }));
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
componentDidMount() {
|
|
179
|
-
this.fetch(this.state.page, this.state.perPage);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
renderPagination(variant) {
|
|
183
|
-
const { page, perPage } = this.state;
|
|
184
|
-
return (
|
|
185
|
-
<Pagination
|
|
186
|
-
isCompact
|
|
187
|
-
itemCount={100}
|
|
188
|
-
page={page}
|
|
189
|
-
perPage={perPage}
|
|
190
|
-
onSetPage={(_evt, value) => {
|
|
191
|
-
this.fetch(value, perPage);
|
|
192
|
-
}}
|
|
193
|
-
onPerPageSelect={(_evt, value) => {
|
|
194
|
-
this.fetch(1, value);
|
|
195
|
-
}}
|
|
196
|
-
variant={variant}
|
|
197
|
-
titles={{
|
|
198
|
-
paginationAriaLabel: `${variant} pagination`
|
|
199
|
-
}}
|
|
200
|
-
/>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
buildSelectDropdown() {
|
|
205
|
-
const { isDropDownOpen, selectedItems } = this.state;
|
|
206
|
-
const numSelected = selectedItems.length;
|
|
207
|
-
const allSelected = numSelected === 100;
|
|
208
|
-
const anySelected = numSelected > 0;
|
|
209
|
-
const someChecked = anySelected ? null : false;
|
|
210
|
-
const isChecked = allSelected ? true : someChecked;
|
|
211
|
-
|
|
212
|
-
const items = (
|
|
213
|
-
<>
|
|
214
|
-
<DropdownItem key="item-1" onClick={() => this.handleSelectClick('none')}>
|
|
215
|
-
Select none (0 items)
|
|
216
|
-
</DropdownItem>
|
|
217
|
-
<DropdownItem key="item-2" onClick={() => this.handleSelectClick('page')}>
|
|
218
|
-
Select page ({this.state.perPage} items)
|
|
219
|
-
</DropdownItem>
|
|
220
|
-
<DropdownItem key="item-3" onClick={() => this.handleSelectClick('all')}>
|
|
221
|
-
Select all (100 items)
|
|
222
|
-
</DropdownItem>
|
|
223
|
-
</>
|
|
224
|
-
);
|
|
225
|
-
return (
|
|
226
|
-
<Dropdown
|
|
227
|
-
onSelect={this.onDropDownSelect}
|
|
228
|
-
isOpen={isDropDownOpen}
|
|
229
|
-
onOpenChange={(isOpen) => this.setState({ isDropDownOpen: isOpen })}
|
|
230
|
-
toggle={(toggleRef) => (
|
|
231
|
-
<MenuToggle
|
|
232
|
-
ref={toggleRef}
|
|
233
|
-
isExpanded={isDropDownOpen}
|
|
234
|
-
onClick={this.onDropDownToggle}
|
|
235
|
-
aria-label="Select cards"
|
|
236
|
-
splitButtonOptions={{
|
|
237
|
-
items: [
|
|
238
|
-
<MenuToggleCheckbox
|
|
239
|
-
id="split-dropdown-checkbox"
|
|
240
|
-
key="split-dropdown-checkbox"
|
|
241
|
-
aria-label={anySelected ? 'Deselect all cards' : 'Select all cards'}
|
|
242
|
-
isChecked={allSelected}
|
|
243
|
-
onClick={() => {
|
|
244
|
-
anySelected ? this.handleSelectClick('none') : this.handleSelectClick('all');
|
|
245
|
-
}}
|
|
246
|
-
>
|
|
247
|
-
{numSelected !== 0 && `${numSelected} selected`}
|
|
248
|
-
</MenuToggleCheckbox>
|
|
249
|
-
]
|
|
250
|
-
}}
|
|
251
|
-
></MenuToggle>
|
|
252
|
-
)}
|
|
253
|
-
>
|
|
254
|
-
<DropdownList>{items}</DropdownList>
|
|
255
|
-
</Dropdown>
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
renderToolbar() {
|
|
260
|
-
return (
|
|
261
|
-
<React.Fragment>
|
|
262
|
-
<Toolbar>
|
|
263
|
-
<ToolbarContent>
|
|
264
|
-
<ToolbarGroup>
|
|
265
|
-
<ToolbarItem variant="bulk-select">{this.buildSelectDropdown()}</ToolbarItem>
|
|
266
|
-
</ToolbarGroup>
|
|
267
|
-
<ToolbarItem variant="pagination">{this.renderPagination('top')}</ToolbarItem>
|
|
268
|
-
</ToolbarContent>
|
|
269
|
-
</Toolbar>
|
|
270
|
-
</React.Fragment>
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
render() {
|
|
275
|
-
const { loading, res } = this.state;
|
|
276
|
-
const rows = res.map((post) => ({
|
|
277
|
-
cells: [post.title, post.body],
|
|
278
|
-
selected: post.selected
|
|
279
|
-
}));
|
|
280
|
-
|
|
281
|
-
return (
|
|
282
|
-
<DashboardWrapper hasPageTemplateTitle>
|
|
283
|
-
<PageSection isWidthLimited>
|
|
284
|
-
{this.renderToolbar()}
|
|
285
|
-
{!loading && (
|
|
286
|
-
<TableDeprecated
|
|
287
|
-
aria-label="Bulk Select Table Demo"
|
|
288
|
-
cells={['Title', 'Body']}
|
|
289
|
-
rows={rows}
|
|
290
|
-
onSelect={this.onSelect}
|
|
291
|
-
canSelectAll={false}
|
|
292
|
-
>
|
|
293
|
-
<TableHeader />
|
|
294
|
-
<TableBody />
|
|
295
|
-
</TableDeprecated>
|
|
296
|
-
)}
|
|
297
|
-
|
|
298
|
-
{loading && (
|
|
299
|
-
<div className="pf-v5-l-bullseye">
|
|
300
|
-
<Title headingLevel="h2" size="3xl">
|
|
301
|
-
Please wait while loading data
|
|
302
|
-
</Title>
|
|
303
|
-
</div>
|
|
304
|
-
)}
|
|
305
|
-
{this.renderPagination('bottom')}
|
|
306
|
-
</PageSection>
|
|
307
|
-
</DashboardWrapper>
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
61
|
```
|
|
312
62
|
|
|
313
63
|
### Expand/collapse all
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Dropdown,
|
|
4
|
+
DropdownList,
|
|
5
|
+
DropdownItem,
|
|
6
|
+
MenuToggle,
|
|
7
|
+
MenuToggleCheckbox,
|
|
8
|
+
PageSection,
|
|
9
|
+
Pagination,
|
|
10
|
+
Toolbar,
|
|
11
|
+
ToolbarContent,
|
|
12
|
+
ToolbarGroup,
|
|
13
|
+
ToolbarItem
|
|
14
|
+
} from '@patternfly/react-core';
|
|
15
|
+
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
16
|
+
import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper';
|
|
17
|
+
import { rows, columns } from '../../examples/Data.jsx';
|
|
18
|
+
|
|
19
|
+
export const BulkSelectTableDemo = () => {
|
|
20
|
+
const [isBulkSelectDropdownOpen, setIsBulkSelectDropdownOpen] = React.useState(false);
|
|
21
|
+
const [bulkSelection, setBulkSelection] = React.useState('');
|
|
22
|
+
const [page, setPage] = React.useState(1);
|
|
23
|
+
const [perPage, setPerPage] = React.useState(10);
|
|
24
|
+
const [paginatedRows, setPaginatedRows] = React.useState(rows.slice(0, 10));
|
|
25
|
+
const [selectedRows, setSelectedRows] = React.useState([]);
|
|
26
|
+
const handleSetPage = (_evt, newPage, _perPage, startIdx, endIdx) => {
|
|
27
|
+
setPaginatedRows(rows.slice(startIdx, endIdx));
|
|
28
|
+
setPage(newPage);
|
|
29
|
+
};
|
|
30
|
+
const handlePerPageSelect = (_evt, newPerPage, newPage, startIdx, endIdx) => {
|
|
31
|
+
setPaginatedRows(rows.slice(startIdx, endIdx));
|
|
32
|
+
setPage(newPage);
|
|
33
|
+
setPerPage(newPerPage);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const setRowSelected = (row, isSelecting = true) =>
|
|
37
|
+
setSelectedRows(prevSelected => {
|
|
38
|
+
const otherSelectedRows = prevSelected.filter(r => r !== row.name);
|
|
39
|
+
return isSelecting ? [...otherSelectedRows, row.name] : otherSelectedRows;
|
|
40
|
+
});
|
|
41
|
+
const selectAllRows = (isSelecting = true) =>
|
|
42
|
+
setSelectedRows(isSelecting ? rows.map(r => r.name) : []);
|
|
43
|
+
const selectPageRows = (isSelecting = true) => setSelectedRows(isSelecting ? paginatedRows.map(r => r.name) : []);
|
|
44
|
+
const isRowSelected = (row) => selectedRows.includes(row.name);
|
|
45
|
+
|
|
46
|
+
const buildPagination = (variant, isCompact) => (
|
|
47
|
+
<Pagination
|
|
48
|
+
isCompact={isCompact}
|
|
49
|
+
itemCount={rows.length}
|
|
50
|
+
page={page}
|
|
51
|
+
perPage={perPage}
|
|
52
|
+
onSetPage={handleSetPage}
|
|
53
|
+
onPerPageSelect={handlePerPageSelect}
|
|
54
|
+
variant={variant}
|
|
55
|
+
titles={{
|
|
56
|
+
paginationAriaLabel: `${variant} pagination`
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const buildBulkSelectDropdown = () => {
|
|
62
|
+
const numSelected = selectedRows.length;
|
|
63
|
+
const allSelected = numSelected === rows.length;
|
|
64
|
+
const anySelected = numSelected > 0;
|
|
65
|
+
const someChecked = anySelected ? null : false;
|
|
66
|
+
const isChecked = allSelected ? true : someChecked;
|
|
67
|
+
|
|
68
|
+
const items = (
|
|
69
|
+
<>
|
|
70
|
+
<DropdownItem itemId="none">
|
|
71
|
+
Select none (0 items)
|
|
72
|
+
</DropdownItem>
|
|
73
|
+
<DropdownItem itemId="page">
|
|
74
|
+
Select page ({perPage} items)
|
|
75
|
+
</DropdownItem>
|
|
76
|
+
<DropdownItem itemId="all">
|
|
77
|
+
Select all ({rows.length} items)
|
|
78
|
+
</DropdownItem>
|
|
79
|
+
</>
|
|
80
|
+
);
|
|
81
|
+
return (
|
|
82
|
+
<Dropdown
|
|
83
|
+
role="menu"
|
|
84
|
+
onSelect={(_ev, itemId) => {
|
|
85
|
+
if (itemId === "all") {
|
|
86
|
+
selectAllRows(bulkSelection !== 'all');
|
|
87
|
+
} else if (itemId === "page") {
|
|
88
|
+
selectPageRows(bulkSelection !== 'page');
|
|
89
|
+
} else {
|
|
90
|
+
setSelectedRows([]);
|
|
91
|
+
}
|
|
92
|
+
setBulkSelection(itemId);
|
|
93
|
+
}}
|
|
94
|
+
isOpen={isBulkSelectDropdownOpen}
|
|
95
|
+
onOpenChange={(isOpen) => setIsBulkSelectDropdownOpen(isOpen)}
|
|
96
|
+
toggle={(toggleRef) => (
|
|
97
|
+
<MenuToggle
|
|
98
|
+
ref={toggleRef}
|
|
99
|
+
isExpanded={isBulkSelectDropdownOpen}
|
|
100
|
+
onClick={() => setIsBulkSelectDropdownOpen(!isBulkSelectDropdownOpen)}
|
|
101
|
+
aria-label="Select cards"
|
|
102
|
+
splitButtonOptions={{
|
|
103
|
+
items: [
|
|
104
|
+
<MenuToggleCheckbox
|
|
105
|
+
id="split-dropdown-checkbox"
|
|
106
|
+
key="split-dropdown-checkbox"
|
|
107
|
+
aria-label={anySelected ? 'Deselect all cards' : 'Select all cards'}
|
|
108
|
+
isChecked={isChecked}
|
|
109
|
+
onClick={() => {
|
|
110
|
+
anySelected ? setSelectedRows([]) : selectAllRows(bulkSelection !== 'all');
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
{numSelected !== 0 && `${numSelected} selected`}
|
|
114
|
+
</MenuToggleCheckbox>
|
|
115
|
+
]
|
|
116
|
+
}}
|
|
117
|
+
></MenuToggle>
|
|
118
|
+
)}
|
|
119
|
+
>
|
|
120
|
+
<DropdownList>{items}</DropdownList>
|
|
121
|
+
</Dropdown>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const toolbar=(
|
|
126
|
+
<Toolbar>
|
|
127
|
+
<ToolbarContent>
|
|
128
|
+
<ToolbarGroup>
|
|
129
|
+
<ToolbarItem variant="bulk-select">{buildBulkSelectDropdown()}</ToolbarItem>
|
|
130
|
+
</ToolbarGroup>
|
|
131
|
+
<ToolbarItem variant="pagination">{buildPagination('top')}</ToolbarItem>
|
|
132
|
+
</ToolbarContent>
|
|
133
|
+
</Toolbar>
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<DashboardWrapper hasPageTemplateTitle>
|
|
138
|
+
<PageSection isWidthLimited>
|
|
139
|
+
{toolbar}
|
|
140
|
+
<Table aria-label="Selectable table">
|
|
141
|
+
<Thead>
|
|
142
|
+
<Tr>
|
|
143
|
+
<Th/>
|
|
144
|
+
<Th key={0}>{columns[0]}</Th>
|
|
145
|
+
<Th key={1}>{columns[1]}</Th>
|
|
146
|
+
<Th key={2}>{columns[2]}</Th>
|
|
147
|
+
<Th key={3}>{columns[3]}</Th>
|
|
148
|
+
</Tr>
|
|
149
|
+
</Thead>
|
|
150
|
+
<Tbody>
|
|
151
|
+
{paginatedRows.map((row, rowIndex) => (
|
|
152
|
+
<Tr key={row.name}>
|
|
153
|
+
<Td
|
|
154
|
+
select={{
|
|
155
|
+
rowIndex,
|
|
156
|
+
onSelect: (_event, isSelecting) => setRowSelected(row, isSelecting),
|
|
157
|
+
isSelected: isRowSelected(row)
|
|
158
|
+
}}
|
|
159
|
+
/>
|
|
160
|
+
<Td dataLabel={columns[0]}>{row.name}</Td>
|
|
161
|
+
<Td dataLabel={columns[1]}>{row.threads}</Td>
|
|
162
|
+
<Td dataLabel={columns[2]}>{row.applications}</Td>
|
|
163
|
+
<Td dataLabel={columns[3]}>{row.workspaces}</Td>
|
|
164
|
+
</Tr>
|
|
165
|
+
))}
|
|
166
|
+
</Tbody>
|
|
167
|
+
</Table>
|
|
168
|
+
{buildPagination('bottom')}
|
|
169
|
+
</PageSection>
|
|
170
|
+
</DashboardWrapper>
|
|
171
|
+
);
|
|
172
|
+
}
|