@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
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
DataList,
|
|
5
|
+
DataListCheck,
|
|
6
|
+
DataListControl,
|
|
7
|
+
DataListDragButton,
|
|
8
|
+
DataListItem,
|
|
9
|
+
DataListItemRow,
|
|
10
|
+
DataListCell,
|
|
11
|
+
DataListItemCells,
|
|
12
|
+
Toolbar,
|
|
13
|
+
ToolbarContent,
|
|
14
|
+
ToolbarItem,
|
|
15
|
+
Modal,
|
|
16
|
+
OverflowMenu,
|
|
17
|
+
OverflowMenuGroup,
|
|
18
|
+
OverflowMenuItem,
|
|
19
|
+
Text,
|
|
20
|
+
TextContent,
|
|
21
|
+
TextVariants,
|
|
22
|
+
MenuToggle
|
|
23
|
+
} from '@patternfly/react-core';
|
|
24
|
+
import { Table as TableDeprecated, TableHeader, TableBody } from '@patternfly/react-table/deprecated';
|
|
25
|
+
import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
|
|
26
|
+
import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
|
|
27
|
+
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
|
|
28
|
+
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
29
|
+
import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
|
|
30
|
+
|
|
31
|
+
interface RowType {
|
|
32
|
+
cells: (
|
|
33
|
+
| {
|
|
34
|
+
title: React.JSX.Element;
|
|
35
|
+
props: {
|
|
36
|
+
column: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
title: string;
|
|
41
|
+
props: {
|
|
42
|
+
column: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
)[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const TableColumnManagementWithDraggable: React.FunctionComponent = () => {
|
|
49
|
+
const actions = [
|
|
50
|
+
{
|
|
51
|
+
title: <a href="#">Link</a>
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
title: 'Action'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
isSeparator: true
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
title: <a href="#">Separated link</a>
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
const defaultColumns: string[] = ['Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit', ''];
|
|
64
|
+
const defaultRows = [
|
|
65
|
+
{
|
|
66
|
+
cells: [
|
|
67
|
+
{
|
|
68
|
+
title: (
|
|
69
|
+
<React.Fragment>
|
|
70
|
+
<div>Node 1</div>
|
|
71
|
+
<a href="#">siemur/test-space</a>
|
|
72
|
+
</React.Fragment>
|
|
73
|
+
),
|
|
74
|
+
props: { column: 'Repositories' }
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
title: (
|
|
78
|
+
<React.Fragment>
|
|
79
|
+
<CodeBranchIcon key="icon" /> 10
|
|
80
|
+
</React.Fragment>
|
|
81
|
+
),
|
|
82
|
+
props: { column: 'Branches' }
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
title: (
|
|
86
|
+
<React.Fragment>
|
|
87
|
+
<CodeIcon key="icon" /> 25
|
|
88
|
+
</React.Fragment>
|
|
89
|
+
),
|
|
90
|
+
props: { column: 'Pull requests' }
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
title: (
|
|
94
|
+
<React.Fragment>
|
|
95
|
+
<CubeIcon key="icon" /> 5
|
|
96
|
+
</React.Fragment>
|
|
97
|
+
),
|
|
98
|
+
props: { column: 'Workspaces' }
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
title: '2 days ago',
|
|
102
|
+
props: { column: 'Last commit' }
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
title: (
|
|
106
|
+
<React.Fragment>
|
|
107
|
+
<a href="#">Action link</a>
|
|
108
|
+
</React.Fragment>
|
|
109
|
+
),
|
|
110
|
+
props: { column: '' }
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
cells: [
|
|
116
|
+
{
|
|
117
|
+
title: (
|
|
118
|
+
<React.Fragment>
|
|
119
|
+
<div>Node 2</div>
|
|
120
|
+
<a href="#">siemur/test-space</a>
|
|
121
|
+
</React.Fragment>
|
|
122
|
+
),
|
|
123
|
+
props: { column: 'Repositories' }
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
title: (
|
|
127
|
+
<React.Fragment>
|
|
128
|
+
<CodeBranchIcon key="icon" /> 8
|
|
129
|
+
</React.Fragment>
|
|
130
|
+
),
|
|
131
|
+
props: { column: 'Branches' }
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
title: (
|
|
135
|
+
<React.Fragment>
|
|
136
|
+
<CodeIcon key="icon" /> 30
|
|
137
|
+
</React.Fragment>
|
|
138
|
+
),
|
|
139
|
+
props: { column: 'Pull requests' }
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
title: (
|
|
143
|
+
<React.Fragment>
|
|
144
|
+
<CubeIcon key="icon" /> 2
|
|
145
|
+
</React.Fragment>
|
|
146
|
+
),
|
|
147
|
+
props: { column: 'Workspaces' }
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
title: '2 days ago',
|
|
151
|
+
props: { column: 'Last commit' }
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
title: (
|
|
155
|
+
<React.Fragment>
|
|
156
|
+
<a href="#">Action link</a>
|
|
157
|
+
</React.Fragment>
|
|
158
|
+
),
|
|
159
|
+
props: { column: '' }
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
cells: [
|
|
165
|
+
{
|
|
166
|
+
title: (
|
|
167
|
+
<React.Fragment>
|
|
168
|
+
<div>Node 3</div>
|
|
169
|
+
<a href="#">siemur/test-space</a>
|
|
170
|
+
</React.Fragment>
|
|
171
|
+
),
|
|
172
|
+
props: { column: 'Repositories' }
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
title: (
|
|
176
|
+
<React.Fragment>
|
|
177
|
+
<CodeBranchIcon key="icon" /> 12
|
|
178
|
+
</React.Fragment>
|
|
179
|
+
),
|
|
180
|
+
props: { column: 'Branches' }
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
title: (
|
|
184
|
+
<React.Fragment>
|
|
185
|
+
<CodeIcon key="icon" /> 48
|
|
186
|
+
</React.Fragment>
|
|
187
|
+
),
|
|
188
|
+
props: { column: 'Pull requests' }
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
title: (
|
|
192
|
+
<React.Fragment>
|
|
193
|
+
<CubeIcon key="icon" /> 13
|
|
194
|
+
</React.Fragment>
|
|
195
|
+
),
|
|
196
|
+
props: { column: 'Workspaces' }
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
title: '30 days ago',
|
|
200
|
+
props: { column: 'Last commit' }
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
title: (
|
|
204
|
+
<React.Fragment>
|
|
205
|
+
<a href="#">Action link</a>
|
|
206
|
+
</React.Fragment>
|
|
207
|
+
),
|
|
208
|
+
props: { column: '' }
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
cells: [
|
|
214
|
+
{
|
|
215
|
+
title: (
|
|
216
|
+
<React.Fragment>
|
|
217
|
+
<div>Node 4</div>
|
|
218
|
+
<a href="#">siemur/test-space</a>
|
|
219
|
+
</React.Fragment>
|
|
220
|
+
),
|
|
221
|
+
props: { column: 'Repositories' }
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
title: (
|
|
225
|
+
<React.Fragment>
|
|
226
|
+
<CodeBranchIcon key="icon" /> 3
|
|
227
|
+
</React.Fragment>
|
|
228
|
+
),
|
|
229
|
+
props: { column: 'Branches' }
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
title: (
|
|
233
|
+
<React.Fragment>
|
|
234
|
+
<CodeIcon key="icon" /> 8
|
|
235
|
+
</React.Fragment>
|
|
236
|
+
),
|
|
237
|
+
props: { column: 'Pull requests' }
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
title: (
|
|
241
|
+
<React.Fragment>
|
|
242
|
+
<CubeIcon key="icon" /> 20
|
|
243
|
+
</React.Fragment>
|
|
244
|
+
),
|
|
245
|
+
props: { column: 'Workspaces' }
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
title: '8 days ago',
|
|
249
|
+
props: { column: 'Last commit' }
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
title: (
|
|
253
|
+
<React.Fragment>
|
|
254
|
+
<a href="#">Action link</a>
|
|
255
|
+
</React.Fragment>
|
|
256
|
+
),
|
|
257
|
+
props: { column: '' }
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
cells: [
|
|
263
|
+
{
|
|
264
|
+
title: (
|
|
265
|
+
<React.Fragment>
|
|
266
|
+
<div>Node 5</div>
|
|
267
|
+
<a href="#">siemur/test-space</a>
|
|
268
|
+
</React.Fragment>
|
|
269
|
+
),
|
|
270
|
+
props: { column: 'Repositories' }
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
title: (
|
|
274
|
+
<React.Fragment>
|
|
275
|
+
<CodeBranchIcon key="icon" /> 34
|
|
276
|
+
</React.Fragment>
|
|
277
|
+
),
|
|
278
|
+
props: { column: 'Branches' }
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
title: (
|
|
282
|
+
<React.Fragment>
|
|
283
|
+
<CodeIcon key="icon" /> 21
|
|
284
|
+
</React.Fragment>
|
|
285
|
+
),
|
|
286
|
+
props: { column: 'Pull requests' }
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
title: (
|
|
290
|
+
<React.Fragment>
|
|
291
|
+
<CubeIcon key="icon" /> 26
|
|
292
|
+
</React.Fragment>
|
|
293
|
+
),
|
|
294
|
+
props: { column: 'Workspaces' }
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
title: '2 days ago',
|
|
298
|
+
props: { column: 'Last commit' }
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
title: (
|
|
302
|
+
<React.Fragment>
|
|
303
|
+
<a href="#">Action link</a>
|
|
304
|
+
</React.Fragment>
|
|
305
|
+
),
|
|
306
|
+
props: { column: '' }
|
|
307
|
+
}
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
];
|
|
311
|
+
|
|
312
|
+
const [filters, setFilters] = React.useState<string[]>([]);
|
|
313
|
+
const [filteredColumns, setFilteredColumns] = React.useState<string[]>([]);
|
|
314
|
+
const [columns, setColumns] = React.useState<string[]>(defaultColumns);
|
|
315
|
+
const [rows, setRows] = React.useState(defaultRows);
|
|
316
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
317
|
+
const [check1, setCheck1] = React.useState(true);
|
|
318
|
+
const [check2, setCheck2] = React.useState(true);
|
|
319
|
+
const [check3, setCheck3] = React.useState(true);
|
|
320
|
+
const [check4, setCheck4] = React.useState(true);
|
|
321
|
+
const [check5, setCheck5] = React.useState(true);
|
|
322
|
+
|
|
323
|
+
const matchCheckboxNameToColumn = (name: string) => {
|
|
324
|
+
switch (name) {
|
|
325
|
+
case 'check1':
|
|
326
|
+
return 'Repositories';
|
|
327
|
+
case 'check2':
|
|
328
|
+
return 'Branches';
|
|
329
|
+
case 'check3':
|
|
330
|
+
return 'Pull requests';
|
|
331
|
+
case 'check4':
|
|
332
|
+
return 'Workspaces';
|
|
333
|
+
case 'check5':
|
|
334
|
+
return 'Last commit';
|
|
335
|
+
default:
|
|
336
|
+
return '';
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
const filterData = (checked: boolean, name: string) => {
|
|
341
|
+
if (checked) {
|
|
342
|
+
const updatedFilters = filters.filter((item) => item !== name);
|
|
343
|
+
const updatedFilteredColumns = defaultColumns.filter((column) => !updatedFilters.includes(column));
|
|
344
|
+
setFilters(updatedFilters);
|
|
345
|
+
setFilteredColumns(updatedFilteredColumns);
|
|
346
|
+
} else {
|
|
347
|
+
const updatedFilters = filters;
|
|
348
|
+
updatedFilters.push(name);
|
|
349
|
+
const updatedFilteredColumns = columns.filter((column) => !filters.includes(column));
|
|
350
|
+
setFilters(updatedFilters);
|
|
351
|
+
setFilteredColumns(updatedFilteredColumns);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
const unfilterAllData = () => {
|
|
355
|
+
setFilters([]);
|
|
356
|
+
setFilteredColumns(defaultColumns);
|
|
357
|
+
};
|
|
358
|
+
const handleChange = (event: React.FormEvent<HTMLInputElement>, checked: boolean) => {
|
|
359
|
+
const target = event.currentTarget;
|
|
360
|
+
const name = target.name;
|
|
361
|
+
|
|
362
|
+
const value = target.type === 'checkbox' ? checked : !!target.value;
|
|
363
|
+
filterData(checked, matchCheckboxNameToColumn(target.name));
|
|
364
|
+
switch (name) {
|
|
365
|
+
case 'check1':
|
|
366
|
+
setCheck1(value);
|
|
367
|
+
break;
|
|
368
|
+
case 'check2':
|
|
369
|
+
setCheck2(value);
|
|
370
|
+
break;
|
|
371
|
+
case 'check3':
|
|
372
|
+
setCheck3(value);
|
|
373
|
+
break;
|
|
374
|
+
case 'check4':
|
|
375
|
+
setCheck4(value);
|
|
376
|
+
break;
|
|
377
|
+
case 'check5':
|
|
378
|
+
setCheck5(value);
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
const handleModalToggle = (_event: KeyboardEvent | React.MouseEvent) => {
|
|
383
|
+
setIsModalOpen(!isModalOpen);
|
|
384
|
+
};
|
|
385
|
+
const onSave = () => {
|
|
386
|
+
// concat empty string at the end for actions column
|
|
387
|
+
const filteredOrderedColumns: string[] = columns
|
|
388
|
+
.filter((col) => filteredColumns.length === 0 || filteredColumns.indexOf(col as string) > -1)
|
|
389
|
+
.concat(['']);
|
|
390
|
+
const orderedRows: RowType[] = [];
|
|
391
|
+
defaultRows.forEach((row) => {
|
|
392
|
+
const updatedCells = row.cells
|
|
393
|
+
.filter((cell) => filteredOrderedColumns.indexOf(cell.props.column) > -1)
|
|
394
|
+
.sort((cellA, cellB) => {
|
|
395
|
+
const indexA = filteredOrderedColumns.indexOf(cellA.props.column);
|
|
396
|
+
const indexB = filteredOrderedColumns.indexOf(cellB.props.column);
|
|
397
|
+
if (indexA < indexB) {
|
|
398
|
+
return -1;
|
|
399
|
+
}
|
|
400
|
+
if (indexA > indexB) {
|
|
401
|
+
return 1;
|
|
402
|
+
}
|
|
403
|
+
// a must be equal to b
|
|
404
|
+
return 0;
|
|
405
|
+
});
|
|
406
|
+
orderedRows.push({
|
|
407
|
+
cells: updatedCells
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
setColumns(filteredOrderedColumns as string[]);
|
|
411
|
+
setRows(orderedRows);
|
|
412
|
+
setIsModalOpen(!isModalOpen);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
const selectAllColumns = () => {
|
|
416
|
+
unfilterAllData();
|
|
417
|
+
setCheck1(true);
|
|
418
|
+
setCheck2(true);
|
|
419
|
+
setCheck3(true);
|
|
420
|
+
setCheck4(true);
|
|
421
|
+
setCheck5(true);
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
const renderModal = () => (
|
|
425
|
+
<Modal
|
|
426
|
+
title="Manage columns"
|
|
427
|
+
isOpen={isModalOpen}
|
|
428
|
+
variant="small"
|
|
429
|
+
description={
|
|
430
|
+
<TextContent>
|
|
431
|
+
<Text component={TextVariants.p}>Selected categories will be displayed in the table.</Text>
|
|
432
|
+
<Button isInline onClick={selectAllColumns} variant="link">
|
|
433
|
+
Select all
|
|
434
|
+
</Button>
|
|
435
|
+
</TextContent>
|
|
436
|
+
}
|
|
437
|
+
onClose={handleModalToggle}
|
|
438
|
+
actions={[
|
|
439
|
+
<Button key="save" variant="primary" onClick={onSave}>
|
|
440
|
+
Save
|
|
441
|
+
</Button>,
|
|
442
|
+
<Button key="cancel" variant="secondary" onClick={handleModalToggle}>
|
|
443
|
+
Cancel
|
|
444
|
+
</Button>
|
|
445
|
+
]}
|
|
446
|
+
>
|
|
447
|
+
<DataList aria-label="Table column management" id="table-column-management" isCompact>
|
|
448
|
+
<DataListItem aria-labelledby="table-column-management-item1" id="data1">
|
|
449
|
+
<DataListItemRow>
|
|
450
|
+
<DataListControl>
|
|
451
|
+
<DataListDragButton
|
|
452
|
+
aria-label="Reorder"
|
|
453
|
+
aria-labelledby="table-column-management-item1"
|
|
454
|
+
aria-describedby="Press space or enter to begin dragging, and use the arrow keys to navigate up or down. Press enter to confirm the drag, or any other key to cancel the drag operation."
|
|
455
|
+
aria-pressed="false"
|
|
456
|
+
/>
|
|
457
|
+
<DataListCheck
|
|
458
|
+
aria-labelledby="table-column-management-item1"
|
|
459
|
+
checked={check1}
|
|
460
|
+
name="check1"
|
|
461
|
+
id="check1"
|
|
462
|
+
onChange={handleChange}
|
|
463
|
+
otherControls
|
|
464
|
+
/>
|
|
465
|
+
</DataListControl>
|
|
466
|
+
<DataListItemCells
|
|
467
|
+
dataListCells={[
|
|
468
|
+
<DataListCell id="table-column-management-item1" key="table-column-management-item1">
|
|
469
|
+
<label htmlFor="check1">Repositories</label>
|
|
470
|
+
</DataListCell>
|
|
471
|
+
]}
|
|
472
|
+
/>
|
|
473
|
+
</DataListItemRow>
|
|
474
|
+
</DataListItem>
|
|
475
|
+
<DataListItem aria-labelledby="table-column-management-item2" id="data2">
|
|
476
|
+
<DataListItemRow>
|
|
477
|
+
<DataListControl>
|
|
478
|
+
<DataListDragButton
|
|
479
|
+
aria-label="Reorder"
|
|
480
|
+
aria-labelledby="table-column-management-item2"
|
|
481
|
+
aria-describedby="Press space or enter to begin dragging, and use the arrow keys to navigate up or down. Press enter to confirm the drag, or any other key to cancel the drag operation."
|
|
482
|
+
aria-pressed="false"
|
|
483
|
+
/>
|
|
484
|
+
<DataListCheck
|
|
485
|
+
aria-labelledby="table-column-management-item2"
|
|
486
|
+
checked={check2}
|
|
487
|
+
name="check2"
|
|
488
|
+
id="check2"
|
|
489
|
+
onChange={handleChange}
|
|
490
|
+
otherControls
|
|
491
|
+
/>
|
|
492
|
+
</DataListControl>
|
|
493
|
+
<DataListItemCells
|
|
494
|
+
dataListCells={[
|
|
495
|
+
<DataListCell id="table-column-management-item2" key="table-column-management-item2">
|
|
496
|
+
<label htmlFor="check2">Branches</label>
|
|
497
|
+
</DataListCell>
|
|
498
|
+
]}
|
|
499
|
+
/>
|
|
500
|
+
</DataListItemRow>
|
|
501
|
+
</DataListItem>
|
|
502
|
+
<DataListItem aria-labelledby="table-column-management-item3" id="data3">
|
|
503
|
+
<DataListItemRow>
|
|
504
|
+
<DataListControl>
|
|
505
|
+
<DataListDragButton
|
|
506
|
+
aria-label="Reorder"
|
|
507
|
+
aria-labelledby="table-column-management-item3"
|
|
508
|
+
aria-describedby="Press space or enter to begin dragging, and use the arrow keys to navigate up or down. Press enter to confirm the drag, or any other key to cancel the drag operation."
|
|
509
|
+
aria-pressed="false"
|
|
510
|
+
/>
|
|
511
|
+
<DataListCheck
|
|
512
|
+
aria-labelledby="table-column-management-item3"
|
|
513
|
+
checked={check3}
|
|
514
|
+
name="check3"
|
|
515
|
+
id="check3"
|
|
516
|
+
onChange={handleChange}
|
|
517
|
+
otherControls
|
|
518
|
+
/>
|
|
519
|
+
</DataListControl>
|
|
520
|
+
<DataListItemCells
|
|
521
|
+
dataListCells={[
|
|
522
|
+
<DataListCell id="table-column-management-item3" key="table-column-management-item3">
|
|
523
|
+
<label htmlFor="check3">Pull requests</label>
|
|
524
|
+
</DataListCell>
|
|
525
|
+
]}
|
|
526
|
+
/>
|
|
527
|
+
</DataListItemRow>
|
|
528
|
+
</DataListItem>
|
|
529
|
+
<DataListItem aria-labelledby="table-column-management-item4" id="data4">
|
|
530
|
+
<DataListItemRow>
|
|
531
|
+
<DataListControl>
|
|
532
|
+
<DataListDragButton
|
|
533
|
+
aria-label="Reorder"
|
|
534
|
+
aria-labelledby="table-column-management-item4"
|
|
535
|
+
aria-describedby="Press space or enter to begin dragging, and use the arrow keys to navigate up or down. Press enter to confirm the drag, or any other key to cancel the drag operation."
|
|
536
|
+
aria-pressed="false"
|
|
537
|
+
/>
|
|
538
|
+
<DataListCheck
|
|
539
|
+
aria-labelledby="table-column-management-item4"
|
|
540
|
+
checked={check4}
|
|
541
|
+
name="check4"
|
|
542
|
+
id="check4"
|
|
543
|
+
onChange={handleChange}
|
|
544
|
+
otherControls
|
|
545
|
+
/>
|
|
546
|
+
</DataListControl>
|
|
547
|
+
<DataListItemCells
|
|
548
|
+
dataListCells={[
|
|
549
|
+
<DataListCell id="table-column-management-item4" key="table-column-management-item4">
|
|
550
|
+
<label htmlFor="check4">Workspaces</label>
|
|
551
|
+
</DataListCell>
|
|
552
|
+
]}
|
|
553
|
+
/>
|
|
554
|
+
</DataListItemRow>
|
|
555
|
+
</DataListItem>
|
|
556
|
+
<DataListItem aria-labelledby="table-column-management-item5" id="data5">
|
|
557
|
+
<DataListItemRow>
|
|
558
|
+
<DataListControl>
|
|
559
|
+
<DataListDragButton
|
|
560
|
+
aria-label="Reorder"
|
|
561
|
+
aria-labelledby="table-column-management-item5"
|
|
562
|
+
aria-describedby="Press space or enter to begin dragging, and use the arrow keys to navigate up or down. Press enter to confirm the drag, or any other key to cancel the drag operation."
|
|
563
|
+
aria-pressed="false"
|
|
564
|
+
/>
|
|
565
|
+
<DataListCheck
|
|
566
|
+
aria-labelledby="table-column-management-item5"
|
|
567
|
+
checked={check5}
|
|
568
|
+
name="check5"
|
|
569
|
+
id="check5"
|
|
570
|
+
onChange={handleChange}
|
|
571
|
+
otherControls
|
|
572
|
+
/>
|
|
573
|
+
</DataListControl>
|
|
574
|
+
<DataListItemCells
|
|
575
|
+
dataListCells={[
|
|
576
|
+
<DataListCell id="table-column-management-item5" key="table-column-management-item5">
|
|
577
|
+
<label htmlFor="check5">Last commit</label>
|
|
578
|
+
</DataListCell>
|
|
579
|
+
]}
|
|
580
|
+
/>
|
|
581
|
+
</DataListItemRow>
|
|
582
|
+
</DataListItem>
|
|
583
|
+
</DataList>
|
|
584
|
+
</Modal>
|
|
585
|
+
);
|
|
586
|
+
|
|
587
|
+
const toolbarItems = (
|
|
588
|
+
<React.Fragment>
|
|
589
|
+
<span id="page-layout-table-draggable-column-management-action-toolbar-top-select-checkbox-label" hidden>
|
|
590
|
+
Choose one
|
|
591
|
+
</span>
|
|
592
|
+
<ToolbarContent>
|
|
593
|
+
<ToolbarItem variant="overflow-menu">
|
|
594
|
+
<OverflowMenu breakpoint="md">
|
|
595
|
+
<OverflowMenuItem isPersistent>
|
|
596
|
+
<MenuToggle>
|
|
597
|
+
<FilterIcon /> Name
|
|
598
|
+
</MenuToggle>
|
|
599
|
+
</OverflowMenuItem>
|
|
600
|
+
<OverflowMenuItem>
|
|
601
|
+
<MenuToggle variant="plain" aria-label="Sort columns">
|
|
602
|
+
<SortAmountDownIcon aria-hidden="true" />
|
|
603
|
+
</MenuToggle>
|
|
604
|
+
</OverflowMenuItem>
|
|
605
|
+
<OverflowMenuGroup groupType="button" isPersistent>
|
|
606
|
+
<OverflowMenuItem>
|
|
607
|
+
<Button variant="primary">Action</Button>
|
|
608
|
+
</OverflowMenuItem>
|
|
609
|
+
<OverflowMenuItem>
|
|
610
|
+
<Button variant="link" onClick={handleModalToggle}>
|
|
611
|
+
Manage columns
|
|
612
|
+
</Button>
|
|
613
|
+
</OverflowMenuItem>
|
|
614
|
+
</OverflowMenuGroup>
|
|
615
|
+
</OverflowMenu>
|
|
616
|
+
</ToolbarItem>
|
|
617
|
+
</ToolbarContent>
|
|
618
|
+
</React.Fragment>
|
|
619
|
+
);
|
|
620
|
+
|
|
621
|
+
return (
|
|
622
|
+
<React.Fragment>
|
|
623
|
+
<TableDeprecated
|
|
624
|
+
gridBreakPoint="grid-xl"
|
|
625
|
+
header={
|
|
626
|
+
<React.Fragment>
|
|
627
|
+
<Toolbar id="page-layout-table-draggable-column-management-action-toolbar-top">{toolbarItems}</Toolbar>
|
|
628
|
+
</React.Fragment>
|
|
629
|
+
}
|
|
630
|
+
aria-label="Column Management with Draggable Table"
|
|
631
|
+
cells={columns}
|
|
632
|
+
rows={rows}
|
|
633
|
+
actions={actions}
|
|
634
|
+
>
|
|
635
|
+
<TableHeader />
|
|
636
|
+
<TableBody />
|
|
637
|
+
</TableDeprecated>
|
|
638
|
+
{renderModal()}
|
|
639
|
+
</React.Fragment>
|
|
640
|
+
);
|
|
641
|
+
};
|