Skip to content

Commit

Permalink
refactor(ui): Remove obsolete code
Browse files Browse the repository at this point in the history
With new API endpoints, item count functions are no longer needed in the
UI code, so remove them. Also, as `VulnerabilityRating` is finally
exposed from back-end, no need to keep a copy of it in the UI code
either.

Further cleanup will be possible, once the
`...runs/${runId}/vulnerabilities` endpoint also returns the overall
vulnerability rating directly instead of calculating it in front-end.

Signed-off-by: Jyrki Keisala <jyrki.keisala@doubleopen.org>
  • Loading branch information
Etsija committed Dec 23, 2024
1 parent 7d31414 commit 5e39bb0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 175 deletions.
6 changes: 2 additions & 4 deletions ui/src/helpers/calc-overall-vulnerability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
* License-Filename: LICENSE
*/

import {
VulnerabilityRating,
vulnerabilityRatings,
} from '@/helpers/get-status-class';
import { VulnerabilityRating } from '@/api/requests';
import { vulnerabilityRatings } from '@/helpers/get-status-class';

/**
* Calculate the overall vulnerability rating based on the individual ratings.
Expand Down
9 changes: 6 additions & 3 deletions ui/src/helpers/get-status-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
* License-Filename: LICENSE
*/

import { JobStatus, OrtRunStatus, Severity } from '@/api/requests';
import {
JobStatus,
OrtRunStatus,
Severity,
VulnerabilityRating,
} from '@/api/requests';
import { PackageManager } from '@/routes/organizations/$orgId/products/$productId/repositories/$repoId/-types';

// Combine statuses reported either by ORT Runs or the individual jobs within them.
Expand All @@ -32,8 +37,6 @@ export const vulnerabilityRatings = {
NONE: 0,
} as const;

export type VulnerabilityRating = keyof typeof vulnerabilityRatings;

// TailwindCSS classes matching to statuses
//
// Note: all color classes need to be defined as they are here, as they
Expand Down
163 changes: 0 additions & 163 deletions ui/src/helpers/item-counts.ts

This file was deleted.

7 changes: 2 additions & 5 deletions ui/src/helpers/sorting-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
* License-Filename: LICENSE
*/

import { Severity } from '@/api/requests';
import {
VulnerabilityRating,
vulnerabilityRatings,
} from '@/helpers/get-status-class';
import { Severity, VulnerabilityRating } from '@/api/requests';
import { vulnerabilityRatings } from '@/helpers/get-status-class';

/**
* Compare two severities by their severity level. The severity levels are defined as follows:
Expand Down

0 comments on commit 5e39bb0

Please sign in to comment.