1- import React , { useEffect } from ' react'
2- import ReactJson from '@microlink/react-json-view' ;
3- import { AgGridReact } from 'ag-grid- react' ;
1+ import ReactJson from "@microlink/ react-json-view" ;
2+ import { AgGridReact } from "ag-grid-react" ;
3+ import React from " react" ;
44
5- import { DEFAULT_MATCHES_COL_DEF , DetectionMatchesCols } from './MatchesTableCols' ;
6- import { LicenseDetectionDetails } from '../../pages/LicenseDetections/licenseDefinitions' ;
5+ import { LicenseDetectionDetails } from "../../pages/LicenseDetections/licenseDefinitions" ;
6+ import {
7+ DEFAULT_FILE_REGION_COL_DEF ,
8+ DetectionFileRegionCols ,
9+ } from "./FileRegionTableCols" ;
10+ import {
11+ DEFAULT_MATCHES_COL_DEF ,
12+ DetectionMatchesCols ,
13+ } from "./MatchesTableCols" ;
714
8- import './licenseDetection.css'
9- import '../../styles/entityCommonStyles.css'
10- import { DEFAULT_FILE_REGION_COL_DEF , DetectionFileRegionCols } from './FileRegionTableCols' ;
15+ import "../../styles/entityCommonStyles.css" ;
16+ import "./licenseDetection.css" ;
1117
1218interface LicenseDetectionEntityProps {
13- licenseDetection : LicenseDetectionDetails | null ,
19+ licenseDetection : LicenseDetectionDetails | null ;
1420}
1521const LicenseDetectionEntity = ( props : LicenseDetectionEntityProps ) => {
1622 const { licenseDetection } = props ;
1723 const matches = licenseDetection ?. matches || [ ] ;
1824 const file_regions = licenseDetection ?. file_regions || [ ] ;
1925
20- useEffect ( ( ) => {
21- // if(matches)
22- // matches.push({
23- // ...matches[0]
24- // })
25- } , [ matches ] ) ;
26-
27- if ( ! licenseDetection ) {
26+ if ( ! licenseDetection ) {
2827 return (
2928 < div >
30- < h5 >
31- No License Detection to show
32- </ h5 >
29+ < h5 > No License Detection to show</ h5 >
3330 </ div >
34- )
31+ ) ;
3532 }
3633 return (
37- < div className = ' license-detecion-entity' >
34+ < div className = " license-detecion-entity" >
3835 < h5 >
39- { licenseDetection . license_expression }
40- < br />
36+ { licenseDetection . license_expression }
37+ < br />
4138 </ h5 >
42- < div className = 'license-entity-properties' >
43- {
44- [
45- // [ "License Expression:", licenseDetection.license_expression || "NA" ],
46- [ "License Identifier:" , licenseDetection . identifier || "NA" ] ,
47- [ "Instances:" , ( licenseDetection . detection_count || 0 ) . toString ( ) ] ,
48- ...(
49- licenseDetection . detection_log &&
50- Array . isArray ( licenseDetection . detection_log ) && licenseDetection . detection_log . length &&
39+ < div className = "license-entity-properties" >
40+ { [
41+ // [ "License Expression:", licenseDetection.license_expression || "NA" ],
42+ [ "License Identifier:" , licenseDetection . identifier || "NA" ] ,
43+ [ "Instances:" , ( licenseDetection . detection_count || 0 ) . toString ( ) ] ,
44+ ...( licenseDetection . detection_log &&
45+ Array . isArray ( licenseDetection . detection_log ) &&
46+ licenseDetection . detection_log . length && [
5147 [
52- [
53- "Detection log " ,
54- < >
55- < ul >
56- {
57- licenseDetection . detection_log . map ( ( log_item , idx ) => (
58- < li key = { String ( log_item ) + idx } >
59- { log_item }
60- </ li >
61- ) )
62- }
63- </ ul >
64- </ >
65- ]
66- ]
67- )
68- ] . map ( entry => (
69- < React . Fragment key = { entry [ 0 ] . toString ( ) } >
70- < span className = 'property' >
71- { entry [ 0 ] || "" }
72- </ span >
73- < span className = 'value' >
74- { entry [ 1 ] || "" }
75- </ span >
76- < br />
77- </ React . Fragment >
78- ) )
79- }
48+ "Detection log " ,
49+ < >
50+ < ul >
51+ { licenseDetection . detection_log . map ( ( log_item , idx ) => (
52+ < li key = { String ( log_item ) + idx } > { log_item } </ li >
53+ ) ) }
54+ </ ul >
55+ </ > ,
56+ ] ,
57+ ] ) ,
58+ ] . map ( ( entry ) => (
59+ < React . Fragment key = { entry [ 0 ] . toString ( ) } >
60+ < span className = "property" > { entry [ 0 ] || "" } </ span >
61+ < span className = "value" > { entry [ 1 ] || "" } </ span >
62+ < br />
63+ </ React . Fragment >
64+ ) ) }
8065 </ div >
81-
8266 { /* <br/>
8367 <br/>
8468 <br/>
8569 <br/> */ }
86- < br />
70+ < br />
8771 Matches
8872 < AgGridReact
8973 rowData = { matches }
9074 columnDefs = { DetectionMatchesCols }
9175 className = "ag-theme-alpine ag-grid-customClass matches-table"
92-
9376 ensureDomOrder
9477 enableCellTextSelection
95-
9678 pagination = { false }
9779 defaultColDef = { DEFAULT_MATCHES_COL_DEF }
9880 />
99- < br />
81+ < br />
10082 File regions
10183 < AgGridReact
10284 rowData = { file_regions }
10385 columnDefs = { DetectionFileRegionCols }
10486 className = "ag-theme-alpine ag-grid-customClass file-regions-table"
105-
10687 ensureDomOrder
10788 enableCellTextSelection
108-
10989 pagination = { false }
11090 defaultColDef = { DEFAULT_FILE_REGION_COL_DEF }
11191 />
112- < br />
92+ < br />
11393 Raw license detection:
11494 < ReactJson
11595 src = { licenseDetection }
@@ -118,7 +98,7 @@ const LicenseDetectionEntity = (props: LicenseDetectionEntityProps) => {
11898 collapsed = { 0 }
11999 />
120100 </ div >
121- )
122- }
101+ ) ;
102+ } ;
123103
124- export default LicenseDetectionEntity
104+ export default LicenseDetectionEntity ;
0 commit comments