From 3591c9a65652de176f4b5d0cb52ed3c9c179b7e9 Mon Sep 17 00:00:00 2001 From: Thomas Steenbergen Date: Thu, 9 Sep 2021 10:01:44 +0200 Subject: [PATCH] reporter-web-app: Make the package id optional for rule violations A rule violation may not necessarily correspond to a specific package. For example, it would not make sense to require a package identifier for a rule violation which represents an issue with the (ORT result) labels. Signed-off-by: Thomas Steenbergen --- reporter-web-app/public/index.html | 8 +-- .../src/components/RuleViolationsTable.js | 66 ++++++++++++------- .../src/models/WebAppRuleViolation.js | 6 ++ 3 files changed, 50 insertions(+), 30 deletions(-) diff --git a/reporter-web-app/public/index.html b/reporter-web-app/public/index.html index 5b6bd940f8db..bbc03e4d7906 100644 --- a/reporter-web-app/public/index.html +++ b/reporter-web-app/public/index.html @@ -62473,12 +62473,10 @@ "rule_violation_resolutions" : [ ], "rule_violations" : [ { "_id" : 0, - "rule" : "UNHANDLED_LICENSE", - "pkg" : 77, - "license" : 7, - "license_source" : "DETECTED", + "rule" : "DEPRECATED_LABEL", + "pkg" : null, "severity" : "ERROR", - "message" : "The license LicenseRef-scancode-public-domain is currently not covered by policy rules. The license was detected in package NPM::eslint-scope:5.1.0", + "message" : "The scan is using the deprecated label 'org=fake-unit'.", "how_to_fix" : "A text written in MarkDown to help users resolve policy violations\nwhich may link to additional resources." }, { "_id" : 1, diff --git a/reporter-web-app/src/components/RuleViolationsTable.js b/reporter-web-app/src/components/RuleViolationsTable.js index 72f0fa63255f..508954c5aacc 100644 --- a/reporter-web-app/src/components/RuleViolationsTable.js +++ b/reporter-web-app/src/components/RuleViolationsTable.js @@ -162,12 +162,14 @@ class RuleViolationsTable extends React.Component { onFilter: (value, webAppRuleViolation) => { const webAppPackage = webAppRuleViolation.package; - if (value === 'excluded') { - return webAppPackage.isExcluded; - } + if (webAppPackage) { + if (value === 'excluded') { + return webAppPackage.isExcluded; + } - if (value === 'included') { - return !webAppPackage.isExcluded; + if (value === 'included') { + return !webAppPackage.isExcluded; + } } return false; @@ -175,18 +177,22 @@ class RuleViolationsTable extends React.Component { render: (webAppRuleViolation) => { const webAppPackage = webAppRuleViolation.package; - return webAppPackage.isExcluded ? ( - - - - - - ) : ( - - ); + if (webAppPackage) { + return webAppPackage.isExcluded ? ( + + + + + + ) : ( + + ); + } + + return null; }, responsive: ['md'], width: '2em' @@ -266,11 +272,17 @@ class RuleViolationsTable extends React.Component { ) } - - - { - webAppPackage.hasLicenses() + webAppRuleViolation.hasPackage() + && ( + + + + ) + } + { + webAppRuleViolation.hasPackage() + && webAppPackage.hasLicenses() && ( @@ -278,7 +290,8 @@ class RuleViolationsTable extends React.Component { ) } { - webAppPackage.hasPaths() + webAppRuleViolation.hasPackage() + && webAppPackage.hasPaths() && ( @@ -286,7 +299,8 @@ class RuleViolationsTable extends React.Component { ) } { - webAppPackage.hasFindings() + webAppRuleViolation.hasPackage() + && webAppPackage.hasFindings() && (