forked from guacsec/trustify-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvulnerability-table.tsx
More file actions
120 lines (114 loc) · 4.07 KB
/
vulnerability-table.tsx
File metadata and controls
120 lines (114 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import React from "react";
import { NavLink } from "react-router-dom";
import { Table, Tbody, Td, Th, Thead, Tr } from "@patternfly/react-table";
import { extendedSeverityFromSeverity } from "@app/api/models";
import { SeverityShieldAndText } from "@app/components/SeverityShieldAndText";
import { SimplePagination } from "@app/components/SimplePagination";
import {
ConditionalTableBody,
TableHeaderContentWithControls,
TableRowContentWithControls,
} from "@app/components/TableControls";
import { VulnerabilityDescription } from "@app/components/VulnerabilityDescription";
import { formatDate } from "@app/utils/utils";
import { SbomsCount } from "./components/SbomsCount";
import { VulnerabilitySearchContext } from "./vulnerability-context";
export const VulnerabilityTable: React.FC = () => {
const { isFetching, fetchError, totalItemCount, tableControls } =
React.useContext(VulnerabilitySearchContext);
const {
numRenderedColumns,
currentPageItems,
propHelpers: {
paginationProps,
tableProps,
getThProps,
getTrProps,
getTdProps,
},
} = tableControls;
return (
<>
<Table {...tableProps} aria-label="Vulnerability table">
<Thead>
<Tr>
<TableHeaderContentWithControls {...tableControls}>
<Th {...getThProps({ columnKey: "identifier" })} />
<Th {...getThProps({ columnKey: "title" })} />
<Th {...getThProps({ columnKey: "severity" })} />
<Th {...getThProps({ columnKey: "published" })} />
<Th {...getThProps({ columnKey: "sboms" })} />
</TableHeaderContentWithControls>
</Tr>
</Thead>
<ConditionalTableBody
isLoading={isFetching}
isError={!!fetchError}
isNoData={totalItemCount === 0}
numRenderedColumns={numRenderedColumns}
>
{currentPageItems.map((item, rowIndex) => {
return (
<Tbody key={item.identifier}>
<Tr {...getTrProps({ item })}>
<TableRowContentWithControls
{...tableControls}
item={item}
rowIndex={rowIndex}
>
<Td
width={15}
modifier="breakWord"
{...getTdProps({
columnKey: "identifier",
item: item,
rowIndex,
})}
>
<NavLink to={`/vulnerabilities/${item.identifier}`}>
{item.identifier}
</NavLink>
</Td>
<Td
width={45}
modifier="truncate"
{...getTdProps({ columnKey: "title" })}
>
<VulnerabilityDescription vulnerability={item} />
</Td>
<Td width={10} {...getTdProps({ columnKey: "severity" })}>
<SeverityShieldAndText
value={extendedSeverityFromSeverity(
item.average_severity,
)}
/>
</Td>
<Td width={10} {...getTdProps({ columnKey: "published" })}>
{formatDate(item.published)}
</Td>
<Td
width={10}
{...getTdProps({
columnKey: "sboms",
item: item,
rowIndex,
})}
>
<SbomsCount vulnerabilityId={item.identifier} />
</Td>
</TableRowContentWithControls>
</Tr>
</Tbody>
);
})}
</ConditionalTableBody>
</Table>
<SimplePagination
idPrefix="vulnerability-table"
isTop={false}
isCompact
paginationProps={paginationProps}
/>
</>
);
};