-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Omkar Phansopkar <omkarphansopkar@gmail.com>
- Loading branch information
Showing
15 changed files
with
219 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/components/LicenseEntity/LicenseMatchCells/MatchedText.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from "react"; | ||
import { useMatchedTextContext } from "../MatchedTextContext"; | ||
import CoreLink from "../../CoreLink/CoreLink"; | ||
import { LicenseMatch } from "../../../services/importedJsonTypes"; | ||
|
||
interface MatchedTextRendererProps { | ||
value: string; | ||
match: LicenseMatch; | ||
} | ||
|
||
const MatchedTextRenderer = (props: MatchedTextRendererProps) => { | ||
const { value, match } = props; | ||
const { openDiffWindow } = useMatchedTextContext(); | ||
|
||
const trimmedText = value; | ||
|
||
return ( | ||
<CoreLink | ||
key={value} | ||
onClick={() => | ||
value && | ||
openDiffWindow( | ||
value, | ||
match.rule_identifier, | ||
match.start_line, | ||
match.match_coverage | ||
) | ||
} | ||
> | ||
{trimmedText} | ||
</CoreLink> | ||
); | ||
}; | ||
|
||
export default MatchedTextRenderer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React from "react"; | ||
import { | ||
LicenseClueMatch, | ||
LicenseDetectionMatch, | ||
} from "../../services/importedJsonTypes"; | ||
import { Table } from "react-bootstrap"; | ||
import MatchedTextRenderer from "./LicenseMatchCells/MatchedText"; | ||
import MatchLicenseExpressionRenderer from "./LicenseMatchCells/MatchLicenseExpression"; | ||
import CoreLink from "../CoreLink/CoreLink"; | ||
import { LicenseTypes } from "../../services/workbenchDB.types"; | ||
import { MatchedTextProvider } from "./MatchedTextContext"; | ||
|
||
interface LicenseMatchProps { | ||
showLIcenseText?: boolean; | ||
matchesInfo: | ||
| { | ||
licenseType: LicenseTypes.DETECTION; | ||
matches: LicenseDetectionMatch[]; | ||
} | ||
| { | ||
licenseType: LicenseTypes.CLUE; | ||
matches: LicenseClueMatch[]; | ||
}; | ||
} | ||
const LicenseMatchesTable = (props: LicenseMatchProps) => { | ||
const { matchesInfo, showLIcenseText } = props; | ||
|
||
return ( | ||
<MatchedTextProvider> | ||
<div> | ||
{matchesInfo.matches.map((match) => ( | ||
<div className="matches-table-container"> | ||
<Table size="sm" bordered> | ||
<tbody> | ||
<tr> | ||
<td>License Expression</td> | ||
<td> | ||
<MatchLicenseExpressionRenderer | ||
matchInfo={{ | ||
match: match, | ||
spdxLicense: false, | ||
}} | ||
/> | ||
</td> | ||
</tr> | ||
{showLIcenseText && ( | ||
<tr className="matched-text-row"> | ||
<td>Matched Text</td> | ||
<td> | ||
<div> | ||
<MatchedTextRenderer | ||
match={match} | ||
value={match.matched_text} | ||
/> | ||
</div> | ||
</td> | ||
</tr> | ||
)} | ||
<tr> | ||
<td>Score</td> | ||
<td>{match.score}</td> | ||
</tr> | ||
<tr> | ||
<td>Matched length</td> | ||
<td>{match.matched_length}</td> | ||
</tr> | ||
<tr> | ||
<td>Match Coverage</td> | ||
<td>{match.match_coverage}</td> | ||
</tr> | ||
<tr> | ||
<td>Matcher</td> | ||
<td>{match.matcher}</td> | ||
</tr> | ||
<tr> | ||
<td>Rule URL</td> | ||
<td> | ||
<CoreLink href={match.rule_url} external> | ||
{match.rule_identifier} | ||
</CoreLink> | ||
</td> | ||
</tr> | ||
{matchesInfo.licenseType === LicenseTypes.DETECTION && ( | ||
<tr> | ||
<td>License Expression SPDX</td> | ||
<td> | ||
<MatchLicenseExpressionRenderer | ||
matchInfo={{ | ||
match: match, | ||
spdxLicense: true, | ||
}} | ||
/> | ||
</td> | ||
</tr> | ||
)} | ||
</tbody> | ||
</Table> | ||
</div> | ||
))} | ||
</div> | ||
</MatchedTextProvider> | ||
); | ||
}; | ||
|
||
export default LicenseMatchesTable; |
Oops, something went wrong.