@patternfly/react-table 6.0.0-alpha.2 → 6.0.0-alpha.4
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 +56 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/Table/package.json +1 -1
- package/dist/dynamic/components/Table/utils/decorators/package.json +1 -1
- package/dist/dynamic/components/Table/utils/package.json +1 -1
- package/dist/dynamic/deprecated/components/Table/base/package.json +1 -1
- package/dist/dynamic/deprecated/components/Table/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/esm/components/Table/Caption.js +1 -1
- package/dist/esm/components/Table/Caption.js.map +1 -1
- package/dist/esm/components/Table/CollapseColumn.js +1 -1
- package/dist/esm/components/Table/CollapseColumn.js.map +1 -1
- package/dist/esm/components/Table/DraggableRowWrapper.js +2 -2
- package/dist/esm/components/Table/DraggableRowWrapper.js.map +1 -1
- package/dist/esm/components/Table/EditColumn.js +1 -1
- package/dist/esm/components/Table/EditColumn.js.map +1 -1
- package/dist/esm/components/Table/EditableSelectInputCell.js +2 -2
- package/dist/esm/components/Table/EditableSelectInputCell.js.map +1 -1
- package/dist/esm/components/Table/EditableTextCell.js +2 -2
- package/dist/esm/components/Table/EditableTextCell.js.map +1 -1
- package/dist/esm/components/Table/ExpandableRowContent.js +1 -1
- package/dist/esm/components/Table/ExpandableRowContent.js.map +1 -1
- package/dist/esm/components/Table/HeaderCellInfoWrapper.js +1 -1
- package/dist/esm/components/Table/HeaderCellInfoWrapper.js.map +1 -1
- package/dist/esm/components/Table/InnerScrollContainer.js +1 -1
- package/dist/esm/components/Table/InnerScrollContainer.js.map +1 -1
- package/dist/esm/components/Table/OuterScrollContainer.js +1 -1
- package/dist/esm/components/Table/OuterScrollContainer.js.map +1 -1
- package/dist/esm/components/Table/SortColumn.js +1 -1
- package/dist/esm/components/Table/SortColumn.js.map +1 -1
- package/dist/esm/components/Table/Table.js +3 -3
- package/dist/esm/components/Table/Table.js.map +1 -1
- package/dist/esm/components/Table/TableText.js +1 -1
- package/dist/esm/components/Table/TableText.js.map +1 -1
- package/dist/esm/components/Table/Tbody.js +1 -1
- package/dist/esm/components/Table/Tbody.js.map +1 -1
- package/dist/esm/components/Table/Td.js +3 -3
- package/dist/esm/components/Table/Td.js.map +1 -1
- package/dist/esm/components/Table/Th.js +2 -2
- package/dist/esm/components/Table/Th.js.map +1 -1
- package/dist/esm/components/Table/Thead.js +1 -1
- package/dist/esm/components/Table/Thead.js.map +1 -1
- package/dist/esm/components/Table/Tr.js +2 -2
- package/dist/esm/components/Table/Tr.js.map +1 -1
- package/dist/esm/components/Table/TreeRowWrapper.js +2 -2
- package/dist/esm/components/Table/TreeRowWrapper.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/cellActions.js +1 -1
- package/dist/esm/components/Table/utils/decorators/cellActions.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/cellWidth.js +1 -1
- package/dist/esm/components/Table/utils/decorators/cellWidth.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/classNames.js +1 -1
- package/dist/esm/components/Table/utils/decorators/classNames.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/collapsible.js +1 -1
- package/dist/esm/components/Table/utils/decorators/collapsible.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/compoundExpand.js +1 -1
- package/dist/esm/components/Table/utils/decorators/compoundExpand.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/editable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/editable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/favoritable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/favoritable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/info.js +1 -1
- package/dist/esm/components/Table/utils/decorators/info.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/selectable.js +2 -2
- package/dist/esm/components/Table/utils/decorators/selectable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/sortable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/sortable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/treeRow.js +2 -2
- package/dist/esm/components/Table/utils/decorators/treeRow.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/wrappable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/wrappable.js.map +1 -1
- package/dist/esm/demos/index.d.ts +2 -0
- package/dist/esm/demos/index.d.ts.map +1 -0
- package/dist/esm/demos/index.js +2 -0
- package/dist/esm/demos/index.js.map +1 -0
- package/dist/esm/demos/sampleData.d.ts +13 -0
- package/dist/esm/demos/sampleData.d.ts.map +1 -0
- package/dist/esm/demos/sampleData.js +764 -0
- package/dist/esm/demos/sampleData.js.map +1 -0
- package/dist/esm/deprecated/components/Table/Table.js +1 -1
- package/dist/esm/deprecated/components/Table/Table.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/js/demos/index.d.ts +2 -0
- package/dist/js/demos/index.d.ts.map +1 -0
- package/dist/js/demos/index.js +5 -0
- package/dist/js/demos/index.js.map +1 -0
- package/dist/js/demos/sampleData.d.ts +13 -0
- package/dist/js/demos/sampleData.d.ts.map +1 -0
- package/dist/js/demos/sampleData.js +767 -0
- package/dist/js/demos/sampleData.js.map +1 -0
- package/dist/js/index.d.ts +1 -0
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +1 -0
- package/dist/js/index.js.map +1 -1
- package/dist/umd/react-table.min.js +3 -3
- package/package.json +6 -6
- package/src/components/Table/examples/TableStickyColumnsAndHeader.tsx +5 -4
- package/src/components/Table/utils/transformers.test.tsx +1 -0
- package/src/demos/Table.md +159 -0
- package/src/demos/examples/TableAutomaticPagination.tsx +101 -0
- package/src/{docs/demos/table-demos/BulkSelect.jsx → demos/examples/TableBulkSelect.tsx} +41 -20
- package/src/demos/examples/TableColumnManagement.tsx +486 -0
- package/src/demos/examples/TableColumnManagementWithDraggable.tsx +641 -0
- package/src/{docs/demos/table-demos/Compact.jsx → demos/examples/TableCompact.tsx} +32 -16
- package/src/{docs/demos/table-demos/CompoundExpansion.jsx → demos/examples/TableCompoundExpansion.tsx} +25 -12
- package/src/demos/examples/TableEmptyStateDefault.tsx +60 -0
- package/src/demos/examples/TableEmptyStateError.tsx +53 -0
- package/src/demos/examples/TableEmptyStateLoading.tsx +43 -0
- package/src/{docs/demos/table-demos/ExpandCollapseAll.jsx → demos/examples/TableExpandCollapseAll.tsx} +17 -10
- package/src/demos/examples/TableFilterable.tsx +394 -0
- package/src/{docs/demos/table-demos/SortableResponsive.jsx → demos/examples/TableSortableResponsive.tsx} +29 -27
- package/src/{docs/demos/table-demos/StaticBottomPagination.jsx → demos/examples/TableStaticBottomPagination.tsx} +22 -9
- package/src/{docs/demos/table-demos/StickyFirstColumn.jsx → demos/examples/TableStickyFirstColumn.tsx} +31 -9
- package/src/{docs/demos/table-demos/StickyHeader.jsx → demos/examples/TableStickyHeader.tsx} +3 -3
- package/src/demos/index.ts +1 -0
- package/src/{docs/demos/table-demos/sampleData.js → demos/sampleData.tsx} +88 -77
- package/src/deprecated/components/Table/__tests__/Table.test.tsx +4 -9
- package/src/index.ts +1 -0
- package/src/docs/demos/Table.md +0 -1620
- package/src/docs/demos/table-demos/ColumnManagement.jsx +0 -471
|
@@ -1,471 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Button,
|
|
5
|
-
Card,
|
|
6
|
-
DataList,
|
|
7
|
-
DataListCheck,
|
|
8
|
-
DataListItem,
|
|
9
|
-
DataListItemRow,
|
|
10
|
-
DataListCell,
|
|
11
|
-
DataListItemCells,
|
|
12
|
-
Label,
|
|
13
|
-
Toolbar,
|
|
14
|
-
ToolbarContent,
|
|
15
|
-
ToolbarItem,
|
|
16
|
-
MenuToggle,
|
|
17
|
-
Modal,
|
|
18
|
-
OverflowMenu,
|
|
19
|
-
OverflowMenuGroup,
|
|
20
|
-
OverflowMenuItem,
|
|
21
|
-
PageSection,
|
|
22
|
-
Pagination,
|
|
23
|
-
PaginationVariant,
|
|
24
|
-
Text,
|
|
25
|
-
TextContent,
|
|
26
|
-
TextVariants
|
|
27
|
-
} from '@patternfly/react-core';
|
|
28
|
-
import { Table, TableText, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
29
|
-
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
30
|
-
import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
|
|
31
|
-
import { DashboardWrapper } from '@patternfly/react-core/src/demos/DashboardWrapper.js';
|
|
32
|
-
import { capitalize } from '@patternfly/react-table/src/components/Table/utils/utils';
|
|
33
|
-
import { rows, columns } from '@patternfly/react-table/src/docs/demos/table-demos/sampleData';
|
|
34
|
-
|
|
35
|
-
export const ColumnManagementAction = () => {
|
|
36
|
-
const defaultColumns = columns;
|
|
37
|
-
const defaultRows = rows;
|
|
38
|
-
|
|
39
|
-
const [filters, setFilters] = React.useState([]);
|
|
40
|
-
const [filteredColumns, setFilteredColumns] = React.useState([]);
|
|
41
|
-
const [filteredRows, setFilteredRows] = React.useState([]);
|
|
42
|
-
const [managedColumns, setManagedColumns] = React.useState(defaultColumns);
|
|
43
|
-
const [managedRows, setManagedRows] = React.useState(defaultRows);
|
|
44
|
-
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
45
|
-
const [checkedState, setCheckedState] = React.useState(Array(columns.length).fill(true));
|
|
46
|
-
const [page, setPage] = React.useState(1);
|
|
47
|
-
const [perPage, setPerPage] = React.useState(10);
|
|
48
|
-
const [paginatedRows, setPaginatedRows] = React.useState(rows);
|
|
49
|
-
|
|
50
|
-
const matchCheckboxNameToColumn = (name) => {
|
|
51
|
-
switch (name) {
|
|
52
|
-
case 'check1':
|
|
53
|
-
return 'Servers';
|
|
54
|
-
case 'check2':
|
|
55
|
-
return 'Threads';
|
|
56
|
-
case 'check3':
|
|
57
|
-
return 'Applications';
|
|
58
|
-
case 'check4':
|
|
59
|
-
return 'Workspaces';
|
|
60
|
-
case 'check5':
|
|
61
|
-
return 'Status';
|
|
62
|
-
case 'check6':
|
|
63
|
-
return 'Location';
|
|
64
|
-
case 'check7':
|
|
65
|
-
return 'Last Modified';
|
|
66
|
-
case 'check8':
|
|
67
|
-
return 'URL';
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
const matchSelectedColumnNameToAttr = (name) => {
|
|
71
|
-
switch (name) {
|
|
72
|
-
case 'Servers':
|
|
73
|
-
return 'name';
|
|
74
|
-
case 'Threads':
|
|
75
|
-
return 'threads';
|
|
76
|
-
case 'Applications':
|
|
77
|
-
return 'applications';
|
|
78
|
-
case 'Workspaces':
|
|
79
|
-
return 'workspaces';
|
|
80
|
-
case 'Status':
|
|
81
|
-
return 'status';
|
|
82
|
-
case 'Location':
|
|
83
|
-
return 'location';
|
|
84
|
-
case 'Last Modified':
|
|
85
|
-
return 'lastModified';
|
|
86
|
-
case 'URL':
|
|
87
|
-
return 'url';
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// Pagination logic
|
|
92
|
-
const handleSetPage = (_evt, newPage) => {
|
|
93
|
-
setPage(newPage);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const handlePerPageSelect = (_evt, newPerPage) => {
|
|
97
|
-
setPerPage(newPerPage);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const renderPagination = (variant, isCompact) => (
|
|
101
|
-
<Pagination
|
|
102
|
-
isCompact={isCompact}
|
|
103
|
-
itemCount={rows.length}
|
|
104
|
-
page={page}
|
|
105
|
-
perPage={perPage}
|
|
106
|
-
onSetPage={handleSetPage}
|
|
107
|
-
onPerPageSelect={handlePerPageSelect}
|
|
108
|
-
variant={variant}
|
|
109
|
-
titles={{
|
|
110
|
-
paginationAriaLabel: `${variant} pagination`
|
|
111
|
-
}}
|
|
112
|
-
/>
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
React.useEffect(() => {
|
|
116
|
-
setPaginatedRows(managedRows.slice((page - 1) * perPage, page * perPage - 1));
|
|
117
|
-
}, [managedRows, page, perPage]);
|
|
118
|
-
|
|
119
|
-
// Removes attribute from each node object in Data.jsx
|
|
120
|
-
const removePropFromObject = (object, keys) =>
|
|
121
|
-
keys.reduce((obj, prop) => {
|
|
122
|
-
const { [prop]: _, ...keep } = obj;
|
|
123
|
-
return keep;
|
|
124
|
-
}, object);
|
|
125
|
-
|
|
126
|
-
// Filters columns out of table that are not selected in the column management modal
|
|
127
|
-
const filterData = (checked, name) => {
|
|
128
|
-
const selectedColumn = matchSelectedColumnNameToAttr(name);
|
|
129
|
-
|
|
130
|
-
const filteredRows = [];
|
|
131
|
-
if (checked) {
|
|
132
|
-
const updatedFilters = filters.filter((item) => item !== selectedColumn);
|
|
133
|
-
|
|
134
|
-
// Only show the names of columns that were selected in the modal
|
|
135
|
-
const filteredColumns = defaultColumns.filter(
|
|
136
|
-
(column) => !updatedFilters.includes(matchSelectedColumnNameToAttr(column))
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
// Remove the attributes (i.e. "columns") that were not selected
|
|
140
|
-
defaultRows.forEach((item) => filteredRows.push(removePropFromObject(item, updatedFilters)));
|
|
141
|
-
|
|
142
|
-
setFilters(updatedFilters);
|
|
143
|
-
setFilteredColumns(filteredColumns);
|
|
144
|
-
setFilteredRows(filteredRows);
|
|
145
|
-
} else {
|
|
146
|
-
let updatedFilters = filters;
|
|
147
|
-
updatedFilters.push(selectedColumn);
|
|
148
|
-
|
|
149
|
-
// Only show the names of columns that were selected in the modal
|
|
150
|
-
const filteredColumns = managedColumns.filter(
|
|
151
|
-
(column) => !filters.includes(matchSelectedColumnNameToAttr(column))
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
// Remove the attributes (i.e. "columns") that were not selected
|
|
155
|
-
managedRows.forEach((item) => filteredRows.push(removePropFromObject(item, updatedFilters)));
|
|
156
|
-
|
|
157
|
-
setFilters(updatedFilters);
|
|
158
|
-
setFilteredColumns(filteredColumns);
|
|
159
|
-
setFilteredRows(filteredRows);
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
const unfilterAllData = () => {
|
|
163
|
-
setFilters([]);
|
|
164
|
-
setFilteredColumns(defaultColumns);
|
|
165
|
-
setFilteredRows(defaultRows);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const handleChange = (event, checked) => {
|
|
169
|
-
const target = event.target;
|
|
170
|
-
const value = target.type === 'checkbox' ? target.checked : target.value;
|
|
171
|
-
|
|
172
|
-
// Remove any columns from the table that aren't checked
|
|
173
|
-
filterData(checked, matchCheckboxNameToColumn(target.name));
|
|
174
|
-
const checkedIndex = columns.findIndex((element) => element === matchCheckboxNameToColumn(target.name));
|
|
175
|
-
|
|
176
|
-
const updatedCheckedState = [...checkedState];
|
|
177
|
-
updatedCheckedState[checkedIndex] = value;
|
|
178
|
-
setCheckedState(updatedCheckedState);
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
const handleModalToggle = (_event) => {
|
|
182
|
-
setIsModalOpen(!isModalOpen);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const onSave = () => {
|
|
186
|
-
setManagedColumns(filteredColumns);
|
|
187
|
-
setManagedRows(filteredRows);
|
|
188
|
-
setPaginatedRows(filteredRows);
|
|
189
|
-
setIsModalOpen(!isModalOpen);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const selectAllColumns = () => {
|
|
193
|
-
unfilterAllData();
|
|
194
|
-
setCheckedState(Array(columns.length).fill(true));
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const renderModal = () => {
|
|
198
|
-
return (
|
|
199
|
-
<Modal
|
|
200
|
-
title="Manage columns"
|
|
201
|
-
isOpen={isModalOpen}
|
|
202
|
-
variant="small"
|
|
203
|
-
description={
|
|
204
|
-
<TextContent>
|
|
205
|
-
<Text component={TextVariants.p}>Selected categories will be displayed in the table.</Text>
|
|
206
|
-
<Button isInline onClick={selectAllColumns} variant="link">
|
|
207
|
-
Select all
|
|
208
|
-
</Button>
|
|
209
|
-
</TextContent>
|
|
210
|
-
}
|
|
211
|
-
onClose={handleModalToggle}
|
|
212
|
-
actions={[
|
|
213
|
-
<Button key="save" variant="primary" onClick={onSave}>
|
|
214
|
-
Save
|
|
215
|
-
</Button>,
|
|
216
|
-
<Button key="cancel" variant="secondary" onClick={handleModalToggle}>
|
|
217
|
-
Cancel
|
|
218
|
-
</Button>
|
|
219
|
-
]}
|
|
220
|
-
>
|
|
221
|
-
<DataList aria-label="Table column management" id="table-column-management" isCompact>
|
|
222
|
-
<DataListItem aria-labelledby="table-column-management-item1">
|
|
223
|
-
<DataListItemRow>
|
|
224
|
-
<DataListCheck
|
|
225
|
-
aria-labelledby="table-column-management-item1"
|
|
226
|
-
checked={checkedState[0]}
|
|
227
|
-
name="check1"
|
|
228
|
-
id="check1"
|
|
229
|
-
onChange={handleChange}
|
|
230
|
-
/>
|
|
231
|
-
<DataListItemCells
|
|
232
|
-
dataListCells={[
|
|
233
|
-
<DataListCell id="table-column-management-item1" key="table-column-management-item1">
|
|
234
|
-
<label htmlFor="check1">{columns[0]}</label>
|
|
235
|
-
</DataListCell>
|
|
236
|
-
]}
|
|
237
|
-
/>
|
|
238
|
-
</DataListItemRow>
|
|
239
|
-
</DataListItem>
|
|
240
|
-
<DataListItem aria-labelledby="table-column-management-item2">
|
|
241
|
-
<DataListItemRow>
|
|
242
|
-
<DataListCheck
|
|
243
|
-
aria-labelledby="table-column-management-item2"
|
|
244
|
-
checked={checkedState[1]}
|
|
245
|
-
name="check2"
|
|
246
|
-
id="check2"
|
|
247
|
-
onChange={handleChange}
|
|
248
|
-
/>
|
|
249
|
-
<DataListItemCells
|
|
250
|
-
dataListCells={[
|
|
251
|
-
<DataListCell id="table-column-management-item2" key="table-column-management-item2">
|
|
252
|
-
<label htmlFor="check2">{columns[1]}</label>
|
|
253
|
-
</DataListCell>
|
|
254
|
-
]}
|
|
255
|
-
/>
|
|
256
|
-
</DataListItemRow>
|
|
257
|
-
</DataListItem>
|
|
258
|
-
<DataListItem aria-labelledby="table-column-management-item3">
|
|
259
|
-
<DataListItemRow>
|
|
260
|
-
<DataListCheck
|
|
261
|
-
aria-labelledby="table-column-management-item3"
|
|
262
|
-
checked={checkedState[2]}
|
|
263
|
-
name="check3"
|
|
264
|
-
id="check3"
|
|
265
|
-
onChange={handleChange}
|
|
266
|
-
/>
|
|
267
|
-
<DataListItemCells
|
|
268
|
-
dataListCells={[
|
|
269
|
-
<DataListCell id="table-column-management-item3" key="table-column-management-item3">
|
|
270
|
-
<label htmlFor="check3">{columns[2]}</label>
|
|
271
|
-
</DataListCell>
|
|
272
|
-
]}
|
|
273
|
-
/>
|
|
274
|
-
</DataListItemRow>
|
|
275
|
-
</DataListItem>
|
|
276
|
-
<DataListItem aria-labelledby="table-column-management-item4">
|
|
277
|
-
<DataListItemRow>
|
|
278
|
-
<DataListCheck
|
|
279
|
-
aria-labelledby="table-column-management-item4"
|
|
280
|
-
checked={checkedState[3]}
|
|
281
|
-
name="check4"
|
|
282
|
-
id="check4"
|
|
283
|
-
onChange={handleChange}
|
|
284
|
-
/>
|
|
285
|
-
<DataListItemCells
|
|
286
|
-
dataListCells={[
|
|
287
|
-
<DataListCell id="table-column-management-item4" key="table-column-management-item4">
|
|
288
|
-
<label htmlFor="check4">{columns[3]}</label>
|
|
289
|
-
</DataListCell>
|
|
290
|
-
]}
|
|
291
|
-
/>
|
|
292
|
-
</DataListItemRow>
|
|
293
|
-
</DataListItem>
|
|
294
|
-
<DataListItem aria-labelledby="table-column-management-item4">
|
|
295
|
-
<DataListItemRow>
|
|
296
|
-
<DataListCheck
|
|
297
|
-
aria-labelledby="table-column-management-item4"
|
|
298
|
-
checked={checkedState[4]}
|
|
299
|
-
name="check5"
|
|
300
|
-
id="check5"
|
|
301
|
-
onChange={handleChange}
|
|
302
|
-
/>
|
|
303
|
-
<DataListItemCells
|
|
304
|
-
dataListCells={[
|
|
305
|
-
<DataListCell id="table-column-management-item4" key="table-column-management-item4">
|
|
306
|
-
<label htmlFor="check5">{columns[4]}</label>
|
|
307
|
-
</DataListCell>
|
|
308
|
-
]}
|
|
309
|
-
/>
|
|
310
|
-
</DataListItemRow>
|
|
311
|
-
</DataListItem>
|
|
312
|
-
<DataListItem aria-labelledby="table-column-management-item5">
|
|
313
|
-
<DataListItemRow>
|
|
314
|
-
<DataListCheck
|
|
315
|
-
aria-labelledby="table-column-management-item5"
|
|
316
|
-
checked={checkedState[5]}
|
|
317
|
-
name="check6"
|
|
318
|
-
id="check6"
|
|
319
|
-
onChange={handleChange}
|
|
320
|
-
/>
|
|
321
|
-
<DataListItemCells
|
|
322
|
-
dataListCells={[
|
|
323
|
-
<DataListCell id="table-column-management-item5" key="table-column-management-item5">
|
|
324
|
-
<label htmlFor="check6">{columns[5]}</label>
|
|
325
|
-
</DataListCell>
|
|
326
|
-
]}
|
|
327
|
-
/>
|
|
328
|
-
</DataListItemRow>
|
|
329
|
-
</DataListItem>
|
|
330
|
-
<DataListItem aria-labelledby="table-column-management-item6">
|
|
331
|
-
<DataListItemRow>
|
|
332
|
-
<DataListCheck
|
|
333
|
-
aria-labelledby="table-column-management-item6"
|
|
334
|
-
checked={checkedState[6]}
|
|
335
|
-
name="check7"
|
|
336
|
-
id="check7"
|
|
337
|
-
onChange={handleChange}
|
|
338
|
-
/>
|
|
339
|
-
<DataListItemCells
|
|
340
|
-
dataListCells={[
|
|
341
|
-
<DataListCell id="table-column-management-item6" key="table-column-management-item5">
|
|
342
|
-
<label htmlFor="check7">{columns[6]}</label>
|
|
343
|
-
</DataListCell>
|
|
344
|
-
]}
|
|
345
|
-
/>
|
|
346
|
-
</DataListItemRow>
|
|
347
|
-
</DataListItem>
|
|
348
|
-
<DataListItem aria-labelledby="table-column-management-item5">
|
|
349
|
-
<DataListItemRow>
|
|
350
|
-
<DataListCheck
|
|
351
|
-
aria-labelledby="table-column-management-item5"
|
|
352
|
-
checked={checkedState[7]}
|
|
353
|
-
name="check8"
|
|
354
|
-
id="check8"
|
|
355
|
-
onChange={handleChange}
|
|
356
|
-
/>
|
|
357
|
-
<DataListItemCells
|
|
358
|
-
dataListCells={[
|
|
359
|
-
<DataListCell id="table-column-management-item7" key="table-column-management-item7">
|
|
360
|
-
<label htmlFor="check8">{columns[7]}</label>
|
|
361
|
-
</DataListCell>
|
|
362
|
-
]}
|
|
363
|
-
/>
|
|
364
|
-
</DataListItemRow>
|
|
365
|
-
</DataListItem>
|
|
366
|
-
</DataList>
|
|
367
|
-
</Modal>
|
|
368
|
-
);
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
const renderLabel = (labelText) => {
|
|
372
|
-
switch (labelText) {
|
|
373
|
-
case 'Running':
|
|
374
|
-
return <Label color="green">{labelText}</Label>;
|
|
375
|
-
case 'Stopped':
|
|
376
|
-
return <Label color="orange">{labelText}</Label>;
|
|
377
|
-
case 'Needs Maintenance':
|
|
378
|
-
return <Label color="blue">{labelText}</Label>;
|
|
379
|
-
case 'Down':
|
|
380
|
-
return <Label color="red">{labelText}</Label>;
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
const toolbarItems = (
|
|
385
|
-
<React.Fragment>
|
|
386
|
-
<Toolbar id="page-layout-table-column-management-action-toolbar-top">
|
|
387
|
-
<span id="page-layout-table-column-management-action-toolbar-top-select-checkbox-label" hidden>
|
|
388
|
-
Choose one
|
|
389
|
-
</span>
|
|
390
|
-
<ToolbarContent>
|
|
391
|
-
<ToolbarItem variant="overflow-menu">
|
|
392
|
-
<OverflowMenu breakpoint="md">
|
|
393
|
-
<OverflowMenuItem>
|
|
394
|
-
<MenuToggle>
|
|
395
|
-
<FilterIcon /> Name
|
|
396
|
-
</MenuToggle>
|
|
397
|
-
</OverflowMenuItem>
|
|
398
|
-
<OverflowMenuItem>
|
|
399
|
-
<MenuToggle variant="plain" aria-label="Sort columns">
|
|
400
|
-
<SortAmountDownIcon aria-hidden="true" />
|
|
401
|
-
</MenuToggle>
|
|
402
|
-
</OverflowMenuItem>
|
|
403
|
-
<OverflowMenuGroup groupType="button" isPersistent>
|
|
404
|
-
<OverflowMenuItem>
|
|
405
|
-
<Button variant="primary">Action</Button>
|
|
406
|
-
</OverflowMenuItem>
|
|
407
|
-
<OverflowMenuItem breakpoint="md" isPersistent>
|
|
408
|
-
<Button variant="link" onClick={handleModalToggle}>
|
|
409
|
-
Manage columns
|
|
410
|
-
</Button>
|
|
411
|
-
</OverflowMenuItem>
|
|
412
|
-
</OverflowMenuGroup>
|
|
413
|
-
</OverflowMenu>
|
|
414
|
-
</ToolbarItem>
|
|
415
|
-
<ToolbarItem variant="pagination">{renderPagination(PaginationVariant.top)}</ToolbarItem>
|
|
416
|
-
</ToolbarContent>
|
|
417
|
-
</Toolbar>
|
|
418
|
-
</React.Fragment>
|
|
419
|
-
);
|
|
420
|
-
|
|
421
|
-
return (
|
|
422
|
-
<React.Fragment>
|
|
423
|
-
<DashboardWrapper hasPageTemplateTitle>
|
|
424
|
-
<PageSection isFilled>
|
|
425
|
-
<Card>
|
|
426
|
-
{toolbarItems}
|
|
427
|
-
<Table variant="compact" aria-label="Column Management Table">
|
|
428
|
-
<Thead>
|
|
429
|
-
<Tr>
|
|
430
|
-
{managedColumns.map((column, columnIndex) => (
|
|
431
|
-
<Th key={columnIndex}>{column}</Th>
|
|
432
|
-
))}
|
|
433
|
-
</Tr>
|
|
434
|
-
</Thead>
|
|
435
|
-
<Tbody>
|
|
436
|
-
{paginatedRows.map((row, rowIndex) => (
|
|
437
|
-
<Tr key={rowIndex}>
|
|
438
|
-
<>
|
|
439
|
-
{Object.entries(row).map(([key, value]) =>
|
|
440
|
-
key === 'status' ? (
|
|
441
|
-
<Td width={15} dataLabel="Status">
|
|
442
|
-
{renderLabel(value)}
|
|
443
|
-
</Td>
|
|
444
|
-
) : key === 'url' ? (
|
|
445
|
-
<Td width={10} dataLabel="URL" modifier="truncate">
|
|
446
|
-
<TableText>
|
|
447
|
-
<a href="#">{row.url}</a>
|
|
448
|
-
</TableText>
|
|
449
|
-
</Td>
|
|
450
|
-
) : (
|
|
451
|
-
<Td
|
|
452
|
-
width={key === 'name' ? 15 : 10}
|
|
453
|
-
dataLabel={key === 'lastModified' ? 'Last modified' : capitalize(key)}
|
|
454
|
-
>
|
|
455
|
-
{value}
|
|
456
|
-
</Td>
|
|
457
|
-
)
|
|
458
|
-
)}
|
|
459
|
-
</>
|
|
460
|
-
</Tr>
|
|
461
|
-
))}
|
|
462
|
-
</Tbody>
|
|
463
|
-
</Table>
|
|
464
|
-
{renderPagination(PaginationVariant.bottom)}
|
|
465
|
-
{renderModal()}
|
|
466
|
-
</Card>
|
|
467
|
-
</PageSection>
|
|
468
|
-
</DashboardWrapper>
|
|
469
|
-
</React.Fragment>
|
|
470
|
-
);
|
|
471
|
-
};
|