Skip to content

Commit ea5e43a

Browse files
Venefilynlbarcziova
authored andcommitted
fix(OpenScanHub): Schema not reflecting API data
There was a discrepancy between what the API should return and what is being returned. This fixes some of the fields that can be null and handles the case where that occurs.
1 parent 4f1fdcb commit ea5e43a

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

frontend/src/apiDefinitions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,9 @@ export interface OSHScan {
482482
release: string | null;
483483
repo_name: string;
484484
repo_namespace: string;
485-
scan_results_url: string;
486-
status: string;
485+
scan_results_url: string | null;
486+
status: string | null;
487487
submitted_time: number | null;
488-
task_id: number;
489-
url: string;
488+
task_id: number | null;
489+
url: string | null;
490490
}

frontend/src/components/osh/OSHScan.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ export const OSHScan = () => {
8383
<DescriptionListTerm>Status</DescriptionListTerm>
8484
<DescriptionListDescription>
8585
<StatusLabel
86-
status={data.status}
86+
status={data.status ?? "unknown"}
8787
target={"rawhide"}
8888
link={data.url}
8989
/>
9090
</DescriptionListDescription>
9191

92-
{data.status === "succeeded" ? (
92+
{data.status === "succeeded" && data.scan_results_url ? (
9393
<>
9494
<DescriptionListTerm>New findings</DescriptionListTerm>
9595
<DescriptionListDescription>

frontend/src/components/statusLabels/StatusLabel.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ import { BaseStatusLabel, BaseStatusLabelProps } from "./BaseStatusLabel";
1616

1717
export interface StatusLabelProps {
1818
status: string;
19-
link?: string;
19+
link?: string | null;
2020
target?: string;
2121
}
2222

2323
/**
2424
* Status label component that is used from other components.
2525
*/
2626
export const StatusLabel: React.FC<StatusLabelProps> = (props) => {
27-
const [color, setColor] = useState<BaseStatusLabelProps["color"]>("purple");
28-
const [icon, setIcon] = useState(<InfoCircleIcon />);
27+
const [color, setColor] = useState<BaseStatusLabelProps["color"]>("grey");
28+
const [icon, setIcon] = useState(<QuestionCircleIcon />);
2929

3030
useEffect(() => {
3131
switch (props.status) {
@@ -45,7 +45,7 @@ export const StatusLabel: React.FC<StatusLabelProps> = (props) => {
4545
setIcon(<ExclamationTriangleIcon />);
4646
break;
4747
case "pending":
48-
setColor("cyan");
48+
setColor("teal");
4949
setIcon(<HourglassHalfIcon />);
5050
break;
5151
case "running":

0 commit comments

Comments
 (0)