-
-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathLicenseMatchesTable.tsx
More file actions
146 lines (143 loc) · 5.35 KB
/
Copy pathLicenseMatchesTable.tsx
File metadata and controls
146 lines (143 loc) · 5.35 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import React from "react";
import { Button, OverlayTrigger, Popover, Table } from "react-bootstrap";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faInfoCircle } from "@fortawesome/free-solid-svg-icons";
import {
LicenseClueMatch,
LicenseDetectionMatch,
} from "../../services/importedJsonTypes";
import MatchedTextRenderer from "./LicenseMatchCells/MatchedText";
import MatchLicenseExpressionRenderer from "./LicenseMatchCells/MatchLicenseExpression";
import { MatchedTextProvider } from "./MatchedTextContext";
import MatchRuleDetails from "./MatchRuleDetails";
import CoreLink from "../CoreLink/CoreLink";
import { useWorkbenchDB } from "../../contexts/dbContext";
interface LicenseMatchProps {
showLIcenseText?: boolean;
matches: LicenseClueMatch[] | LicenseDetectionMatch[];
}
const LicenseMatchesTable = (props: LicenseMatchProps) => {
const { matches, showLIcenseText } = props;
const { goToFileInTableView } = useWorkbenchDB();
return (
<MatchedTextProvider>
<div>
{matches.map((match, idx) => (
<div
className="matches-table-container"
key={match.license_expression + "_" + idx}
>
<Table size="sm" bordered>
<tbody>
<tr>
<td colSpan={2}>License Expression</td>
<td colSpan={7}>
<MatchLicenseExpressionRenderer
matchInfo={{
match: match,
spdxLicense: false,
}}
/>
</td>
</tr>
{match.spdx_license_expression && (
<tr>
<td colSpan={2}>License Expression SPDX</td>
<td colSpan={7}>
<MatchLicenseExpressionRenderer
matchInfo={{
match: match,
spdxLicense: true,
}}
/>
</td>
</tr>
)}
{match.from_file && (
<tr>
<td colSpan={2}>Matched file</td>
<td colSpan={7}>
<CoreLink
onClick={() => goToFileInTableView(match.from_file)}
>
{match.from_file}
</CoreLink>
</td>
</tr>
)}
{showLIcenseText && (
<tr className="matched-text-row">
<td colSpan={2}>Matched Text</td>
<td colSpan={7}>
<div>
<MatchedTextRenderer
match={match}
value={match.matched_text}
/>
</div>
</td>
</tr>
)}
<tr>
<td colSpan={2}>Start Line</td>
<td colSpan={3}>{match.start_line}</td>
<td colSpan={2}>End Line</td>
<td colSpan={2}>{match.end_line}</td>
</tr>
<tr>
<td colSpan={2}>Matched length</td>
<td colSpan={3}>{match.matched_length}</td>
<td colSpan={2}>Match Coverage</td>
<td colSpan={2}>{match.match_coverage}</td>
</tr>
<tr>
<td colSpan={2}>Score</td>
<td colSpan={3}>{match.score}</td>
<td colSpan={2}>Rule Rele ance</td>
<td colSpan={2}>{match.rule_relevance}</td>
</tr>
<tr>
<td colSpan={2}>Rule</td>
<td colSpan={3}>
<span>
<span>
{match.rule_url ? (
<CoreLink external href={match.rule_url || null}>
{match.rule_identifier}
</CoreLink>
) : (
match.rule_identifier
)}
</span>
<OverlayTrigger
trigger={["click"]}
placement="right"
rootClose
transition={false}
delay={{ show: 200, hide: 300 }}
overlay={
<Popover className="rule-popover">
<Popover.Body>
<MatchRuleDetails match={match} />
</Popover.Body>
</Popover>
}
>
<Button className="ms-3 p-0 border-0 bg-transparent cursor-pointer rule-info-button">
<FontAwesomeIcon icon={faInfoCircle} />
</Button>
</OverlayTrigger>
</span>
</td>
<td colSpan={2}>Matcher</td>
<td colSpan={2}>{match.matcher}</td>
</tr>
</tbody>
</Table>
</div>
))}
</div>
</MatchedTextProvider>
);
};
export default LicenseMatchesTable;