Skip to content

Commit

Permalink
refactor(web-app-template): Swap two columns in summary views
Browse files Browse the repository at this point in the history
Swap the column for `severitiy` with the column for `is_excluded`, so
that the `is_excluded` column is no more next to the package name. This
avoid mis-leading the user into thinking that `is_excluded` tells
whether the package is excluded. It is supposed to say the the `issue`
is excluded.

Note: This prepares for making `is_excluded` column reflect exclusions
of `Issue.affectedPath`. The summary view of rule violations and
vulnerabilities are only changed for consistency with the issues summary
view.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Apr 23, 2024
1 parent dfee399 commit 5e805cf
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 182 deletions.
124 changes: 62 additions & 62 deletions plugins/reporters/web-app-template/src/components/IssuesTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,68 @@ class IssuesTable extends React.Component {

const columns = [];

if (showExcludesColumn) {
columns.push({
align: 'right',
filters: (() => [
{
text: (
<span>
<FileExcelOutlined className="ort-excluded" />
{' '}
Excluded
</span>
),
value: 'excluded'
},
{
text: (
<span>
<FileAddOutlined />
{' '}
Included
</span>
),
value: 'included'
}
])(),
filteredValue: filteredInfo.excludes || null,
key: 'excludes',
onFilter: (value, webAppOrtIssue) => {
const webAppPackage = webAppOrtIssue.package;

if (value === 'excluded') {
return webAppPackage.isExcluded;
}

if (value === 'included') {
return !webAppPackage.isExcluded;
}

return false;
},
render: (webAppOrtIssue) => {
const webAppPackage = webAppOrtIssue.package;

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

columns.push({
align: 'center',
dataIndex: 'severityIndex',
Expand Down Expand Up @@ -129,68 +191,6 @@ class IssuesTable extends React.Component {
width: '5em'
});

if (showExcludesColumn) {
columns.push({
align: 'right',
filters: (() => [
{
text: (
<span>
<FileExcelOutlined className="ort-excluded" />
{' '}
Excluded
</span>
),
value: 'excluded'
},
{
text: (
<span>
<FileAddOutlined />
{' '}
Included
</span>
),
value: 'included'
}
])(),
filteredValue: filteredInfo.excludes || null,
key: 'excludes',
onFilter: (value, webAppOrtIssue) => {
const webAppPackage = webAppOrtIssue.package;

if (value === 'excluded') {
return webAppPackage.isExcluded;
}

if (value === 'included') {
return !webAppPackage.isExcluded;
}

return false;
},
render: (webAppOrtIssue) => {
const webAppPackage = webAppOrtIssue.package;

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

columns.push(
{
ellipsis: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,68 @@ class RuleViolationsTable extends React.Component {
}

const columns = [];

if (showExcludesColumn) {
columns.push({
align: 'right',
filters: (() => [
{
text: (
<span>
<FileExcelOutlined className="ort-excluded" />
{' '}
Excluded
</span>
),
value: 'excluded'
},
{
text: (
<span>
<FileAddOutlined />
{' '}
Included
</span>
),
value: 'included'
}
])(),
filteredValue: filteredInfo.excludes || null,
key: 'excludes',
onFilter: (value, webAppRuleViolation) => {
if (!webAppRuleViolation.hasPackage()) return true;

const { isExcluded } = webAppRuleViolation.package;

return (isExcluded && value === 'excluded') || (!isExcluded && value === 'included');
},
render: (webAppRuleViolation) => {
const webAppPackage = webAppRuleViolation.package;

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'
});
}

columns.push({
align: 'center',
dataIndex: 'severityIndex',
Expand Down Expand Up @@ -130,67 +192,6 @@ class RuleViolationsTable extends React.Component {
width: '5em'
});

if (showExcludesColumn) {
columns.push({
align: 'right',
filters: (() => [
{
text: (
<span>
<FileExcelOutlined className="ort-excluded" />
{' '}
Excluded
</span>
),
value: 'excluded'
},
{
text: (
<span>
<FileAddOutlined />
{' '}
Included
</span>
),
value: 'included'
}
])(),
filteredValue: filteredInfo.excludes || null,
key: 'excludes',
onFilter: (value, webAppRuleViolation) => {
if (!webAppRuleViolation.hasPackage()) return true;

const { isExcluded } = webAppRuleViolation.package;

return (isExcluded && value === 'excluded') || (!isExcluded && value === 'included');
},
render: (webAppRuleViolation) => {
const webAppPackage = webAppRuleViolation.package;

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'
});
}

columns.push(
{
dataIndex: 'packageName',
Expand Down
Loading

0 comments on commit 5e805cf

Please sign in to comment.