Skip to content

Commit

Permalink
reporter-web-app: Make the package id optional for rule violations
Browse files Browse the repository at this point in the history
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 <thomas.steenbergen@here.com>
  • Loading branch information
tsteenbe committed Sep 17, 2021
1 parent 41580bf commit 3591c9a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 30 deletions.
8 changes: 3 additions & 5 deletions reporter-web-app/public/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 41 additions & 25 deletions reporter-web-app/src/components/RuleViolationsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,37 @@ 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;
},
render: (webAppRuleViolation) => {
const webAppPackage = webAppRuleViolation.package;

return webAppPackage.isExcluded ? (
<span className="ort-excludes">
<Tooltip
placement="right"
title={Array.from(webAppPackage.excludeReasons).join(', ')}
>
<FileExcelOutlined className="ort-excluded" />
</Tooltip>
</span>
) : (
<FileAddOutlined />
);
if (webAppPackage) {
return webAppPackage.isExcluded ? (
<span className="ort-excludes">
<Tooltip
placement="right"
title={Array.from(webAppPackage.excludeReasons).join(', ')}
>
<FileExcelOutlined className="ort-excluded" />
</Tooltip>
</span>
) : (
<FileAddOutlined />
);
}

return null;
},
responsive: ['md'],
width: '2em'
Expand Down Expand Up @@ -266,27 +272,35 @@ class RuleViolationsTable extends React.Component {
</Panel>
)
}
<Panel header="Details" key="2">
<PackageDetails webAppPackage={webAppPackage} />
</Panel>
{
webAppPackage.hasLicenses()
webAppRuleViolation.hasPackage()
&& (
<Panel header="Details" key="2">
<PackageDetails webAppPackage={webAppPackage} />
</Panel>
)
}
{
webAppRuleViolation.hasPackage()
&& webAppPackage.hasLicenses()
&& (
<Panel header="Licenses" key="3">
<PackageLicenses webAppPackage={webAppPackage} />
</Panel>
)
}
{
webAppPackage.hasPaths()
webAppRuleViolation.hasPackage()
&& webAppPackage.hasPaths()
&& (
<Panel header="Paths" key="4">
<PackagePaths paths={webAppPackage.paths} />
</Panel>
)
}
{
webAppPackage.hasFindings()
webAppRuleViolation.hasPackage()
&& webAppPackage.hasFindings()
&& (
<Panel header="Scan Results" key="5">
<PackageFindingsTable
Expand All @@ -296,7 +310,8 @@ class RuleViolationsTable extends React.Component {
)
}
{
webAppPackage.hasPathExcludes()
webAppRuleViolation.hasPackage()
&& webAppPackage.hasPathExcludes()
&& (
<Panel header="Path Excludes" key="6">
<PathExcludesTable
Expand All @@ -306,7 +321,8 @@ class RuleViolationsTable extends React.Component {
)
}
{
webAppPackage.hasScopeExcludes()
webAppRuleViolation.hasPackage()
&& webAppPackage.hasScopeExcludes()
&& (
<Panel header="Scope Excludes" key="7">
<ScopeExcludesTable
Expand Down
6 changes: 6 additions & 0 deletions reporter-web-app/src/models/WebAppRuleViolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class WebAppRuleViolation {

if (Number.isInteger(obj.pkg)) {
this.#packageIndex = obj.pkg;
} else {
this.#packageIndex = -1;
}

if (obj.severity) {
Expand Down Expand Up @@ -209,6 +211,10 @@ class WebAppRuleViolation {
hasHowToFix() {
return !!this.#howToFix;
}

hasPackage() {
return !!this.#package;
}
}

export default WebAppRuleViolation;

0 comments on commit 3591c9a

Please sign in to comment.