@rhc-shared-components/packages-table 1.0.3 → 2.0.0
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/dist/components/ExcludedPackagesTable.d.ts +6 -6
- package/dist/components/FilterInput.d.ts +6 -6
- package/dist/components/FilterableTable.d.ts +19 -19
- package/dist/components/Select.d.ts +9 -9
- package/dist/components/ToggleGroup.d.ts +10 -10
- package/dist/components/VulnerabilitiesTable.d.ts +7 -7
- package/dist/index.d.ts +14 -14
- package/dist/index.js +816 -971
- package/dist/index.modern.js +602 -709
- package/dist/index.test.d.ts +1 -1
- package/package.json +9 -11
- package/CHANGELOG.md +0 -79
package/dist/index.modern.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
3
|
+
import { useState, useEffect, useCallback, cloneElement } from 'react';
|
|
4
|
+
import { Toolbar, ToolbarContent, ToolbarItem, Bullseye, Title, Spinner, EmptyState, EmptyStateHeader, EmptyStateIcon, Pagination, SearchInput, ToggleGroup as ToggleGroup$1, ToggleGroupItem, Tabs, Tab } from '@patternfly/react-core';
|
|
4
5
|
import { sortBy, uniqueId } from 'lodash';
|
|
6
|
+
import { setTabIndex, handleArrows } from '@patternfly/react-core/dist/esm/helpers/KeyboardHandler';
|
|
7
|
+
import { useOUIAProps } from '@patternfly/react-core/dist/esm/helpers/OUIA/ouia';
|
|
5
8
|
import { useOUIAProps as useOUIAProps$1 } from '@patternfly/react-core/dist/esm/helpers';
|
|
6
9
|
import mergeWith from 'lodash/mergeWith';
|
|
7
10
|
import { Tooltip } from '@patternfly/react-core/dist/esm/components/Tooltip';
|
|
@@ -15,7 +18,17 @@ import { Checkbox } from '@patternfly/react-core/dist/esm/components/Checkbox';
|
|
|
15
18
|
import { Select, SelectOption } from '@patternfly/react-core/deprecated';
|
|
16
19
|
import { format } from 'date-fns';
|
|
17
20
|
|
|
18
|
-
var css_248z = ".vulnerabilities-table .impact-icon {\n font-size: 1.5rem;\n padding-right: 0.5rem;\n}\n.vulnerabilities-table .impact-icon.color-critical {\n color: #a30000;\n}\n.vulnerabilities-table .impact-icon.color-important {\n color: #ec7a08;\n}\n.vulnerabilities-table .impact-icon.color-moderate {\n color: #f5c12e;\n}\n.vulnerabilities-table .impact-icon.color-low {\n color: #777;\n}\n.vulnerabilities-table__affected-packages-cell {\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n}\n.vulnerabilities-table__impact-cell {\n display: flex;\n align-items: center;\n flex-wrap: nowrap;\n}\n\n.filterable-table {\n padding-bottom: var(--pf-v5-global--spacer--lg);\n}\n.filterable-table__bottom-pagination[class] {\n margin-top: 1rem;\n}\n.filterable-table .pf-v5-c-
|
|
21
|
+
var css_248z = ".vulnerabilities-table .impact-icon {\n font-size: 1.5rem;\n padding-right: 0.5rem;\n}\n.vulnerabilities-table .impact-icon.color-critical {\n color: #a30000;\n}\n.vulnerabilities-table .impact-icon.color-important {\n color: #ec7a08;\n}\n.vulnerabilities-table .impact-icon.color-moderate {\n color: #f5c12e;\n}\n.vulnerabilities-table .impact-icon.color-low {\n color: #777;\n}\n.vulnerabilities-table__affected-packages-cell {\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n}\n.vulnerabilities-table__impact-cell {\n display: flex;\n align-items: center;\n flex-wrap: nowrap;\n}\n\n.filterable-table {\n padding-bottom: var(--pf-v5-global--spacer--lg);\n}\n.filterable-table__bottom-pagination[class] {\n margin-top: 1rem;\n}\n.filterable-table .pf-v5-c-toolbar__content {\n --pf-v5-c-toolbar__content--PaddingRight: 0;\n --pf-v5-c-toolbar__content--PaddingLeft: 0;\n}\n.filterable-table .pf-v5-c-input-group__text {\n --pf-v5-c-input-group__text--PaddingRight: 0;\n}\n.filterable-table .pf-v5-c-pagination.pf-m-bottom {\n --pf-v5-c-pagination--m-bottom--md--PaddingRight: 0;\n}\n\n.packages-table .pf-v5-c-tabs__item > button {\n padding: 1rem 1.5rem;\n}\n.packages-table__excluded-packages-disclaimer {\n margin: 1rem 0 0 0.5rem;\n}\n\n.filter-input {\n width: 18rem;\n}";
|
|
22
|
+
|
|
23
|
+
function _extends() {
|
|
24
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
25
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
26
|
+
var t = arguments[e];
|
|
27
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
28
|
+
}
|
|
29
|
+
return n;
|
|
30
|
+
}, _extends.apply(null, arguments);
|
|
31
|
+
}
|
|
19
32
|
|
|
20
33
|
/******************************************************************************
|
|
21
34
|
Copyright (c) Microsoft Corporation.
|
|
@@ -31,52 +44,23 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
31
44
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
32
45
|
PERFORMANCE OF THIS SOFTWARE.
|
|
33
46
|
***************************************************************************** */
|
|
34
|
-
function __rest
|
|
47
|
+
function __rest(s, e) {
|
|
35
48
|
var t = {};
|
|
36
|
-
|
|
37
49
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
38
|
-
|
|
39
50
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
40
51
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
41
52
|
}
|
|
42
53
|
return t;
|
|
43
54
|
}
|
|
44
|
-
|
|
45
55
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
46
56
|
var e = new Error(message);
|
|
47
57
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
48
58
|
};
|
|
49
59
|
|
|
50
|
-
/*! *****************************************************************************
|
|
51
|
-
Copyright (c) Microsoft Corporation.
|
|
52
|
-
|
|
53
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
54
|
-
purpose with or without fee is hereby granted.
|
|
55
|
-
|
|
56
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
57
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
58
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
59
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
60
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
61
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
62
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
63
|
-
***************************************************************************** */
|
|
64
|
-
function __rest(s, e) {
|
|
65
|
-
var t = {};
|
|
66
|
-
|
|
67
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
68
|
-
|
|
69
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
70
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
71
|
-
}
|
|
72
|
-
return t;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
60
|
let currentId = 0;
|
|
76
61
|
/**
|
|
77
62
|
* Factory to create Icon class components for consumers
|
|
78
63
|
*/
|
|
79
|
-
|
|
80
64
|
function createIcon({
|
|
81
65
|
name,
|
|
82
66
|
xOffset = 0,
|
|
@@ -86,21 +70,18 @@ function createIcon({
|
|
|
86
70
|
svgPath
|
|
87
71
|
}) {
|
|
88
72
|
var _a;
|
|
89
|
-
|
|
90
73
|
return _a = class SVGIcon extends React.Component {
|
|
91
74
|
constructor() {
|
|
92
75
|
super(...arguments);
|
|
93
76
|
this.id = `icon-title-${currentId++}`;
|
|
94
77
|
}
|
|
95
|
-
|
|
96
78
|
render() {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
79
|
+
const _b = this.props,
|
|
80
|
+
{
|
|
81
|
+
title,
|
|
82
|
+
className
|
|
83
|
+
} = _b,
|
|
84
|
+
props = __rest(_b, ["title", "className"]);
|
|
104
85
|
const classes = className ? `pf-v5-svg ${className}` : 'pf-v5-svg';
|
|
105
86
|
const hasTitle = Boolean(title);
|
|
106
87
|
const viewBox = [xOffset, yOffset, width, height].join(' ');
|
|
@@ -119,7 +100,6 @@ function createIcon({
|
|
|
119
100
|
d: svgPath
|
|
120
101
|
}));
|
|
121
102
|
}
|
|
122
|
-
|
|
123
103
|
}, _a.displayName = name, _a;
|
|
124
104
|
}
|
|
125
105
|
|
|
@@ -136,46 +116,42 @@ var EllipsisVIcon$1 = EllipsisVIcon;
|
|
|
136
116
|
|
|
137
117
|
const ActionsColumnBase = _a => {
|
|
138
118
|
var {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
119
|
+
items,
|
|
120
|
+
isDisabled,
|
|
121
|
+
rowData,
|
|
122
|
+
extraData,
|
|
123
|
+
actionsToggle,
|
|
124
|
+
popperProps = {
|
|
125
|
+
position: 'end',
|
|
126
|
+
direction: 'down'
|
|
127
|
+
},
|
|
128
|
+
innerRef,
|
|
129
|
+
firstActionItemRef,
|
|
130
|
+
isOnOpenChangeDisabled = false
|
|
131
|
+
} = _a,
|
|
132
|
+
props = __rest(_a, ["items", "isDisabled", "rowData", "extraData", "actionsToggle", "popperProps", "innerRef", "firstActionItemRef", "isOnOpenChangeDisabled"]);
|
|
154
133
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
155
|
-
|
|
156
134
|
const onToggle = () => {
|
|
157
135
|
setIsOpen(!isOpen);
|
|
158
136
|
};
|
|
159
|
-
|
|
160
137
|
const onActionClick = (event, onClick) => {
|
|
161
138
|
// Only prevent default if onClick is provided. This allows href support.
|
|
162
139
|
if (onClick) {
|
|
163
|
-
event.preventDefault();
|
|
164
|
-
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
// tslint:disable-next-line:no-unused-expression
|
|
165
142
|
onClick(event, extraData && extraData.rowIndex, rowData, extraData);
|
|
166
143
|
}
|
|
167
144
|
};
|
|
168
|
-
|
|
169
|
-
|
|
145
|
+
return React.createElement(React.Fragment, null, items.filter(item => item.isOutsideDropdown)
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
170
147
|
.map((_a, key) => {
|
|
171
148
|
var {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
149
|
+
title,
|
|
150
|
+
itemKey,
|
|
151
|
+
onClick,
|
|
152
|
+
isOutsideDropdown
|
|
153
|
+
} = _a,
|
|
154
|
+
props = __rest(_a, ["title", "itemKey", "onClick", "isOutsideDropdown"]);
|
|
179
155
|
return typeof title === 'string' ? React.createElement(Button, Object.assign({
|
|
180
156
|
onClick: event => onActionClick(event, onClick)
|
|
181
157
|
}, props, {
|
|
@@ -208,22 +184,20 @@ const ActionsColumnBase = _a => {
|
|
|
208
184
|
popperProps: popperProps
|
|
209
185
|
}), React.createElement(DropdownList, null, items.filter(item => !item.isOutsideDropdown).map((_a, index) => {
|
|
210
186
|
var {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
187
|
+
title,
|
|
188
|
+
itemKey,
|
|
189
|
+
onClick,
|
|
190
|
+
tooltipProps,
|
|
191
|
+
isSeparator,
|
|
192
|
+
shouldCloseOnClick = true
|
|
193
|
+
} = _a,
|
|
194
|
+
props = __rest(_a, ["title", "itemKey", "onClick", "tooltipProps", "isSeparator", "shouldCloseOnClick"]);
|
|
220
195
|
if (isSeparator) {
|
|
221
196
|
return React.createElement(Divider, {
|
|
222
197
|
key: itemKey || index,
|
|
223
198
|
"data-key": itemKey || index
|
|
224
199
|
});
|
|
225
200
|
}
|
|
226
|
-
|
|
227
201
|
const item = React.createElement(DropdownItem, Object.assign({
|
|
228
202
|
onClick: event => {
|
|
229
203
|
onActionClick(event, onClick);
|
|
@@ -234,7 +208,6 @@ const ActionsColumnBase = _a => {
|
|
|
234
208
|
"data-key": itemKey || index,
|
|
235
209
|
ref: index === 0 ? firstActionItemRef : undefined
|
|
236
210
|
}), title);
|
|
237
|
-
|
|
238
211
|
if (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.content) {
|
|
239
212
|
return React.createElement(Tooltip, Object.assign({
|
|
240
213
|
key: itemKey || index
|
|
@@ -244,7 +217,6 @@ const ActionsColumnBase = _a => {
|
|
|
244
217
|
}
|
|
245
218
|
}))));
|
|
246
219
|
};
|
|
247
|
-
|
|
248
220
|
const ActionsColumn = React.forwardRef((props, ref) => React.createElement(ActionsColumnBase, Object.assign({}, props, {
|
|
249
221
|
innerRef: ref
|
|
250
222
|
})));
|
|
@@ -271,12 +243,10 @@ function css(...args) {
|
|
|
271
243
|
const hasOwn = {}.hasOwnProperty;
|
|
272
244
|
args.filter(Boolean).forEach(arg => {
|
|
273
245
|
const argType = typeof arg;
|
|
274
|
-
|
|
275
246
|
if (argType === 'string' || argType === 'number') {
|
|
276
247
|
classes.push(arg);
|
|
277
248
|
} else if (Array.isArray(arg) && arg.length) {
|
|
278
249
|
const inner = css(...arg);
|
|
279
|
-
|
|
280
250
|
if (inner) {
|
|
281
251
|
classes.push(inner);
|
|
282
252
|
}
|
|
@@ -384,13 +354,12 @@ var styles$1 = {
|
|
|
384
354
|
|
|
385
355
|
const CollapseColumn = _a => {
|
|
386
356
|
var {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
357
|
+
className = '',
|
|
358
|
+
children = null,
|
|
359
|
+
isOpen,
|
|
360
|
+
onToggle
|
|
361
|
+
} = _a,
|
|
362
|
+
props = __rest(_a, ["className", "children", "isOpen", "onToggle"]);
|
|
394
363
|
return React.createElement(React.Fragment, null, isOpen !== undefined && React.createElement(Button, Object.assign({
|
|
395
364
|
className: css(className, isOpen && styles$1.modifiers.expanded)
|
|
396
365
|
}, props, {
|
|
@@ -417,13 +386,12 @@ var GripVerticalIcon$1 = GripVerticalIcon;
|
|
|
417
386
|
|
|
418
387
|
const DraggableCell = _a => {
|
|
419
388
|
var {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
389
|
+
className,
|
|
390
|
+
onClick,
|
|
391
|
+
'aria-label': ariaLabel,
|
|
392
|
+
id
|
|
393
|
+
} = _a,
|
|
394
|
+
props = __rest(_a, ["className", "onClick", 'aria-label', "id"]);
|
|
427
395
|
return React.createElement(Button, Object.assign({
|
|
428
396
|
id: id,
|
|
429
397
|
variant: "plain",
|
|
@@ -472,14 +440,11 @@ const HelpIcon = createIcon(HelpIconConfig);
|
|
|
472
440
|
var HelpIcon$1 = HelpIcon;
|
|
473
441
|
|
|
474
442
|
var TableTextVariant;
|
|
475
|
-
|
|
476
443
|
(function (TableTextVariant) {
|
|
477
444
|
TableTextVariant["div"] = "div";
|
|
478
445
|
TableTextVariant["nav"] = "nav";
|
|
479
446
|
})(TableTextVariant || (TableTextVariant = {}));
|
|
480
|
-
|
|
481
447
|
var WrapModifier;
|
|
482
|
-
|
|
483
448
|
(function (WrapModifier) {
|
|
484
449
|
WrapModifier["wrap"] = "wrap";
|
|
485
450
|
WrapModifier["nowrap"] = "nowrap";
|
|
@@ -487,35 +452,30 @@ var WrapModifier;
|
|
|
487
452
|
WrapModifier["breakWord"] = "breakWord";
|
|
488
453
|
WrapModifier["fitContent"] = "fitContent";
|
|
489
454
|
})(WrapModifier || (WrapModifier = {}));
|
|
490
|
-
|
|
491
455
|
const TableText = _a => {
|
|
492
456
|
var {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
457
|
+
children = null,
|
|
458
|
+
className = '',
|
|
459
|
+
variant = 'span',
|
|
460
|
+
wrapModifier = null,
|
|
461
|
+
tooltip: tooltipProp = '',
|
|
462
|
+
tooltipProps = {},
|
|
463
|
+
onMouseEnter: onMouseEnterProp = () => {},
|
|
464
|
+
focused = false,
|
|
465
|
+
tooltipHasDefaultBehavior = false
|
|
466
|
+
} = _a,
|
|
467
|
+
props = __rest(_a, ["children", "className", "variant", "wrapModifier", "tooltip", "tooltipProps", "onMouseEnter", "focused", "tooltipHasDefaultBehavior"]);
|
|
505
468
|
const Component = variant;
|
|
506
469
|
const textRef = React.createRef();
|
|
507
470
|
const [tooltip, setTooltip] = React.useState(tooltipProp);
|
|
508
|
-
|
|
509
471
|
const onMouseEnter = event => {
|
|
510
472
|
if (event.target.offsetWidth < event.target.scrollWidth) {
|
|
511
473
|
setTooltip(tooltipProp || event.target.innerText);
|
|
512
474
|
} else {
|
|
513
475
|
setTooltip('');
|
|
514
476
|
}
|
|
515
|
-
|
|
516
477
|
onMouseEnterProp(event);
|
|
517
478
|
};
|
|
518
|
-
|
|
519
479
|
const onFocus = element => {
|
|
520
480
|
if (element.offsetWidth < element.scrollWidth) {
|
|
521
481
|
setTooltip(tooltipProp || element.innerText);
|
|
@@ -523,7 +483,6 @@ const TableText = _a => {
|
|
|
523
483
|
setTooltip('');
|
|
524
484
|
}
|
|
525
485
|
};
|
|
526
|
-
|
|
527
486
|
const text = React.createElement(Component, Object.assign({
|
|
528
487
|
ref: textRef,
|
|
529
488
|
onMouseEnter: !tooltipHasDefaultBehavior ? onMouseEnter : undefined,
|
|
@@ -641,24 +600,21 @@ var treeViewStyles = {
|
|
|
641
600
|
};
|
|
642
601
|
|
|
643
602
|
var RowSelectVariant;
|
|
644
|
-
|
|
645
603
|
(function (RowSelectVariant) {
|
|
646
604
|
RowSelectVariant["radio"] = "radio";
|
|
647
605
|
RowSelectVariant["checkbox"] = "checkbox";
|
|
648
606
|
})(RowSelectVariant || (RowSelectVariant = {}));
|
|
649
|
-
|
|
650
607
|
const SelectColumn = _a => {
|
|
651
608
|
var {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
609
|
+
children = null,
|
|
610
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
611
|
+
className,
|
|
612
|
+
onSelect = null,
|
|
613
|
+
selectVariant,
|
|
614
|
+
tooltip,
|
|
615
|
+
tooltipProps
|
|
616
|
+
} = _a,
|
|
617
|
+
props = __rest(_a, ["children", "className", "onSelect", "selectVariant", "tooltip", "tooltipProps"]);
|
|
662
618
|
const inputRef = React.createRef();
|
|
663
619
|
const content = React.createElement(React.Fragment, null, React.createElement("label", null, React.createElement("input", Object.assign({}, props, {
|
|
664
620
|
ref: inputRef,
|
|
@@ -707,25 +663,21 @@ const selectable = (label, {
|
|
|
707
663
|
column,
|
|
708
664
|
property
|
|
709
665
|
};
|
|
710
|
-
|
|
711
666
|
if (rowData && rowData.hasOwnProperty('parent') && !rowData.showSelect && !rowData.fullWidth) {
|
|
712
667
|
return {
|
|
713
668
|
component: 'td',
|
|
714
669
|
isVisible: true
|
|
715
670
|
};
|
|
716
671
|
}
|
|
717
|
-
|
|
718
672
|
const rowId = rowIndex !== undefined ? rowIndex : -1;
|
|
719
673
|
/**
|
|
720
674
|
* @param {React.FormEvent} event - React form event
|
|
721
675
|
*/
|
|
722
|
-
|
|
723
676
|
function selectClick(event) {
|
|
724
|
-
const selected = rowIndex === undefined ? event.currentTarget.checked : rowData && !rowData.selected;
|
|
725
|
-
|
|
677
|
+
const selected = rowIndex === undefined ? event.currentTarget.checked : rowData && !rowData.selected;
|
|
678
|
+
// tslint:disable-next-line:no-unused-expression
|
|
726
679
|
onSelect && onSelect(event, selected, rowId, rowData, extraData);
|
|
727
680
|
}
|
|
728
|
-
|
|
729
681
|
const customProps = Object.assign(Object.assign(Object.assign({}, rowId !== -1 ? {
|
|
730
682
|
checked: rowData && !!rowData.selected,
|
|
731
683
|
'aria-label': `Select row ${rowIndex}`
|
|
@@ -739,13 +691,11 @@ const selectable = (label, {
|
|
|
739
691
|
disabled: true
|
|
740
692
|
});
|
|
741
693
|
let selectName = 'check-all';
|
|
742
|
-
|
|
743
694
|
if (rowId !== -1 && selectVariant === RowSelectVariant.checkbox) {
|
|
744
695
|
selectName = `checkrow${rowIndex}`;
|
|
745
696
|
} else if (rowId !== -1) {
|
|
746
697
|
selectName = 'radioGroup';
|
|
747
698
|
}
|
|
748
|
-
|
|
749
699
|
return {
|
|
750
700
|
className: css(styles$1.tableCheck),
|
|
751
701
|
component: rowId !== -1 ? 'td' : 'th',
|
|
@@ -793,35 +743,30 @@ const ArrowsAltVIcon = createIcon(ArrowsAltVIconConfig);
|
|
|
793
743
|
var ArrowsAltVIcon$1 = ArrowsAltVIcon;
|
|
794
744
|
|
|
795
745
|
var SortByDirection;
|
|
796
|
-
|
|
797
746
|
(function (SortByDirection) {
|
|
798
747
|
SortByDirection["asc"] = "asc";
|
|
799
748
|
SortByDirection["desc"] = "desc";
|
|
800
749
|
})(SortByDirection || (SortByDirection = {}));
|
|
801
|
-
|
|
802
750
|
const SortColumn = _a => {
|
|
803
751
|
var {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
752
|
+
children = null,
|
|
753
|
+
className = '',
|
|
754
|
+
isSortedBy = false,
|
|
755
|
+
onSort = null,
|
|
756
|
+
sortDirection = '',
|
|
757
|
+
type = 'button',
|
|
758
|
+
tooltip,
|
|
759
|
+
tooltipProps,
|
|
760
|
+
tooltipHasDefaultBehavior
|
|
761
|
+
} = _a,
|
|
762
|
+
props = __rest(_a, ["children", "className", "isSortedBy", "onSort", "sortDirection", "type", "tooltip", "tooltipProps", "tooltipHasDefaultBehavior"]);
|
|
816
763
|
let SortedByIcon;
|
|
817
764
|
const [focused, setFocused] = React.useState(false);
|
|
818
|
-
|
|
819
765
|
if (isSortedBy) {
|
|
820
766
|
SortedByIcon = sortDirection === SortByDirection.asc ? LongArrowAltUpIcon$1 : LongArrowAltDownIcon$1;
|
|
821
767
|
} else {
|
|
822
768
|
SortedByIcon = ArrowsAltVIcon$1;
|
|
823
769
|
}
|
|
824
|
-
|
|
825
770
|
return React.createElement("button", Object.assign({}, props, {
|
|
826
771
|
type: type,
|
|
827
772
|
className: css(className, styles$1.tableButton),
|
|
@@ -893,23 +838,21 @@ const sortable = (label, {
|
|
|
893
838
|
/**
|
|
894
839
|
* @param {React.MouseEvent} event - React mouse event
|
|
895
840
|
*/
|
|
896
|
-
|
|
897
841
|
function sortClicked(event) {
|
|
898
842
|
let reversedDirection;
|
|
899
|
-
|
|
900
843
|
if (!isSortedBy) {
|
|
901
844
|
reversedDirection = sortBy.defaultDirection ? sortBy.defaultDirection : SortByDirection.asc;
|
|
902
845
|
} else {
|
|
903
846
|
reversedDirection = sortBy.direction === SortByDirection.asc ? SortByDirection.desc : SortByDirection.asc;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
|
|
847
|
+
}
|
|
848
|
+
// tslint:disable-next-line:no-unused-expression
|
|
907
849
|
onSort && onSort(event, columnIndex, reversedDirection, extraData);
|
|
908
850
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
'aria-sort':
|
|
851
|
+
return Object.assign(Object.assign({
|
|
852
|
+
className: css(styles$1.tableSort, isSortedBy && styles$1.modifiers.selected, className)
|
|
853
|
+
}, isSortedBy && {
|
|
854
|
+
'aria-sort': `${sortBy.direction}ending`
|
|
855
|
+
}), {
|
|
913
856
|
children: React.createElement(SortColumn, {
|
|
914
857
|
isSortedBy: isSortedBy,
|
|
915
858
|
sortDirection: isSortedBy ? sortBy.direction : '',
|
|
@@ -919,11 +862,10 @@ const sortable = (label, {
|
|
|
919
862
|
tooltipProps: tooltipProps,
|
|
920
863
|
tooltipHasDefaultBehavior: tooltipHasDefaultBehavior
|
|
921
864
|
}, label)
|
|
922
|
-
};
|
|
865
|
+
});
|
|
923
866
|
};
|
|
924
867
|
|
|
925
868
|
const resolveOrDefault = (resolver, defaultValue, rowData, extraData) => typeof resolver === 'function' ? resolver(rowData, extraData) : defaultValue;
|
|
926
|
-
|
|
927
869
|
const cellActions = (actions, actionResolver, areActionsDisabled) => (label, {
|
|
928
870
|
rowData,
|
|
929
871
|
column,
|
|
@@ -965,12 +907,10 @@ const cellActions = (actions, actionResolver, areActionsDisabled) => (label, {
|
|
|
965
907
|
};
|
|
966
908
|
|
|
967
909
|
const camelize = s => s.toUpperCase().replace('-', '').replace('_', '');
|
|
968
|
-
|
|
969
910
|
const toCamel = s => s.replace(/([-_][a-z])/gi, camelize);
|
|
970
911
|
/**
|
|
971
912
|
* @param {string} input - String to capitalize
|
|
972
913
|
*/
|
|
973
|
-
|
|
974
914
|
function capitalize(input) {
|
|
975
915
|
return input[0].toUpperCase() + input.substring(1);
|
|
976
916
|
}
|
|
@@ -1012,13 +952,11 @@ const collapsible = (value, {
|
|
|
1012
952
|
/**
|
|
1013
953
|
* @param {React.MouseEvent} event - Mouse event
|
|
1014
954
|
*/
|
|
1015
|
-
|
|
1016
955
|
function onToggle(event) {
|
|
1017
|
-
const open = rowData ? !rowData.isOpen : !allRowsExpanded;
|
|
1018
|
-
|
|
956
|
+
const open = rowData ? !rowData.isOpen : !allRowsExpanded;
|
|
957
|
+
// tslint:disable-next-line:no-unused-expression
|
|
1019
958
|
onCollapse && onCollapse(event, rowIndex, open, rowData, extraData);
|
|
1020
959
|
}
|
|
1021
|
-
|
|
1022
960
|
return {
|
|
1023
961
|
className: ((rowData === null || rowData === void 0 ? void 0 : rowData.isOpen) !== undefined || rowId === -1) && css(styles$1.tableToggle),
|
|
1024
962
|
isVisible: !(rowData === null || rowData === void 0 ? void 0 : rowData.fullWidth),
|
|
@@ -1040,7 +978,6 @@ const compoundExpand = (value, {
|
|
|
1040
978
|
if (!value) {
|
|
1041
979
|
return null;
|
|
1042
980
|
}
|
|
1043
|
-
|
|
1044
981
|
const {
|
|
1045
982
|
title,
|
|
1046
983
|
props
|
|
@@ -1060,12 +997,10 @@ const compoundExpand = (value, {
|
|
|
1060
997
|
/**
|
|
1061
998
|
* @param {React.MouseEvent} event - Mouse event
|
|
1062
999
|
*/
|
|
1063
|
-
|
|
1064
1000
|
function onToggle(event) {
|
|
1065
1001
|
// tslint:disable-next-line:no-unused-expression
|
|
1066
1002
|
onExpand && onExpand(event, rowIndex, columnIndex, props.isOpen, rowData, extraData);
|
|
1067
1003
|
}
|
|
1068
|
-
|
|
1069
1004
|
return {
|
|
1070
1005
|
className: css(styles$1.tableCompoundExpansionToggle, props.isOpen && styles$1.modifiers.expanded),
|
|
1071
1006
|
children: props.isOpen !== undefined && React.createElement("button", {
|
|
@@ -1113,19 +1048,17 @@ const info = ({
|
|
|
1113
1048
|
className: className
|
|
1114
1049
|
}, value)
|
|
1115
1050
|
});
|
|
1116
|
-
|
|
1117
1051
|
return infoObj;
|
|
1118
1052
|
};
|
|
1119
1053
|
|
|
1120
1054
|
const FavoritesCell = _a => {
|
|
1121
1055
|
var {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1056
|
+
className = '',
|
|
1057
|
+
onFavorite,
|
|
1058
|
+
isFavorited,
|
|
1059
|
+
rowIndex
|
|
1060
|
+
} = _a,
|
|
1061
|
+
props = __rest(_a, ["className", "onFavorite", "isFavorited", "rowIndex"]);
|
|
1129
1062
|
const ariaProps = rowIndex === undefined ? {} : {
|
|
1130
1063
|
id: `favorites-button-${rowIndex}`,
|
|
1131
1064
|
'aria-labelledby': `favorites-button-${rowIndex}`
|
|
@@ -1159,8 +1092,8 @@ const favoritable = (value, {
|
|
|
1159
1092
|
columnIndex,
|
|
1160
1093
|
column,
|
|
1161
1094
|
property
|
|
1162
|
-
};
|
|
1163
|
-
|
|
1095
|
+
};
|
|
1096
|
+
// this is a child row which should not display the favorites icon
|
|
1164
1097
|
if (rowData && rowData.hasOwnProperty('parent') && !rowData.fullWidth) {
|
|
1165
1098
|
return {
|
|
1166
1099
|
component: 'td',
|
|
@@ -1170,13 +1103,10 @@ const favoritable = (value, {
|
|
|
1170
1103
|
/**
|
|
1171
1104
|
* @param {React.MouseEvent} event - Mouse event
|
|
1172
1105
|
*/
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
1106
|
function favoritesClick(event) {
|
|
1176
1107
|
// tslint:disable-next-line:no-unused-expression
|
|
1177
1108
|
onFavorite && onFavorite(event, rowData && !rowData.favorited, rowIndex, rowData, extraData);
|
|
1178
1109
|
}
|
|
1179
|
-
|
|
1180
1110
|
const additionalProps = rowData.favoritesProps || {};
|
|
1181
1111
|
return {
|
|
1182
1112
|
className: css(styles$1.tableFavorite, rowData && rowData.favorited && styles$1.modifiers.favorited),
|
|
@@ -1227,11 +1157,9 @@ const treeRow = (onCollapse, onCheckChange, onToggleRowDetails) => (value, {
|
|
|
1227
1157
|
className: styles$1.tableText,
|
|
1228
1158
|
key: "table-text"
|
|
1229
1159
|
}, content));
|
|
1230
|
-
|
|
1231
1160
|
const onChange = (isChecked, event) => {
|
|
1232
1161
|
onCheckChange(event, isChecked, rowIndex, content, rowData);
|
|
1233
1162
|
};
|
|
1234
|
-
|
|
1235
1163
|
return {
|
|
1236
1164
|
component: 'th',
|
|
1237
1165
|
className: treeViewStyles.tableTreeViewTitleCell,
|
|
@@ -1277,7 +1205,6 @@ const treeRow = (onCollapse, onCheckChange, onToggleRowDetails) => (value, {
|
|
|
1277
1205
|
};
|
|
1278
1206
|
|
|
1279
1207
|
var TableGridBreakpoint;
|
|
1280
|
-
|
|
1281
1208
|
(function (TableGridBreakpoint) {
|
|
1282
1209
|
TableGridBreakpoint["none"] = "";
|
|
1283
1210
|
TableGridBreakpoint["grid"] = "grid";
|
|
@@ -1286,9 +1213,7 @@ var TableGridBreakpoint;
|
|
|
1286
1213
|
TableGridBreakpoint["gridXl"] = "grid-xl";
|
|
1287
1214
|
TableGridBreakpoint["grid2xl"] = "grid-2xl";
|
|
1288
1215
|
})(TableGridBreakpoint || (TableGridBreakpoint = {}));
|
|
1289
|
-
|
|
1290
1216
|
var TableVariant;
|
|
1291
|
-
|
|
1292
1217
|
(function (TableVariant) {
|
|
1293
1218
|
TableVariant["compact"] = "compact";
|
|
1294
1219
|
})(TableVariant || (TableVariant = {}));
|
|
@@ -1296,45 +1221,41 @@ var TableVariant;
|
|
|
1296
1221
|
const TableContext = React.createContext({
|
|
1297
1222
|
registerSelectableRow: () => {}
|
|
1298
1223
|
});
|
|
1299
|
-
|
|
1300
1224
|
const TableBase = _a => {
|
|
1301
1225
|
var _b, _c;
|
|
1302
|
-
|
|
1303
1226
|
var {
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1227
|
+
children,
|
|
1228
|
+
className,
|
|
1229
|
+
variant,
|
|
1230
|
+
borders = true,
|
|
1231
|
+
isStickyHeader = false,
|
|
1232
|
+
gridBreakPoint = TableGridBreakpoint.gridMd,
|
|
1233
|
+
'aria-label': ariaLabel,
|
|
1234
|
+
role = 'grid',
|
|
1235
|
+
innerRef,
|
|
1236
|
+
ouiaId,
|
|
1237
|
+
ouiaSafe = true,
|
|
1238
|
+
isTreeTable = false,
|
|
1239
|
+
isNested = false,
|
|
1240
|
+
isStriped = false,
|
|
1241
|
+
isExpandable = false,
|
|
1242
|
+
hasNoInset = false,
|
|
1243
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1244
|
+
nestedHeaderColumnSpans,
|
|
1245
|
+
selectableRowCaptionText
|
|
1246
|
+
} = _a,
|
|
1247
|
+
props = __rest(_a, ["children", "className", "variant", "borders", "isStickyHeader", "gridBreakPoint", 'aria-label', "role", "innerRef", "ouiaId", "ouiaSafe", "isTreeTable", "isNested", "isStriped", "isExpandable", "hasNoInset", "nestedHeaderColumnSpans", "selectableRowCaptionText"]);
|
|
1326
1248
|
const ref = React.useRef(null);
|
|
1327
1249
|
const tableRef = innerRef || ref;
|
|
1328
1250
|
const [hasSelectableRows, setHasSelectableRows] = React.useState(false);
|
|
1329
1251
|
const [tableCaption, setTableCaption] = React.useState();
|
|
1330
1252
|
React.useEffect(() => {
|
|
1331
|
-
document.addEventListener('keydown', handleKeys);
|
|
1332
|
-
|
|
1253
|
+
document.addEventListener('keydown', handleKeys);
|
|
1254
|
+
// sets up roving tab-index to tree tables only
|
|
1333
1255
|
if (tableRef && tableRef.current && tableRef.current.classList.contains('pf-m-tree-view')) {
|
|
1334
1256
|
const tbody = tableRef.current.querySelector('tbody');
|
|
1335
1257
|
tbody && setTabIndex(Array.from(tbody.querySelectorAll('button, a, input')));
|
|
1336
1258
|
}
|
|
1337
|
-
|
|
1338
1259
|
return function cleanup() {
|
|
1339
1260
|
document.removeEventListener('keydown', handleKeys);
|
|
1340
1261
|
};
|
|
@@ -1354,31 +1275,25 @@ const TableBase = _a => {
|
|
|
1354
1275
|
const grid = (_b = stylesGrid.modifiers) === null || _b === void 0 ? void 0 : _b[toCamel(gridBreakPoint || '').replace(/-?2xl/, '_2xl')];
|
|
1355
1276
|
const breakPointPrefix = `treeView${gridBreakPoint.charAt(0).toUpperCase() + gridBreakPoint.slice(1)}`;
|
|
1356
1277
|
const treeGrid = (_c = treeViewStyles.modifiers) === null || _c === void 0 ? void 0 : _c[toCamel(breakPointPrefix || '').replace(/-?2xl/, '_2xl')];
|
|
1357
|
-
|
|
1358
1278
|
const handleKeys = event => {
|
|
1359
|
-
if (isNested || !(tableRef && tableRef.current && tableRef.current.classList.contains(treeViewStyles.modifiers.treeView)) ||
|
|
1279
|
+
if (isNested || !(tableRef && tableRef.current && tableRef.current.classList.contains(treeViewStyles.modifiers.treeView)) ||
|
|
1280
|
+
// implements roving tab-index to tree tables only
|
|
1360
1281
|
tableRef && tableRef.current !== event.target.closest(`.${styles$1.table}:not(.pf-m-nested)`)) {
|
|
1361
1282
|
return;
|
|
1362
1283
|
}
|
|
1363
|
-
|
|
1364
1284
|
const activeElement = document.activeElement;
|
|
1365
1285
|
const key = event.key;
|
|
1366
1286
|
const rows = Array.from(tableRef.current.querySelectorAll('tbody tr')).filter(el => !el.classList.contains('pf-m-disabled') && !el.hidden);
|
|
1367
|
-
|
|
1368
1287
|
if (key === 'Space' || key === 'Enter') {
|
|
1369
1288
|
activeElement.click();
|
|
1370
1289
|
event.preventDefault();
|
|
1371
1290
|
}
|
|
1372
|
-
|
|
1373
1291
|
const getFocusableElement = element => element.querySelectorAll('button:not(:disabled), input:not(:disabled), a:not(:disabled)')[0];
|
|
1374
|
-
|
|
1375
1292
|
handleArrows(event, rows, element => element === activeElement.closest('tr'), getFocusableElement, ['button', 'input', 'a'], undefined, false, true, false);
|
|
1376
1293
|
};
|
|
1377
|
-
|
|
1378
1294
|
const registerSelectableRow = () => {
|
|
1379
1295
|
!hasSelectableRows && setHasSelectableRows(true);
|
|
1380
1296
|
};
|
|
1381
|
-
|
|
1382
1297
|
return React.createElement(TableContext.Provider, {
|
|
1383
1298
|
value: {
|
|
1384
1299
|
registerSelectableRow
|
|
@@ -1392,7 +1307,6 @@ const TableBase = _a => {
|
|
|
1392
1307
|
role: 'treegrid'
|
|
1393
1308
|
}, ouiaProps, props), hasSelectableRows && tableCaption, children));
|
|
1394
1309
|
};
|
|
1395
|
-
|
|
1396
1310
|
const Table = React.forwardRef((props, ref) => React.createElement(TableBase, Object.assign({}, props, {
|
|
1397
1311
|
innerRef: ref
|
|
1398
1312
|
})));
|
|
@@ -1400,29 +1314,28 @@ Table.displayName = 'Table';
|
|
|
1400
1314
|
|
|
1401
1315
|
const TrBase = _a => {
|
|
1402
1316
|
var {
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1317
|
+
children,
|
|
1318
|
+
className,
|
|
1319
|
+
isExpanded,
|
|
1320
|
+
isEditable,
|
|
1321
|
+
isHidden = false,
|
|
1322
|
+
isClickable = false,
|
|
1323
|
+
isRowSelected = false,
|
|
1324
|
+
isStriped = false,
|
|
1325
|
+
isBorderRow = false,
|
|
1326
|
+
isControlRow = false,
|
|
1327
|
+
innerRef,
|
|
1328
|
+
ouiaId,
|
|
1329
|
+
ouiaSafe = true,
|
|
1330
|
+
resetOffset = false,
|
|
1331
|
+
onRowClick,
|
|
1332
|
+
isSelectable,
|
|
1333
|
+
'aria-label': passedAriaLabel
|
|
1334
|
+
} = _a,
|
|
1335
|
+
props = __rest(_a, ["children", "className", "isExpanded", "isEditable", "isHidden", "isClickable", "isRowSelected", "isStriped", "isBorderRow", "isControlRow", "innerRef", "ouiaId", "ouiaSafe", "resetOffset", "onRowClick", "isSelectable", 'aria-label']);
|
|
1422
1336
|
const ouiaProps = useOUIAProps$1('TableRow', ouiaId, ouiaSafe);
|
|
1423
1337
|
const [computedAriaLabel, setComputedAriaLabel] = React.useState('');
|
|
1424
1338
|
let onKeyDown = null;
|
|
1425
|
-
|
|
1426
1339
|
if (onRowClick) {
|
|
1427
1340
|
onKeyDown = e => {
|
|
1428
1341
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
@@ -1431,7 +1344,6 @@ const TrBase = _a => {
|
|
|
1431
1344
|
}
|
|
1432
1345
|
};
|
|
1433
1346
|
}
|
|
1434
|
-
|
|
1435
1347
|
const rowIsHidden = isHidden || isExpanded !== undefined && !isExpanded;
|
|
1436
1348
|
const {
|
|
1437
1349
|
registerSelectableRow
|
|
@@ -1446,7 +1358,7 @@ const TrBase = _a => {
|
|
|
1446
1358
|
}, [isRowSelected, isSelectable, registerSelectableRow, rowIsHidden]);
|
|
1447
1359
|
const ariaLabel = passedAriaLabel || computedAriaLabel;
|
|
1448
1360
|
return React.createElement(React.Fragment, null, React.createElement("tr", Object.assign({
|
|
1449
|
-
className: css(styles$1.tableTr, className, isExpanded !== undefined && styles$1.tableExpandableRow, isExpanded && styles$1.modifiers.expanded, isEditable && inlineStyles.modifiers.inlineEditable, isClickable && styles$1.modifiers.clickable, isRowSelected && styles$1.modifiers.selected, isStriped && styles$1.modifiers.striped, isBorderRow && styles$1.modifiers.borderRow, resetOffset && styles$1.modifiers.firstCellOffsetReset),
|
|
1361
|
+
className: css(styles$1.tableTr, className, isExpanded !== undefined && styles$1.tableExpandableRow, isExpanded && styles$1.modifiers.expanded, isEditable && inlineStyles.modifiers.inlineEditable, isClickable && styles$1.modifiers.clickable, isRowSelected && styles$1.modifiers.selected, isStriped && styles$1.modifiers.striped, isBorderRow && styles$1.modifiers.borderRow, isControlRow && styles$1.tableControlRow, resetOffset && styles$1.modifiers.firstCellOffsetReset),
|
|
1450
1362
|
hidden: rowIsHidden
|
|
1451
1363
|
}, isClickable && {
|
|
1452
1364
|
tabIndex: 0
|
|
@@ -1458,7 +1370,6 @@ const TrBase = _a => {
|
|
|
1458
1370
|
onKeyDown
|
|
1459
1371
|
}, ouiaProps, props), children));
|
|
1460
1372
|
};
|
|
1461
|
-
|
|
1462
1373
|
const Tr = React.forwardRef((props, ref) => React.createElement(TrBase, Object.assign({}, props, {
|
|
1463
1374
|
innerRef: ref
|
|
1464
1375
|
})));
|
|
@@ -1466,20 +1377,18 @@ Tr.displayName = 'Tr';
|
|
|
1466
1377
|
|
|
1467
1378
|
const TheadBase = _a => {
|
|
1468
1379
|
var {
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1380
|
+
children,
|
|
1381
|
+
className,
|
|
1382
|
+
noWrap = false,
|
|
1383
|
+
innerRef,
|
|
1384
|
+
hasNestedHeader
|
|
1385
|
+
} = _a,
|
|
1386
|
+
props = __rest(_a, ["children", "className", "noWrap", "innerRef", "hasNestedHeader"]);
|
|
1477
1387
|
return React.createElement("thead", Object.assign({
|
|
1478
1388
|
className: css(styles$1.tableThead, className, noWrap && styles$1.modifiers.nowrap, hasNestedHeader && styles$1.modifiers.nestedColumnHeader),
|
|
1479
1389
|
ref: innerRef
|
|
1480
1390
|
}, props), children);
|
|
1481
1391
|
};
|
|
1482
|
-
|
|
1483
1392
|
const Thead = React.forwardRef((props, ref) => React.createElement(TheadBase, Object.assign({}, props, {
|
|
1484
1393
|
innerRef: ref
|
|
1485
1394
|
})));
|
|
@@ -1487,22 +1396,20 @@ Thead.displayName = 'Thead';
|
|
|
1487
1396
|
|
|
1488
1397
|
const TbodyBase = _a => {
|
|
1489
1398
|
var {
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1399
|
+
children,
|
|
1400
|
+
className,
|
|
1401
|
+
isExpanded,
|
|
1402
|
+
innerRef,
|
|
1403
|
+
isEvenStriped = false,
|
|
1404
|
+
isOddStriped = false
|
|
1405
|
+
} = _a,
|
|
1406
|
+
props = __rest(_a, ["children", "className", "isExpanded", "innerRef", "isEvenStriped", "isOddStriped"]);
|
|
1499
1407
|
return React.createElement("tbody", Object.assign({
|
|
1500
1408
|
role: "rowgroup",
|
|
1501
1409
|
className: css(styles$1.tableTbody, className, isExpanded && styles$1.modifiers.expanded, isOddStriped && styles$1.modifiers.striped, isEvenStriped && styles$1.modifiers.stripedEven),
|
|
1502
1410
|
ref: innerRef
|
|
1503
1411
|
}, props), children);
|
|
1504
1412
|
};
|
|
1505
|
-
|
|
1506
1413
|
const Tbody = React.forwardRef((props, ref) => React.createElement(TbodyBase, Object.assign({}, props, {
|
|
1507
1414
|
innerRef: ref
|
|
1508
1415
|
})));
|
|
@@ -1532,16 +1439,13 @@ var styles = {
|
|
|
1532
1439
|
/**
|
|
1533
1440
|
* @param {any} props - Props
|
|
1534
1441
|
*/
|
|
1535
|
-
|
|
1536
1442
|
function mergeProps(...props) {
|
|
1537
1443
|
const firstProps = props[0];
|
|
1538
1444
|
const restProps = props.slice(1);
|
|
1539
|
-
|
|
1540
1445
|
if (!restProps.length) {
|
|
1541
1446
|
return mergeWith({}, firstProps);
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1447
|
+
}
|
|
1448
|
+
// Avoid mutating the first prop collection
|
|
1545
1449
|
return mergeWith(mergeWith({}, firstProps), ...restProps, (a, b, key) => {
|
|
1546
1450
|
if (key === 'children') {
|
|
1547
1451
|
if (a && b) {
|
|
@@ -1549,19 +1453,16 @@ function mergeProps(...props) {
|
|
|
1549
1453
|
return React.cloneElement(a, {
|
|
1550
1454
|
children: b
|
|
1551
1455
|
});
|
|
1552
|
-
}
|
|
1456
|
+
}
|
|
1457
|
+
// Children have to be merged in reverse order for Reactabular
|
|
1553
1458
|
// logic to work.
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
1459
|
return Object.assign(Object.assign({}, b), a);
|
|
1557
1460
|
}
|
|
1558
|
-
|
|
1559
1461
|
if (key === 'className') {
|
|
1560
1462
|
// Process class names through classNames to merge properly
|
|
1561
1463
|
// as a string.
|
|
1562
1464
|
return css(a, b);
|
|
1563
1465
|
}
|
|
1564
|
-
|
|
1565
1466
|
return undefined;
|
|
1566
1467
|
});
|
|
1567
1468
|
}
|
|
@@ -1589,56 +1490,50 @@ var cssStickyCellRight = c_table__sticky_cell_Right;
|
|
|
1589
1490
|
|
|
1590
1491
|
const ThBase = _a => {
|
|
1591
1492
|
var {
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1493
|
+
children,
|
|
1494
|
+
className,
|
|
1495
|
+
component = 'th',
|
|
1496
|
+
dataLabel,
|
|
1497
|
+
scope = 'col',
|
|
1498
|
+
textCenter = false,
|
|
1499
|
+
sort = null,
|
|
1500
|
+
modifier,
|
|
1501
|
+
select = null,
|
|
1502
|
+
expand: collapse = null,
|
|
1503
|
+
tooltip = '',
|
|
1504
|
+
tooltipProps,
|
|
1505
|
+
onMouseEnter: onMouseEnterProp = () => {},
|
|
1506
|
+
width,
|
|
1507
|
+
visibility,
|
|
1508
|
+
innerRef,
|
|
1509
|
+
info: infoProps,
|
|
1510
|
+
isStickyColumn = false,
|
|
1511
|
+
hasRightBorder = false,
|
|
1512
|
+
hasLeftBorder = false,
|
|
1513
|
+
stickyMinWidth = '120px',
|
|
1514
|
+
stickyLeftOffset,
|
|
1515
|
+
stickyRightOffset,
|
|
1516
|
+
isSubheader = false,
|
|
1517
|
+
screenReaderText,
|
|
1518
|
+
'aria-label': ariaLabel
|
|
1519
|
+
} = _a,
|
|
1520
|
+
props = __rest(_a, ["children", "className", "component", "dataLabel", "scope", "textCenter", "sort", "modifier", "select", "expand", "tooltip", "tooltipProps", "onMouseEnter", "width", "visibility", "innerRef", "info", "isStickyColumn", "hasRightBorder", "hasLeftBorder", "stickyMinWidth", "stickyLeftOffset", "stickyRightOffset", "isSubheader", "screenReaderText", 'aria-label']);
|
|
1621
1521
|
if (!children && !screenReaderText && !ariaLabel) {
|
|
1622
1522
|
// eslint-disable-next-line no-console
|
|
1623
1523
|
console.warn('Th: Table headers must have an accessible name. If the Th is intended to be visually empty, pass in screenReaderText. If the Th contains only non-text, interactive content such as a checkbox or expand toggle, pass in an aria-label.');
|
|
1624
1524
|
}
|
|
1625
|
-
|
|
1626
1525
|
const [showTooltip, setShowTooltip] = React.useState(false);
|
|
1627
1526
|
const [truncated, setTruncated] = React.useState(false);
|
|
1628
1527
|
const cellRef = innerRef ? innerRef : React.createRef();
|
|
1629
|
-
|
|
1630
1528
|
const onMouseEnter = event => {
|
|
1631
1529
|
if (event.target.offsetWidth < event.target.scrollWidth) {
|
|
1632
1530
|
!showTooltip && setShowTooltip(true);
|
|
1633
1531
|
} else {
|
|
1634
1532
|
showTooltip && setShowTooltip(false);
|
|
1635
1533
|
}
|
|
1636
|
-
|
|
1637
1534
|
onMouseEnterProp(event);
|
|
1638
1535
|
};
|
|
1639
|
-
|
|
1640
1536
|
let sortParams = null;
|
|
1641
|
-
|
|
1642
1537
|
if (sort) {
|
|
1643
1538
|
if (sort.isFavorites) {
|
|
1644
1539
|
sortParams = sortableFavorites({
|
|
@@ -1662,7 +1557,6 @@ const ThBase = _a => {
|
|
|
1662
1557
|
});
|
|
1663
1558
|
}
|
|
1664
1559
|
}
|
|
1665
|
-
|
|
1666
1560
|
const selectParams = select ? selectable(children, {
|
|
1667
1561
|
rowData: {
|
|
1668
1562
|
selected: select.isSelected,
|
|
@@ -1691,29 +1585,25 @@ const ThBase = _a => {
|
|
|
1691
1585
|
}) : null;
|
|
1692
1586
|
const widthParams = width ? cellWidth(width)() : null;
|
|
1693
1587
|
const visibilityParams = visibility ? classNames(...visibility.map(vis => Visibility[vis]))() : null;
|
|
1694
|
-
let transformedChildren = (sortParams === null || sortParams === void 0 ? void 0 : sortParams.children) || (selectParams === null || selectParams === void 0 ? void 0 : selectParams.children) || (collapseParams === null || collapseParams === void 0 ? void 0 : collapseParams.children) || children;
|
|
1695
|
-
|
|
1588
|
+
let transformedChildren = (sortParams === null || sortParams === void 0 ? void 0 : sortParams.children) || (selectParams === null || selectParams === void 0 ? void 0 : selectParams.children) || (collapseParams === null || collapseParams === void 0 ? void 0 : collapseParams.children) || children;
|
|
1589
|
+
// info can wrap other transformedChildren
|
|
1696
1590
|
let infoParams = null;
|
|
1697
|
-
|
|
1698
1591
|
if (infoProps) {
|
|
1699
1592
|
infoParams = info(infoProps)(transformedChildren);
|
|
1700
1593
|
transformedChildren = infoParams.children;
|
|
1701
1594
|
}
|
|
1702
|
-
|
|
1703
1595
|
const merged = mergeProps(sortParams, selectParams, collapseParams, widthParams, visibilityParams, infoParams);
|
|
1704
|
-
|
|
1705
1596
|
const {
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1597
|
+
// ignore the merged children since we transform them ourselves so we can wrap it with info
|
|
1598
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1599
|
+
children: mergedChildren = null,
|
|
1600
|
+
// selectable adds this but we don't want it
|
|
1601
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1602
|
+
isVisible = null,
|
|
1603
|
+
className: mergedClassName = '',
|
|
1604
|
+
component: MergedComponent = component
|
|
1605
|
+
} = merged,
|
|
1606
|
+
mergedProps = __rest(merged, ["children", "isVisible", "className", "component"]);
|
|
1717
1607
|
React.useEffect(() => {
|
|
1718
1608
|
setTruncated(cellRef.current.offsetWidth < cellRef.current.scrollWidth);
|
|
1719
1609
|
}, [cellRef]);
|
|
@@ -1744,7 +1634,6 @@ const ThBase = _a => {
|
|
|
1744
1634
|
isVisible: true
|
|
1745
1635
|
}, tooltipProps))) : cell;
|
|
1746
1636
|
};
|
|
1747
|
-
|
|
1748
1637
|
const Th = React.forwardRef((props, ref) => React.createElement(ThBase, Object.assign({}, props, {
|
|
1749
1638
|
innerRef: ref
|
|
1750
1639
|
})));
|
|
@@ -1766,49 +1655,45 @@ const draggable = (value, {
|
|
|
1766
1655
|
|
|
1767
1656
|
const TdBase = _a => {
|
|
1768
1657
|
var {
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1658
|
+
children,
|
|
1659
|
+
className,
|
|
1660
|
+
isActionCell = false,
|
|
1661
|
+
component = 'td',
|
|
1662
|
+
dataLabel,
|
|
1663
|
+
textCenter = false,
|
|
1664
|
+
modifier,
|
|
1665
|
+
select = null,
|
|
1666
|
+
actions = null,
|
|
1667
|
+
expand = null,
|
|
1668
|
+
treeRow: treeRowProp = null,
|
|
1669
|
+
compoundExpand: compoundExpandProp = null,
|
|
1670
|
+
noPadding,
|
|
1671
|
+
width,
|
|
1672
|
+
visibility,
|
|
1673
|
+
innerRef,
|
|
1674
|
+
favorites = null,
|
|
1675
|
+
draggableRow: draggableRowProp = null,
|
|
1676
|
+
tooltip = '',
|
|
1677
|
+
onMouseEnter: onMouseEnterProp = () => {},
|
|
1678
|
+
isStickyColumn = false,
|
|
1679
|
+
hasRightBorder = false,
|
|
1680
|
+
hasLeftBorder = false,
|
|
1681
|
+
stickyMinWidth = '120px',
|
|
1682
|
+
stickyLeftOffset,
|
|
1683
|
+
stickyRightOffset
|
|
1684
|
+
} = _a,
|
|
1685
|
+
props = __rest(_a, ["children", "className", "isActionCell", "component", "dataLabel", "textCenter", "modifier", "select", "actions", "expand", "treeRow", "compoundExpand", "noPadding", "width", "visibility", "innerRef", "favorites", "draggableRow", "tooltip", "onMouseEnter", "isStickyColumn", "hasRightBorder", "hasLeftBorder", "stickyMinWidth", "stickyLeftOffset", "stickyRightOffset"]);
|
|
1798
1686
|
const [showTooltip, setShowTooltip] = React.useState(false);
|
|
1799
1687
|
const [truncated, setTruncated] = React.useState(false);
|
|
1800
1688
|
const cellRef = innerRef ? innerRef : React.createRef();
|
|
1801
|
-
|
|
1802
1689
|
const onMouseEnter = event => {
|
|
1803
1690
|
if (event.target.offsetWidth < event.target.scrollWidth) {
|
|
1804
1691
|
!showTooltip && setShowTooltip(true);
|
|
1805
1692
|
} else {
|
|
1806
1693
|
showTooltip && setShowTooltip(false);
|
|
1807
1694
|
}
|
|
1808
|
-
|
|
1809
1695
|
onMouseEnterProp(event);
|
|
1810
1696
|
};
|
|
1811
|
-
|
|
1812
1697
|
const selectParams = select ? selectable(children, {
|
|
1813
1698
|
rowIndex: select.rowIndex,
|
|
1814
1699
|
rowData: {
|
|
@@ -1894,17 +1779,15 @@ const TdBase = _a => {
|
|
|
1894
1779
|
}
|
|
1895
1780
|
}) : null;
|
|
1896
1781
|
const merged = mergeProps(selectParams, actionParams, expandableParams, compoundParams, widthParams, visibilityParams, favoriteParams, treeRowParams, draggableParams);
|
|
1897
|
-
|
|
1898
1782
|
const {
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1783
|
+
// selectable adds this but we don't want it
|
|
1784
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1785
|
+
isVisible = null,
|
|
1786
|
+
children: mergedChildren = null,
|
|
1787
|
+
className: mergedClassName = '',
|
|
1788
|
+
component: MergedComponent = component
|
|
1789
|
+
} = merged,
|
|
1790
|
+
mergedProps = __rest(merged, ["isVisible", "children", "className", "component"]);
|
|
1908
1791
|
const treeTableTitleCell = className && className.includes(treeViewStyles.tableTreeViewTitleCell) || mergedClassName && mergedClassName.includes(treeViewStyles.tableTreeViewTitleCell);
|
|
1909
1792
|
React.useEffect(() => {
|
|
1910
1793
|
setTruncated(cellRef.current.offsetWidth < cellRef.current.scrollWidth);
|
|
@@ -1933,7 +1816,6 @@ const TdBase = _a => {
|
|
|
1933
1816
|
isVisible: true
|
|
1934
1817
|
})) : cell;
|
|
1935
1818
|
};
|
|
1936
|
-
|
|
1937
1819
|
const Td = React.forwardRef((props, ref) => React.createElement(TdBase, Object.assign({}, props, {
|
|
1938
1820
|
innerRef: ref
|
|
1939
1821
|
})));
|
|
@@ -1970,25 +1852,22 @@ function FilterableTable({
|
|
|
1970
1852
|
actions,
|
|
1971
1853
|
perPageOptions
|
|
1972
1854
|
}) {
|
|
1973
|
-
|
|
1974
1855
|
const [page, setPage] = useState(DEFAULT_PAGE);
|
|
1975
1856
|
const [perPage, setPerPage] = useState(DEFAULT_PERPAGE );
|
|
1976
1857
|
const [sortTableBy, setSortTableBy] = useState({});
|
|
1977
1858
|
const [rows, setRows] = useState([]);
|
|
1978
1859
|
const [filteredItems, setFilteredItems] = useState(items);
|
|
1979
1860
|
const [tableFilters, setTableFilters] = useState([]);
|
|
1980
|
-
/**
|
|
1981
|
-
* Sorts table by the selected column in ascending or decending order
|
|
1982
|
-
* @param _event click
|
|
1983
|
-
* @param index column index
|
|
1984
|
-
* @param direction asc || desc
|
|
1861
|
+
/**
|
|
1862
|
+
* Sorts table by the selected column in ascending or decending order
|
|
1863
|
+
* @param _event click
|
|
1864
|
+
* @param index column index
|
|
1865
|
+
* @param direction asc || desc
|
|
1985
1866
|
*/
|
|
1986
|
-
|
|
1987
1867
|
const onSort = (_event, index, direction) => {
|
|
1988
1868
|
var _columns$index, _columns$index2;
|
|
1989
|
-
|
|
1990
|
-
const
|
|
1991
|
-
const sortFn = columns == null ? void 0 : (_columns$index2 = columns[index]) == null ? void 0 : _columns$index2.sortFn;
|
|
1869
|
+
const sortField = columns == null || (_columns$index = columns[index]) == null ? void 0 : _columns$index.sortField;
|
|
1870
|
+
const sortFn = columns == null || (_columns$index2 = columns[index]) == null ? void 0 : _columns$index2.sortFn;
|
|
1992
1871
|
const sortedRows = sortFn ? sortBy(filteredItems, sortFn) : sortField ? sortBy(filteredItems, item => item[sortField]) : filteredItems;
|
|
1993
1872
|
setSortTableBy({
|
|
1994
1873
|
index,
|
|
@@ -1996,44 +1875,37 @@ function FilterableTable({
|
|
|
1996
1875
|
});
|
|
1997
1876
|
setFilteredItems(direction === SortByDirection.asc ? [...sortedRows] : [...(sortedRows == null ? void 0 : sortedRows.reverse())]);
|
|
1998
1877
|
};
|
|
1999
|
-
/**
|
|
2000
|
-
* Set table rows to display based on current list of filtered items, page, and perPage settings
|
|
1878
|
+
/**
|
|
1879
|
+
* Set table rows to display based on current list of filtered items, page, and perPage settings
|
|
2001
1880
|
*/
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
1881
|
useEffect(() => {
|
|
2005
1882
|
const startIndex = (page - 1) * perPage;
|
|
2006
1883
|
const endIndex = startIndex + perPage;
|
|
2007
1884
|
const itemsInPage = filteredItems.slice(startIndex, endIndex);
|
|
2008
1885
|
setRows(itemsInPage);
|
|
2009
1886
|
}, [filteredItems, page, perPage]);
|
|
2010
|
-
/**
|
|
2011
|
-
* If the list of items change, reset to the first page
|
|
1887
|
+
/**
|
|
1888
|
+
* If the list of items change, reset to the first page
|
|
2012
1889
|
*/
|
|
2013
|
-
|
|
2014
1890
|
function handleItemsPropChange() {
|
|
2015
1891
|
setPage(1);
|
|
2016
1892
|
}
|
|
2017
|
-
|
|
2018
1893
|
const handleItemsPropChangeCallback = useCallback(handleItemsPropChange, [setPage, items]);
|
|
2019
1894
|
useEffect(handleItemsPropChangeCallback, [handleItemsPropChangeCallback]);
|
|
2020
|
-
/**
|
|
2021
|
-
* Whenever a filter is selected or a user enter a search string, run each item through each filter condition
|
|
2022
|
-
* and check it includes the search string. Only inlcude the item in the table if it passes all filter/search string
|
|
2023
|
-
* conditions.
|
|
1895
|
+
/**
|
|
1896
|
+
* Whenever a filter is selected or a user enter a search string, run each item through each filter condition
|
|
1897
|
+
* and check it includes the search string. Only inlcude the item in the table if it passes all filter/search string
|
|
1898
|
+
* conditions.
|
|
2024
1899
|
*/
|
|
2025
|
-
|
|
2026
1900
|
useEffect(() => setFilteredItems(items.filter(item => tableFilters.map((f, i) => {
|
|
2027
|
-
var _filters$i, _filters$i
|
|
2028
|
-
|
|
2029
|
-
return !f ? true : filters == null ? void 0 : (_filters$i = filters[i]) == null ? void 0 : (_filters$i$props = _filters$i.props) == null ? void 0 : _filters$i$props.onChange(f, item);
|
|
1901
|
+
var _filters$i$props$onCh, _filters$i;
|
|
1902
|
+
return !f ? true : (_filters$i$props$onCh = filters == null || (_filters$i = filters[i]) == null || (_filters$i = _filters$i.props) == null || _filters$i.onChange == null ? void 0 : _filters$i.onChange(f, item)) != null ? _filters$i$props$onCh : true;
|
|
2030
1903
|
}).reduce((r, v) => r && v, true))), [filters, items, tableFilters]);
|
|
2031
|
-
/**
|
|
2032
|
-
* Whenever a new filter is selected by the user, update the state of selectedFilters
|
|
2033
|
-
* @param selected filter selections
|
|
2034
|
-
* @param index filter to update with new selections
|
|
1904
|
+
/**
|
|
1905
|
+
* Whenever a new filter is selected by the user, update the state of selectedFilters
|
|
1906
|
+
* @param selected filter selections
|
|
1907
|
+
* @param index filter to update with new selections
|
|
2035
1908
|
*/
|
|
2036
|
-
|
|
2037
1909
|
const onFilterChange = (selected, index) => {
|
|
2038
1910
|
handleItemsPropChangeCallback();
|
|
2039
1911
|
setTableFilters(prevState => {
|
|
@@ -2041,15 +1913,13 @@ function FilterableTable({
|
|
|
2041
1913
|
return [...prevState];
|
|
2042
1914
|
});
|
|
2043
1915
|
};
|
|
2044
|
-
/**
|
|
2045
|
-
* Pagination component
|
|
2046
|
-
* @param variant top or bottom
|
|
2047
|
-
* @returns Pagination component based on variant
|
|
1916
|
+
/**
|
|
1917
|
+
* Pagination component
|
|
1918
|
+
* @param variant top or bottom
|
|
1919
|
+
* @returns Pagination component based on variant
|
|
2048
1920
|
*/
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
1921
|
const renderPagination = variant => {
|
|
2052
|
-
return (filteredItems == null ? void 0 : filteredItems.length) > 0 &&
|
|
1922
|
+
return (filteredItems == null ? void 0 : filteredItems.length) > 0 && jsx(Pagination, {
|
|
2053
1923
|
itemCount: (filteredItems == null ? void 0 : filteredItems.length) || 0,
|
|
2054
1924
|
page: page,
|
|
2055
1925
|
perPage: perPage,
|
|
@@ -2066,64 +1936,85 @@ function FilterableTable({
|
|
|
2066
1936
|
}
|
|
2067
1937
|
});
|
|
2068
1938
|
};
|
|
2069
|
-
/**
|
|
2070
|
-
* Toolbar populated with provided filters
|
|
1939
|
+
/**
|
|
1940
|
+
* Toolbar populated with provided filters
|
|
2071
1941
|
*/
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
1942
|
+
const header = jsx(Toolbar, {
|
|
1943
|
+
children: jsxs(ToolbarContent, {
|
|
1944
|
+
children: [filters == null ? void 0 : filters.map((el, i) => {
|
|
1945
|
+
return jsx(ToolbarItem, {
|
|
1946
|
+
className: 'filterable-table__toolbar__item--filter',
|
|
1947
|
+
children: cloneElement(el, {
|
|
1948
|
+
onChange: selectedFilters => onFilterChange(selectedFilters, i)
|
|
1949
|
+
})
|
|
1950
|
+
}, i);
|
|
1951
|
+
}), actions == null ? void 0 : actions.map((el, i) => {
|
|
1952
|
+
return jsx(ToolbarItem, {
|
|
1953
|
+
className: 'filterable-table__toolbar__item--action',
|
|
1954
|
+
children: el
|
|
1955
|
+
}, i);
|
|
1956
|
+
}), jsx(ToolbarItem, {
|
|
1957
|
+
variant: 'pagination',
|
|
1958
|
+
children: renderPagination('top')
|
|
1959
|
+
})]
|
|
1960
|
+
})
|
|
1961
|
+
});
|
|
1962
|
+
return jsxs("div", {
|
|
1963
|
+
className: 'filterable-table',
|
|
1964
|
+
children: [isLoading ? jsx(Bullseye, {
|
|
1965
|
+
style: {
|
|
1966
|
+
minHeight: '15rem'
|
|
1967
|
+
},
|
|
1968
|
+
children: jsx("div", {
|
|
1969
|
+
children: jsx(Title, {
|
|
1970
|
+
headingLevel: 'h3',
|
|
1971
|
+
children: jsx(Spinner, {
|
|
1972
|
+
size: 'lg'
|
|
1973
|
+
})
|
|
1974
|
+
})
|
|
1975
|
+
})
|
|
1976
|
+
}) : jsxs(Fragment, {
|
|
1977
|
+
children: [header, jsxs(Table, {
|
|
1978
|
+
"aria-label": 'Packages Table',
|
|
1979
|
+
gridBreakPoint: 'grid-xl',
|
|
1980
|
+
children: [jsx(Thead, {
|
|
1981
|
+
children: jsx(Tr, {
|
|
1982
|
+
children: columns.map((col, colIdx) => jsx(Th, _extends({}, col.sortField ? {
|
|
1983
|
+
sort: {
|
|
1984
|
+
onSort: onSort,
|
|
1985
|
+
sortBy: sortTableBy,
|
|
1986
|
+
columnIndex: colIdx
|
|
1987
|
+
}
|
|
1988
|
+
} : {}, {
|
|
1989
|
+
children: col.title
|
|
1990
|
+
}), `pkg-table-head-${colIdx}`))
|
|
1991
|
+
})
|
|
1992
|
+
}), jsx(Tbody, {
|
|
1993
|
+
children: rows.length > 0 ? rows.map((row, rowIdx) => jsx(Tr, {
|
|
1994
|
+
children: columns.map((_col, colIdx) => {
|
|
1995
|
+
var _renderRow;
|
|
1996
|
+
return jsx(Td, {
|
|
1997
|
+
children: (_renderRow = renderRow(row)) == null ? void 0 : _renderRow[colIdx]
|
|
1998
|
+
}, `pkg-table-row-${rowIdx}-col-${colIdx}`);
|
|
1999
|
+
})
|
|
2000
|
+
}, `pkg-table-row-${rowIdx}`)) : jsx(Tr, {
|
|
2001
|
+
children: jsx(Td, {
|
|
2002
|
+
colSpan: columns.length,
|
|
2003
|
+
children: jsx(EmptyState, {
|
|
2004
|
+
children: jsx(EmptyStateHeader, {
|
|
2005
|
+
titleText: 'No results found',
|
|
2006
|
+
icon: jsx(EmptyStateIcon, {
|
|
2007
|
+
icon: SearchIcon
|
|
2008
|
+
}),
|
|
2009
|
+
headingLevel: 'h5'
|
|
2010
|
+
})
|
|
2011
|
+
})
|
|
2012
|
+
})
|
|
2013
|
+
})
|
|
2014
|
+
})]
|
|
2015
|
+
})]
|
|
2016
|
+
}), renderPagination('bottom')]
|
|
2017
|
+
});
|
|
2127
2018
|
}
|
|
2128
2019
|
|
|
2129
2020
|
const FilterInput = ({
|
|
@@ -2131,7 +2022,6 @@ const FilterInput = ({
|
|
|
2131
2022
|
placeholder
|
|
2132
2023
|
}) => {
|
|
2133
2024
|
const [searchStr, setSearchStr] = useState('');
|
|
2134
|
-
|
|
2135
2025
|
const onChange = (event, text) => {
|
|
2136
2026
|
event.stopPropagation();
|
|
2137
2027
|
event.preventDefault();
|
|
@@ -2140,24 +2030,24 @@ const FilterInput = ({
|
|
|
2140
2030
|
return text;
|
|
2141
2031
|
});
|
|
2142
2032
|
};
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
})
|
|
2033
|
+
return jsx("div", {
|
|
2034
|
+
className: 'filter-input',
|
|
2035
|
+
children: jsx(SearchInput, {
|
|
2036
|
+
value: searchStr,
|
|
2037
|
+
placeholder: placeholder,
|
|
2038
|
+
onChange: onChange,
|
|
2039
|
+
"aria-label": 'Text input filter',
|
|
2040
|
+
onFocus: event => {
|
|
2041
|
+
event.stopPropagation();
|
|
2042
|
+
event.preventDefault();
|
|
2043
|
+
},
|
|
2044
|
+
onClick: event => {
|
|
2045
|
+
event.stopPropagation();
|
|
2046
|
+
event.preventDefault();
|
|
2047
|
+
},
|
|
2048
|
+
onClear: event => onChange(event, '')
|
|
2049
|
+
})
|
|
2050
|
+
});
|
|
2161
2051
|
};
|
|
2162
2052
|
|
|
2163
2053
|
const ExcludedPackagesTable = ({
|
|
@@ -2173,46 +2063,47 @@ const ExcludedPackagesTable = ({
|
|
|
2173
2063
|
nvra,
|
|
2174
2064
|
summary
|
|
2175
2065
|
}) => {
|
|
2176
|
-
return [gpg ?
|
|
2066
|
+
return [gpg ? jsx("a", {
|
|
2177
2067
|
href: `https://access.redhat.com/downloads/content/${name}/${version}}-${release}/${architecture}/${gpg == null ? void 0 : gpg.slice(-8)}/package`,
|
|
2178
2068
|
target: '_blank',
|
|
2179
|
-
rel: 'noopener noreferrer'
|
|
2180
|
-
|
|
2069
|
+
rel: 'noopener noreferrer',
|
|
2070
|
+
children: nvra
|
|
2071
|
+
}) : jsx("span", {
|
|
2072
|
+
children: nvra
|
|
2073
|
+
}), summary];
|
|
2181
2074
|
};
|
|
2182
|
-
|
|
2183
2075
|
const onTextInputFilterChange = (text, {
|
|
2184
2076
|
nvra,
|
|
2185
2077
|
summary
|
|
2186
2078
|
}) => `${nvra + summary}`.toLowerCase().includes(text.toLowerCase());
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
}));
|
|
2079
|
+
return jsx("div", {
|
|
2080
|
+
className: 'excluded-packages-table',
|
|
2081
|
+
children: jsx(FilterableTable, {
|
|
2082
|
+
isLoading: isLoading,
|
|
2083
|
+
tableName: 'Excluded packages table',
|
|
2084
|
+
columns: [{
|
|
2085
|
+
title: 'Excluded Package'
|
|
2086
|
+
}, {
|
|
2087
|
+
title: 'Summary'
|
|
2088
|
+
}],
|
|
2089
|
+
items: excludedPackages,
|
|
2090
|
+
renderRow: renderPackagesRow,
|
|
2091
|
+
perPageOptions: [{
|
|
2092
|
+
title: '5',
|
|
2093
|
+
value: 5
|
|
2094
|
+
}, {
|
|
2095
|
+
title: '10',
|
|
2096
|
+
value: 10
|
|
2097
|
+
}, {
|
|
2098
|
+
title: '20',
|
|
2099
|
+
value: 20
|
|
2100
|
+
}],
|
|
2101
|
+
filters: [jsx(FilterInput, {
|
|
2102
|
+
onChange: onTextInputFilterChange,
|
|
2103
|
+
placeholder: 'Filter excluded packages'
|
|
2104
|
+
}, 'excluded-packages-table__filter-input')]
|
|
2105
|
+
})
|
|
2106
|
+
});
|
|
2216
2107
|
};
|
|
2217
2108
|
|
|
2218
2109
|
function EcoSelect({
|
|
@@ -2224,37 +2115,34 @@ function EcoSelect({
|
|
|
2224
2115
|
}) {
|
|
2225
2116
|
const [isOpen, setIsOpen] = useState(false);
|
|
2226
2117
|
const [selected, setSelected] = useState([]);
|
|
2227
|
-
|
|
2228
2118
|
const onToggle = isOpen => setIsOpen(isOpen);
|
|
2229
|
-
|
|
2230
2119
|
const onSelect = (event, selection) => {
|
|
2231
2120
|
const result = selected.includes(selection) ? selected.filter(item => item !== selection) : [selection, ...selected];
|
|
2232
2121
|
setSelected(result);
|
|
2233
2122
|
onChange && onChange(result, event);
|
|
2234
2123
|
};
|
|
2235
|
-
|
|
2236
2124
|
const id = uniqueId('select-');
|
|
2237
|
-
return
|
|
2238
|
-
className: 'select'
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2125
|
+
return jsx("div", {
|
|
2126
|
+
className: 'select',
|
|
2127
|
+
children: jsx(Select, {
|
|
2128
|
+
id: id,
|
|
2129
|
+
variant: variant,
|
|
2130
|
+
"aria-label": ariaLabel,
|
|
2131
|
+
onToggle: (_event, isOpen) => onToggle(isOpen),
|
|
2132
|
+
onSelect: onSelect,
|
|
2133
|
+
selections: selected,
|
|
2134
|
+
isOpen: isOpen,
|
|
2135
|
+
placeholderText: placeholderText,
|
|
2136
|
+
className: 'pf-select-wrapper',
|
|
2137
|
+
children: options.map(option => jsx(SelectOption, {
|
|
2138
|
+
value: option
|
|
2139
|
+
}, option))
|
|
2140
|
+
})
|
|
2141
|
+
});
|
|
2253
2142
|
}
|
|
2254
2143
|
|
|
2255
2144
|
const ToggleGroup = props => {
|
|
2256
2145
|
const [selected, setSelected] = useState('');
|
|
2257
|
-
|
|
2258
2146
|
const onClick = (_, event) => {
|
|
2259
2147
|
const id = event.currentTarget.id;
|
|
2260
2148
|
setSelected(() => {
|
|
@@ -2262,19 +2150,17 @@ const ToggleGroup = props => {
|
|
|
2262
2150
|
return id;
|
|
2263
2151
|
});
|
|
2264
2152
|
};
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
})));
|
|
2153
|
+
return jsx(ToggleGroup$1, {
|
|
2154
|
+
"aria-label": props['aria-label'],
|
|
2155
|
+
children: props.options.map((option, index) => jsx(ToggleGroupItem, {
|
|
2156
|
+
text: option.text,
|
|
2157
|
+
buttonId: option.id,
|
|
2158
|
+
isSelected: selected === option.id,
|
|
2159
|
+
onChange: (event, _) => onClick(_, event)
|
|
2160
|
+
}, index))
|
|
2161
|
+
});
|
|
2275
2162
|
};
|
|
2276
2163
|
|
|
2277
|
-
/* eslint-disable camelcase */
|
|
2278
2164
|
const VulnerabilitiesTable = ({
|
|
2279
2165
|
vulnerabilities,
|
|
2280
2166
|
isLoading,
|
|
@@ -2283,65 +2169,80 @@ const VulnerabilitiesTable = ({
|
|
|
2283
2169
|
const getImpact = ({
|
|
2284
2170
|
severity
|
|
2285
2171
|
}) => {
|
|
2286
|
-
return
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2172
|
+
return jsx(Fragment, {
|
|
2173
|
+
children: jsxs("div", {
|
|
2174
|
+
className: 'vulnerabilities-table__impact-cell',
|
|
2175
|
+
children: [jsx(SecurityIcon, {
|
|
2176
|
+
className: `impact-icon color-${severity.toLowerCase()}`
|
|
2177
|
+
}), jsx("span", {
|
|
2178
|
+
children: severity
|
|
2179
|
+
})]
|
|
2180
|
+
})
|
|
2181
|
+
});
|
|
2291
2182
|
};
|
|
2292
|
-
|
|
2293
2183
|
const getCVE = ({
|
|
2294
2184
|
cve_id
|
|
2295
2185
|
}) => {
|
|
2296
|
-
return
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2186
|
+
return jsx(Fragment, {
|
|
2187
|
+
children: jsx("div", {
|
|
2188
|
+
className: 'vulnerabilities-table__cve-cell',
|
|
2189
|
+
children: jsx("a", {
|
|
2190
|
+
href: `https://access.redhat.com/security/cve/${cve_id}`,
|
|
2191
|
+
target: '_blank',
|
|
2192
|
+
rel: 'noopener noreferrer',
|
|
2193
|
+
children: cve_id
|
|
2194
|
+
})
|
|
2195
|
+
})
|
|
2196
|
+
});
|
|
2303
2197
|
};
|
|
2304
|
-
|
|
2305
2198
|
const getAffectedPackages = rpms => {
|
|
2306
|
-
return
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2199
|
+
return jsx(Fragment, {
|
|
2200
|
+
children: rpms == null ? void 0 : rpms.map(({
|
|
2201
|
+
gpg,
|
|
2202
|
+
name,
|
|
2203
|
+
version,
|
|
2204
|
+
release,
|
|
2205
|
+
architecture,
|
|
2206
|
+
nvra
|
|
2207
|
+
} = {}, index) => {
|
|
2208
|
+
return gpg ? jsx("div", {
|
|
2209
|
+
className: 'vulnerabilities-table__affected-packages-cell',
|
|
2210
|
+
children: jsx("a", {
|
|
2211
|
+
href: `https://access.redhat.com/downloads/content/${name}/${version}-${release}/${architecture}/${gpg == null ? void 0 : gpg.slice(-8)}/package`,
|
|
2212
|
+
target: '_blank',
|
|
2213
|
+
rel: 'noopener noreferrer',
|
|
2214
|
+
children: nvra
|
|
2215
|
+
})
|
|
2216
|
+
}, `affected-package-${index}`) : jsx("div", {
|
|
2217
|
+
className: 'vulnerabilities-table__affected-packages-cell',
|
|
2218
|
+
children: jsx("span", {
|
|
2219
|
+
children: nvra
|
|
2220
|
+
})
|
|
2221
|
+
}, `affected-package-${index}`);
|
|
2222
|
+
})
|
|
2223
|
+
});
|
|
2326
2224
|
};
|
|
2327
|
-
|
|
2328
2225
|
const getRPMAdvisory = ({
|
|
2329
2226
|
advisory_type,
|
|
2330
2227
|
advisory_id
|
|
2331
2228
|
}) => {
|
|
2332
|
-
return
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2229
|
+
return jsx(Fragment, {
|
|
2230
|
+
children: jsx("div", {
|
|
2231
|
+
className: 'vulnerabilities-table__rpm-advisory-cell',
|
|
2232
|
+
children: advisory_type && advisory_id ? jsxs("a", {
|
|
2233
|
+
href: `https://access.redhat.com/errata/${advisory_type}-${advisory_id}`,
|
|
2234
|
+
target: '_blank',
|
|
2235
|
+
rel: 'noopener noreferrer',
|
|
2236
|
+
children: [advisory_type, "-", advisory_id]
|
|
2237
|
+
}) : jsx("span", {
|
|
2238
|
+
children: "-"
|
|
2239
|
+
})
|
|
2240
|
+
})
|
|
2241
|
+
});
|
|
2339
2242
|
};
|
|
2340
|
-
|
|
2341
2243
|
const renderVulnerabilitiesRow = vulnerability => {
|
|
2342
2244
|
return [getImpact(vulnerability), getCVE(vulnerability), getAffectedPackages(vulnerability.rpm_nvra_with_link_data), getRPMAdvisory(vulnerability), vulnerability != null && vulnerability.creation_date ? format(new Date(vulnerability == null ? void 0 : vulnerability.creation_date), 'MMM dd, yyyy hh:mm a') : ''];
|
|
2343
2245
|
};
|
|
2344
|
-
|
|
2345
2246
|
const onTextInputFilterChange = (text, {
|
|
2346
2247
|
rpm_nvra_with_link_data,
|
|
2347
2248
|
severity,
|
|
@@ -2353,89 +2254,81 @@ const VulnerabilitiesTable = ({
|
|
|
2353
2254
|
}) => result += nvra, '');
|
|
2354
2255
|
return `${severity + cve_id + advisory_id + nvraList}`.toLowerCase().includes(text.toLowerCase());
|
|
2355
2256
|
};
|
|
2356
|
-
|
|
2357
2257
|
const onStatusFilterChange = (selected, vulnerability) => {
|
|
2358
2258
|
return selected === 'fixed' ? !!(vulnerability != null && vulnerability.advisory_id) : selected === 'unfixed' ? !(vulnerability != null && vulnerability.advisory_id) : true;
|
|
2359
2259
|
};
|
|
2360
|
-
|
|
2361
2260
|
const onImpactFilterChange = (selected, vulnerability) => {
|
|
2362
2261
|
return selected.length > 0 ? selected.includes(vulnerability.severity) : true;
|
|
2363
2262
|
};
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
sortFn: vulnerability => severitySortOrder[vulnerability.severity]
|
|
2373
|
-
}, {
|
|
2374
|
-
title: 'CVE',
|
|
2375
|
-
sortField: 'cve_id'
|
|
2376
|
-
}, {
|
|
2377
|
-
title: 'Affected Package(s)'
|
|
2378
|
-
}, {
|
|
2379
|
-
title: 'RPM Advisory',
|
|
2380
|
-
sortField: 'advisory_id'
|
|
2381
|
-
}, {
|
|
2382
|
-
title: 'Created',
|
|
2383
|
-
sortField: 'creation_date',
|
|
2384
|
-
sortFn: vulnerability => new Date(vulnerability == null ? void 0 : vulnerability.creation_date).getTime()
|
|
2385
|
-
}],
|
|
2386
|
-
items: vulnerabilities,
|
|
2387
|
-
renderRow: renderVulnerabilitiesRow,
|
|
2388
|
-
isLoading: isLoading,
|
|
2389
|
-
perPageOptions: [{
|
|
2390
|
-
title: '5',
|
|
2391
|
-
value: 5
|
|
2392
|
-
}, {
|
|
2393
|
-
title: '10',
|
|
2394
|
-
value: 10
|
|
2395
|
-
}, {
|
|
2396
|
-
title: '20',
|
|
2397
|
-
value: 20
|
|
2398
|
-
}],
|
|
2399
|
-
filters: [React__default.createElement(FilterInput, {
|
|
2400
|
-
key: 'vulnerabilities-table__filter-input',
|
|
2401
|
-
onChange: onTextInputFilterChange,
|
|
2402
|
-
placeholder: 'Filter vulnerabilities'
|
|
2403
|
-
}), !hideToggler ? React__default.createElement(ToggleGroup, {
|
|
2404
|
-
key: 'vulnerabilities-table__toggle-group',
|
|
2405
|
-
onChange: onStatusFilterChange,
|
|
2406
|
-
"aria-label": 'Vulnerability status filter',
|
|
2407
|
-
options: [{
|
|
2408
|
-
id: 'all',
|
|
2409
|
-
text: 'All'
|
|
2263
|
+
return jsx("div", {
|
|
2264
|
+
className: 'vulnerabilities-table',
|
|
2265
|
+
children: jsx(FilterableTable, {
|
|
2266
|
+
tableName: 'Vulnerabilities impact table',
|
|
2267
|
+
columns: [{
|
|
2268
|
+
title: 'Impact',
|
|
2269
|
+
sortField: 'severity',
|
|
2270
|
+
sortFn: vulnerability => severitySortOrder[vulnerability.severity]
|
|
2410
2271
|
}, {
|
|
2411
|
-
|
|
2412
|
-
|
|
2272
|
+
title: 'CVE',
|
|
2273
|
+
sortField: 'cve_id'
|
|
2413
2274
|
}, {
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2275
|
+
title: 'Affected Package(s)'
|
|
2276
|
+
}, {
|
|
2277
|
+
title: 'RPM Advisory',
|
|
2278
|
+
sortField: 'advisory_id'
|
|
2279
|
+
}, {
|
|
2280
|
+
title: 'Created',
|
|
2281
|
+
sortField: 'creation_date',
|
|
2282
|
+
sortFn: vulnerability => new Date(vulnerability == null ? void 0 : vulnerability.creation_date).getTime()
|
|
2283
|
+
}],
|
|
2284
|
+
items: vulnerabilities,
|
|
2285
|
+
renderRow: renderVulnerabilitiesRow,
|
|
2286
|
+
isLoading: isLoading,
|
|
2287
|
+
perPageOptions: [{
|
|
2288
|
+
title: '5',
|
|
2289
|
+
value: 5
|
|
2290
|
+
}, {
|
|
2291
|
+
title: '10',
|
|
2292
|
+
value: 10
|
|
2293
|
+
}, {
|
|
2294
|
+
title: '20',
|
|
2295
|
+
value: 20
|
|
2296
|
+
}],
|
|
2297
|
+
filters: [jsx(FilterInput, {
|
|
2298
|
+
onChange: onTextInputFilterChange,
|
|
2299
|
+
placeholder: 'Filter vulnerabilities'
|
|
2300
|
+
}, 'vulnerabilities-table__filter-input'), !hideToggler ? jsx(ToggleGroup, {
|
|
2301
|
+
onChange: onStatusFilterChange,
|
|
2302
|
+
"aria-label": 'Vulnerability status filter',
|
|
2303
|
+
options: [{
|
|
2304
|
+
id: 'all',
|
|
2305
|
+
text: 'All'
|
|
2306
|
+
}, {
|
|
2307
|
+
id: 'fixed',
|
|
2308
|
+
text: 'Fixed'
|
|
2309
|
+
}, {
|
|
2310
|
+
id: 'unfixed',
|
|
2311
|
+
text: 'Unfixed'
|
|
2312
|
+
}]
|
|
2313
|
+
}, 'vulnerabilities-table__toggle-group') : jsx(Fragment, {}), jsx(EcoSelect, {
|
|
2314
|
+
onChange: onImpactFilterChange,
|
|
2315
|
+
"aria-label": 'Impact filter',
|
|
2316
|
+
placeholderText: 'Impact',
|
|
2317
|
+
variant: 'checkbox',
|
|
2318
|
+
options: Array.from(new Set(vulnerabilities.map(vulnerability => vulnerability.severity)))
|
|
2319
|
+
}, 'vulnerabilities-table__select')]
|
|
2320
|
+
})
|
|
2321
|
+
});
|
|
2426
2322
|
};
|
|
2427
2323
|
|
|
2428
|
-
/* eslint-disable camelcase */
|
|
2429
2324
|
const severitySortOrder = {
|
|
2430
2325
|
Critical: 1,
|
|
2431
2326
|
Important: 2,
|
|
2432
2327
|
Moderate: 3,
|
|
2433
2328
|
Low: 4
|
|
2434
2329
|
};
|
|
2435
|
-
|
|
2436
2330
|
const InsertCss = () => {
|
|
2437
2331
|
const styleId = 'example-component-styles';
|
|
2438
|
-
|
|
2439
2332
|
if (!document.getElementById(styleId)) {
|
|
2440
2333
|
const styleTag = document.createElement('style');
|
|
2441
2334
|
styleTag.id = styleId;
|
|
@@ -2443,33 +2336,29 @@ const InsertCss = () => {
|
|
|
2443
2336
|
document.body.appendChild(styleTag);
|
|
2444
2337
|
}
|
|
2445
2338
|
};
|
|
2446
|
-
|
|
2447
2339
|
const PackagesTable = ({
|
|
2448
2340
|
vulnerabilities: _vulnerabilities = [],
|
|
2449
2341
|
rpms: _rpms = [],
|
|
2450
2342
|
hideToggler,
|
|
2451
2343
|
isLoading: _isLoading = false
|
|
2452
2344
|
}) => {
|
|
2453
|
-
const [excludedPackages, setExcludedPackages] =
|
|
2454
|
-
const [uniqueVulnerabilities, setUniqueVulnerabilities] =
|
|
2455
|
-
const [activeKey, setActiveKey] =
|
|
2456
|
-
|
|
2345
|
+
const [excludedPackages, setExcludedPackages] = useState([]);
|
|
2346
|
+
const [uniqueVulnerabilities, setUniqueVulnerabilities] = useState([]);
|
|
2347
|
+
const [activeKey, setActiveKey] = useState(0);
|
|
2348
|
+
useEffect(() => {
|
|
2457
2349
|
const VALID_REDHAT_GPG_KEYS = ['199e2f91fd431d51', '5326810137017186', '45689c882fa658e0', '219180cddb42a60e', '7514f77d8366b0d9', 'fd372689897da07a', '938a80caf21541eb', '08b871e6a5787476'];
|
|
2458
|
-
|
|
2459
2350
|
const packages = _rpms.filter(({
|
|
2460
2351
|
gpg
|
|
2461
2352
|
}) => !VALID_REDHAT_GPG_KEYS.includes(gpg));
|
|
2462
|
-
|
|
2463
2353
|
setExcludedPackages(packages);
|
|
2464
|
-
const uniqueVulnerabilities = [..._vulnerabilities];
|
|
2465
|
-
|
|
2354
|
+
const uniqueVulnerabilities = [..._vulnerabilities];
|
|
2355
|
+
// augment vulnerabilities with link data
|
|
2466
2356
|
uniqueVulnerabilities.forEach(vulnerability => {
|
|
2467
|
-
vulnerability.rpm_nvra_with_link_data = [];
|
|
2468
|
-
|
|
2357
|
+
vulnerability.rpm_nvra_with_link_data = [];
|
|
2358
|
+
// // CONNCERT-2121
|
|
2469
2359
|
if (vulnerability != null && vulnerability.affected_packages) {
|
|
2470
2360
|
var _vulnerability$affect;
|
|
2471
|
-
|
|
2472
|
-
vulnerability == null ? void 0 : (_vulnerability$affect = vulnerability.affected_packages) == null ? void 0 : _vulnerability$affect.forEach(({
|
|
2361
|
+
vulnerability == null || (_vulnerability$affect = vulnerability.affected_packages) == null || _vulnerability$affect.forEach(({
|
|
2473
2362
|
name,
|
|
2474
2363
|
arch
|
|
2475
2364
|
}) => {
|
|
@@ -2478,50 +2367,54 @@ const PackagesTable = ({
|
|
|
2478
2367
|
});
|
|
2479
2368
|
} else {
|
|
2480
2369
|
var _vulnerability$packag;
|
|
2481
|
-
|
|
2482
|
-
vulnerability == null ? void 0 : (_vulnerability$packag = vulnerability.packages) == null ? void 0 : _vulnerability$packag.forEach(p => {
|
|
2370
|
+
vulnerability == null || (_vulnerability$packag = vulnerability.packages) == null || _vulnerability$packag.forEach(p => {
|
|
2483
2371
|
var _p$rpm_nvra;
|
|
2484
|
-
|
|
2485
|
-
return p == null ? void 0 : (_p$rpm_nvra = p.rpm_nvra) == null ? void 0 : _p$rpm_nvra.forEach(rpm_nvra => {
|
|
2372
|
+
return p == null || (_p$rpm_nvra = p.rpm_nvra) == null ? void 0 : _p$rpm_nvra.forEach(rpm_nvra => {
|
|
2486
2373
|
const link_data = _rpms == null ? void 0 : _rpms.filter(pk => pk.nvra === rpm_nvra);
|
|
2487
2374
|
vulnerability.rpm_nvra_with_link_data.push(link_data[0]);
|
|
2488
2375
|
});
|
|
2489
2376
|
});
|
|
2490
2377
|
}
|
|
2491
|
-
|
|
2492
2378
|
return vulnerability;
|
|
2493
|
-
});
|
|
2494
|
-
|
|
2495
|
-
uniqueVulnerabilities.sort(vulnerability => severitySortOrder[vulnerability.severity]);
|
|
2496
|
-
|
|
2379
|
+
});
|
|
2380
|
+
// sort vulnerabilities by severity
|
|
2381
|
+
uniqueVulnerabilities.sort(vulnerability => severitySortOrder[vulnerability.severity]);
|
|
2382
|
+
// filter out vulnerabilities with duplicate CVE IDs
|
|
2497
2383
|
uniqueVulnerabilities.filter((value, index, self) => self.findIndex(vulnerability => vulnerability.cve_id === value.cve_id) === index);
|
|
2498
2384
|
setUniqueVulnerabilities(uniqueVulnerabilities);
|
|
2499
2385
|
}, [_rpms, _vulnerabilities]);
|
|
2500
2386
|
InsertCss();
|
|
2501
|
-
return
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2387
|
+
return jsx(Fragment, {
|
|
2388
|
+
children: (uniqueVulnerabilities.length > 0 || excludedPackages.length > 0) && jsx("div", {
|
|
2389
|
+
className: 'packages-table',
|
|
2390
|
+
children: jsxs(Tabs, {
|
|
2391
|
+
activeKey: activeKey,
|
|
2392
|
+
onSelect: (_evt, tabKey) => setActiveKey(tabKey),
|
|
2393
|
+
variant: 'default',
|
|
2394
|
+
isBox: true,
|
|
2395
|
+
"aria-label": 'vulnerability tab',
|
|
2396
|
+
children: [uniqueVulnerabilities.length > 0 && jsx(Tab, {
|
|
2397
|
+
eventKey: 0,
|
|
2398
|
+
title: `Vulnerabilities (${uniqueVulnerabilities.length})`,
|
|
2399
|
+
children: jsx(VulnerabilitiesTable, {
|
|
2400
|
+
vulnerabilities: uniqueVulnerabilities,
|
|
2401
|
+
isLoading: _isLoading,
|
|
2402
|
+
hideToggler: hideToggler
|
|
2403
|
+
})
|
|
2404
|
+
}), excludedPackages.length > 0 && jsxs(Tab, {
|
|
2405
|
+
eventKey: 1,
|
|
2406
|
+
title: `Excluded Packages (${excludedPackages.length})`,
|
|
2407
|
+
children: [jsx("p", {
|
|
2408
|
+
className: 'packages-table__excluded-packages-disclaimer',
|
|
2409
|
+
children: "The following packages were found in this image and cannot be scanned or compared to public vulnerability information. This image may include additional packages or content not found or listed below."
|
|
2410
|
+
}), jsx(ExcludedPackagesTable, {
|
|
2411
|
+
excludedPackages: excludedPackages,
|
|
2412
|
+
isLoading: _isLoading
|
|
2413
|
+
})]
|
|
2414
|
+
})]
|
|
2415
|
+
})
|
|
2416
|
+
})
|
|
2417
|
+
});
|
|
2525
2418
|
};
|
|
2526
2419
|
|
|
2527
2420
|
export { PackagesTable, severitySortOrder };
|