Skip to content

Commit

Permalink
Update links to reports in audit tasks listpage
Browse files Browse the repository at this point in the history
- Audit task reports should now open in audit reports detail page.
  • Loading branch information
a-h-abdelsalam committed Feb 2, 2024
1 parent 4114c26 commit 0fa51d0
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/web/pages/audits/__tests__/__snapshots__/listpage.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ exports[`AuditPage tests should render full AuditPage 1`] = `
<div
class="c2"
>
Compliance Status
Compliance Percent
</div>
</th>
<th
Expand Down Expand Up @@ -1375,7 +1375,7 @@ exports[`AuditPage tests should render full AuditPage 1`] = `
<a
class="c52 c53"
data-testid="details-link"
href="/report/1234"
href="/auditreport/1234"
>
<div
class="c54"
Expand Down Expand Up @@ -1408,7 +1408,7 @@ exports[`AuditPage tests should render full AuditPage 1`] = `
<a
class="c52"
data-testid="details-link"
href="/report/1234"
href="/auditreport/1234"
>
Wed, Jul 10, 2019 2:51 PM CEST
</a>
Expand Down
4 changes: 2 additions & 2 deletions src/web/pages/audits/__tests__/__snapshots__/row.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ exports[`Audit Row tests should render 1`] = `
<a
class="c6 c7"
data-testid="details-link"
href="/report/1234"
href="/auditreport/1234"
>
<div
class="c8"
Expand Down Expand Up @@ -349,7 +349,7 @@ exports[`Audit Row tests should render 1`] = `
<a
class="c6"
data-testid="details-link"
href="/report/1234"
href="/auditreport/1234"
>
Wed, Jul 10, 2019 2:51 PM CEST
</a>
Expand Down
10 changes: 5 additions & 5 deletions src/web/pages/audits/__tests__/__snapshots__/table.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ exports[`Audits table tests should render 1`] = `
<div
class="c8"
>
Compliance Status
Compliance Percent
</div>
</th>
<th
Expand Down Expand Up @@ -829,7 +829,7 @@ exports[`Audits table tests should render 1`] = `
<a
class="c25 c26"
data-testid="details-link"
href="/report/1234"
href="/auditreport/1234"
>
<div
class="c27"
Expand Down Expand Up @@ -862,7 +862,7 @@ exports[`Audits table tests should render 1`] = `
<a
class="c25"
data-testid="details-link"
href="/report/1234"
href="/auditreport/1234"
>
Sat, Aug 10, 2019 2:51 PM CEST
</a>
Expand Down Expand Up @@ -1212,7 +1212,7 @@ exports[`Audits table tests should render 1`] = `
<a
class="c25 c26"
data-testid="details-link"
href="/report/5678"
href="/auditreport/5678"
>
<div
class="c27"
Expand Down Expand Up @@ -1245,7 +1245,7 @@ exports[`Audits table tests should render 1`] = `
<a
class="c25"
data-testid="details-link"
href="/report/1234"
href="/auditreport/1234"
>
Wed, Jul 10, 2019 2:51 PM CEST
</a>
Expand Down
18 changes: 9 additions & 9 deletions src/web/pages/audits/__tests__/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ describe('Audit Row tests', () => {
const detailsLinks = getAllByTestId('details-link');

expect(detailsLinks[0]).toHaveTextContent('Done');
expect(detailsLinks[0]).toHaveAttribute('href', '/report/1234');
expect(detailsLinks[0]).toHaveAttribute('href', '/auditreport/1234');

// Report
expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST');
expect(detailsLinks[1]).toHaveAttribute('href', '/report/1234');
expect(detailsLinks[1]).toHaveAttribute('href', '/auditreport/1234');

// Compliance Status
expect(bars[1]).toHaveAttribute('title', '50%');
Expand Down Expand Up @@ -387,7 +387,7 @@ describe('Audit Row tests', () => {
const detailsLinks = getAllByTestId('details-link');

expect(detailsLinks[0]).toHaveTextContent('0 %');
expect(detailsLinks[0]).toHaveAttribute('href', '/report/5678');
expect(detailsLinks[0]).toHaveAttribute('href', '/auditreport/5678');

// Report
expect(detailsLinks.length).toBe(1);
Expand Down Expand Up @@ -495,11 +495,11 @@ describe('Audit Row tests', () => {
const detailsLinks = getAllByTestId('details-link');

expect(detailsLinks[0]).toHaveTextContent('Stopped');
expect(detailsLinks[0]).toHaveAttribute('href', '/report/5678');
expect(detailsLinks[0]).toHaveAttribute('href', '/auditreport/5678');

// Report
expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST');
expect(detailsLinks[1]).toHaveAttribute('href', '/report/1234');
expect(detailsLinks[1]).toHaveAttribute('href', '/auditreport/1234');

// Compliance Status
expect(bars[1]).toHaveAttribute('title', '50%');
Expand Down Expand Up @@ -605,11 +605,11 @@ describe('Audit Row tests', () => {
const detailsLinks = getAllByTestId('details-link');

expect(detailsLinks[0]).toHaveTextContent('Done');
expect(detailsLinks[0]).toHaveAttribute('href', '/report/1234');
expect(detailsLinks[0]).toHaveAttribute('href', '/auditreport/1234');

// Report
expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST');
expect(detailsLinks[1]).toHaveAttribute('href', '/report/1234');
expect(detailsLinks[1]).toHaveAttribute('href', '/auditreport/1234');

// Compliance Status
expect(bars[1]).toHaveAttribute('title', '50%');
Expand Down Expand Up @@ -718,11 +718,11 @@ describe('Audit Row tests', () => {
const detailsLinks = getAllByTestId('details-link');

expect(detailsLinks[0]).toHaveTextContent('Done');
expect(detailsLinks[0]).toHaveAttribute('href', '/report/1234');
expect(detailsLinks[0]).toHaveAttribute('href', '/auditreport/1234');

// Report
expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST');
expect(detailsLinks[1]).toHaveAttribute('href', '/report/1234');
expect(detailsLinks[1]).toHaveAttribute('href', '/auditreport/1234');

// Compliance Status
expect(bars[1]).toHaveAttribute('title', '50%');
Expand Down
2 changes: 1 addition & 1 deletion src/web/pages/audits/__tests__/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('Audits table tests', () => {
expect(header[0]).toHaveTextContent('Name');
expect(header[1]).toHaveTextContent('Status');
expect(header[2]).toHaveTextContent('Report');
expect(header[3]).toHaveTextContent('Compliance Status');
expect(header[3]).toHaveTextContent('Compliance Percent');
expect(header[4]).toHaveTextContent('Actions');
});

Expand Down
20 changes: 17 additions & 3 deletions src/web/pages/audits/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,21 @@ import {GREENBONE_SENSOR_SCANNER_TYPE} from 'gmp/models/scanner';

import ComplianceStatusBar from 'web/components/bar/compliancestatusbar';

import {renderReport} from 'web/pages/tasks/row';
import DateTime from 'web/components/date/datetime';
import DetailsLink from 'web/components/link/detailslink';

const renderAuditReport = (report, links) => {
if (!isDefined(report)) {
return null;
}
return (
<span>
<DetailsLink type="auditreport" id={report.id} textOnly={!links}>
<DateTime date={report.timestamp} />
</DetailsLink>
</span>
);
};

const getComplianceStatus = report => {
if (!isDefined(report)) {
Expand Down Expand Up @@ -141,9 +155,9 @@ const Row = ({
{entity.comment && <Comment>({entity.comment})</Comment>}
</TableData>
<TableData>
<AuditStatus task={entity} links={links} />
<AuditStatus isAudit={true} task={entity} links={links} />
</TableData>
<TableData>{renderReport(entity.last_report, links)}</TableData>
<TableData>{renderAuditReport(entity.last_report, links)}</TableData>
<TableData>
{isDefined(entity.last_report) && (
<ComplianceStatusBar
Expand Down
4 changes: 2 additions & 2 deletions src/web/pages/tasks/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ import Trend from './trend';

import {GREENBONE_SENSOR_SCANNER_TYPE} from 'gmp/models/scanner';

export const renderReport = (report, links) => {
const renderReport = (report, links) => {
if (!isDefined(report)) {
return null;
}
return (
<span>
<DetailsLink type="auditreport" id={report.id} textOnly={!links}>
<DetailsLink type="report" id={report.id} textOnly={!links}>
<DateTime date={report.timestamp} />
</DetailsLink>
</span>
Expand Down
15 changes: 10 additions & 5 deletions src/web/pages/tasks/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const StyledDetailsLink = styled(DetailsLink)`
}
`;

const TaskStatus = ({task, links = true}) => {
const TaskStatus = ({task, links = true, isAudit = false}) => {
let report_id;
if (isDefined(task.current_report)) {
report_id = task.current_report.id;
Expand All @@ -47,16 +47,20 @@ const TaskStatus = ({task, links = true}) => {
}

return (
<StyledDetailsLink type="report" id={report_id} textOnly={!links}>
<StyledDetailsLink
type={isAudit ? 'auditreport' : 'report'}
id={report_id}
textOnly={!links}
>
<StatusBar
status={
task.isContainer()
? task.status === TASK_STATUS.interrupted
? TASK_STATUS.uploadinginterrupted
: task.status === TASK_STATUS.running ||
task.status === TASK_STATUS.processing
? TASK_STATUS.processing
: TASK_STATUS.container
task.status === TASK_STATUS.processing
? TASK_STATUS.processing
: TASK_STATUS.container
: task.status
}
progress={task.progress}
Expand All @@ -66,6 +70,7 @@ const TaskStatus = ({task, links = true}) => {
};

TaskStatus.propTypes = {
isAudit: PropTypes.bool,
links: PropTypes.bool,
task: PropTypes.model.isRequired,
};
Expand Down

0 comments on commit 0fa51d0

Please sign in to comment.