Skip to content

Commit e31efbc

Browse files
Merge pull request #569 from nexB/fix/licenseDetections
Fix license detection parser issues, trimmed filter options, hide empty 'other dependencies'
2 parents 3d31b21 + a9a4b30 commit e31efbc

29 files changed

+690
-443
lines changed

.eslintrc.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
"es6": true,
55
"node": true
66
},
7+
"plugins": ["css-import-order"],
78
"extends": [
89
"eslint:recommended",
910
"plugin:@typescript-eslint/eslint-recommended",
1011
"plugin:@typescript-eslint/recommended",
1112
"plugin:import/recommended",
1213
"plugin:import/electron",
13-
"plugin:import/typescript"
14+
"plugin:import/typescript",
15+
"plugin:css-import-order/recommended"
1416
],
1517
"parser": "@typescript-eslint/parser",
1618
"settings": {
1719
"import/resolver": {
1820
"node": {
19-
"extensions": [".js", ".jsx", ".ts", ".tsx"]
21+
"extensions": [".js", ".jsx", ".ts", ".tsx", "json"]
2022
}
2123
}
22-
},
24+
}
2325
}

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"electron-packager": "^16.0.0",
5858
"electron-rebuild": "^3.2.9",
5959
"eslint": "^8.24.0",
60+
"eslint-plugin-css-import-order": "^1.1.0",
6061
"eslint-plugin-import": "^2.26.0",
6162
"fork-ts-checker-webpack-plugin": "^7.2.13",
6263
"json-loader": "^0.5.7",

src/App.tsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
import React from "react";
2-
import { HashRouter, Routes, Route } from "react-router-dom";
2+
import { HashRouter, Route,Routes } from "react-router-dom";
33
import { ToastContainer } from "react-toastify";
44

5+
import DropZone from "./components/DropZone/DropZone";
6+
import Layout from "./components/Layout/Layout";
57
import { ROUTES } from "./constants/routes";
68
import { WorkbenchDBProvider } from "./contexts/dbContext";
7-
8-
import Layout from "./components/Layout/Layout";
9-
import DropZone from "./components/DropZone/DropZone";
10-
11-
import Home from "./pages/Home/Home";
12-
import TableView from "./pages/TableView/TableView";
9+
import { WorkbenchStateProvider } from "./contexts/stateContext";
10+
import About from "./pages/About/About";
11+
import ChartView from "./pages/ChartView/ChartView";
1312
import FileInfoDash from "./pages/FileInfoDash/FileInfoDash";
13+
import Home from "./pages/Home/Home";
14+
import LicenseDetections from "./pages/LicenseDetections/LicenseDetections";
1415
import LicenseInfoDash from "./pages/LicenseInfoDash/LicenseInfoDash";
1516
import PackageInfoDash from "./pages/PackageInfoDash/PackageInfoDash";
1617
import Packages from "./pages/Packages/Packages";
17-
import LicenseDetections from "./pages/LicenseDetections/LicenseDetections";
18-
import ChartView from "./pages/ChartView/ChartView";
19-
import ScanInfo from "./pages/ScanInfo/ScanInfo";
20-
import About from "./pages/About/About";
2118
import PageNotFound from "./pages/PageNotFound";
19+
import ScanInfo from "./pages/ScanInfo/ScanInfo";
20+
import TableView from "./pages/TableView/TableView";
2221

2322
import "./utils/ensureRendererDeps";
24-
2523
import "./fontawesome";
24+
2625
import "rc-tree/assets/index.css";
2726
import "react-toastify/dist/ReactToastify.css";
2827
import "bootstrap/dist/css/bootstrap.min.css";
2928
import "react-tooltip/dist/react-tooltip.css";
30-
3129
import "./app.css";
3230
import "./dashStyles.css";
3331
import "./customFaColors.css";
34-
import { WorkbenchStateProvider } from "./contexts/stateContext";
3532

3633
const App = () => {
3734
return (

src/components/FileTree/FileTree.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const FileTree = (props: React.HTMLProps<HTMLDivElement>) => {
1616
initialized,
1717
importedSqliteFilePath,
1818
currentPath,
19-
currentPathType,
2019
updateCurrentPath,
2120
} = workbenchDB;
2221

@@ -38,7 +37,9 @@ const FileTree = (props: React.HTMLProps<HTMLDivElement>) => {
3837
updateCurrentPath(path, pathType);
3938
}
4039

41-
// console.log("Current path & type", currentPath, currentPathType);
40+
// useEffect(() => {
41+
// console.log("Current path", currentPath);
42+
// }, [currentPath]);
4243

4344
if (!treeData) {
4445
return (
@@ -58,6 +59,7 @@ const FileTree = (props: React.HTMLProps<HTMLDivElement>) => {
5859
showLine
5960
treeData={treeData}
6061
switcherIcon={SwitcherIcon}
62+
selectedKeys={[currentPath]}
6163
onSelect={(keys, info) => {
6264
if (keys && keys[0])
6365
selectPath(

src/components/Layout/Layout.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import ImportFallback from '../ImportFallback/ImportFallback';
1010

1111
import { useWorkbenchDB } from '../../contexts/dbContext';
1212
import { FILE_TREE_ROUTES, IMPORT_FALLBACK_ROUTES } from '../../constants/routes';
13+
import ProgressLoader from '../ProgressLoader/ProgressLoader';
1314

14-
import './layout.css';
1515
import "allotment/dist/style.css";
16+
import './layout.css';
1617

1718
const Layout = (props: React.PropsWithChildren) => {
1819
const { pathname } = useLocation();
19-
const { initialized } = useWorkbenchDB();
20+
const { initialized, loadingStatus } = useWorkbenchDB();
2021

2122
const isImportFallbackRoute = IMPORT_FALLBACK_ROUTES.find(route => pathname.includes(route)) !== undefined;
2223
const showFileTree = FILE_TREE_ROUTES.find(route => pathname.includes(route)) !== undefined;
@@ -36,7 +37,14 @@ const Layout = (props: React.PropsWithChildren) => {
3637
</Allotment.Pane>
3738
<Allotment.Pane className='content-pane'>
3839
<div className='content-container'>
39-
{ isImportFallbackRoute && !initialized ? <ImportFallback /> : props.children }
40+
{
41+
isImportFallbackRoute && !initialized ? (
42+
loadingStatus !== null ?
43+
<ProgressLoader progress={loadingStatus} />
44+
:
45+
<ImportFallback />
46+
) : props.children
47+
}
4048
</div>
4149
</Allotment.Pane>
4250
</Allotment>

src/components/Layout/layout.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
padding: 10px;
1616
padding-top: 5px;
1717
padding-bottom: 5px;
18-
min-height: 95%;
18+
min-height: 100%;
1919
}

src/components/LicenseDetection/FileRegionTableCols.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ColDef } from "ag-grid-community";
2+
import { TickRenderer } from "../../pages/TableView/CustomCellRenderers";
23

34
const MINI_FIELD_WIDTH = 90;
45

@@ -29,4 +30,11 @@ export const DetectionFileRegionCols: ColDef[] = [
2930
field: 'end_line',
3031
width: MINI_FIELD_WIDTH,
3132
},
33+
{
34+
headerName: 'From package',
35+
field: 'from_package',
36+
cellRenderer: TickRenderer,
37+
maxWidth: 110,
38+
suppressMenu: true,
39+
},
3240
]
Lines changed: 52 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,95 @@
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

1218
interface LicenseDetectionEntityProps {
13-
licenseDetection: LicenseDetectionDetails | null,
19+
licenseDetection: LicenseDetectionDetails | null;
1420
}
1521
const 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

Comments
 (0)