-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathAlertDetail.tsx
55 lines (51 loc) · 1.7 KB
/
AlertDetail.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { AlertConversation } from "@/api/generated";
import { isAlertMalicious } from "@/features/alerts/lib/is-alert-malicious";
import { isAlertSecret } from "@/features/alerts/lib/is-alert-secret";
import { Markdown } from "./Markdown";
type MaliciousPkgType = {
name: string;
type: string;
status: string;
description: string;
};
export function AlertDetail({ alert }: { alert: AlertConversation }) {
if (alert.trigger_string === null) return "N/A";
if (isAlertSecret(alert) && typeof alert.trigger_string === "string") {
return (
<div className="bg-gray-25 rounded-lg overflow-auto p-4">
<Markdown>{alert.trigger_string}</Markdown>
</div>
);
}
if (isAlertMalicious(alert) && typeof alert.trigger_string === "object") {
const maliciousPkg = alert.trigger_string as MaliciousPkgType;
return (
<div className="max-h-40 w-fit overflow-y-auto whitespace-pre-wrap p-2">
<label className="font-medium">Package:</label>
<a
href={`https://www.insight.stacklok.com/report/${maliciousPkg.type}/${maliciousPkg.name}?utm_source=codegate-ui`}
target="_blank"
rel="noopener noreferrer"
className="text-brand-500 hover:underline"
>
{maliciousPkg.type}/{maliciousPkg.name}
</a>
{maliciousPkg.status && (
<>
<br />
<label className="font-medium">Status:</label> {maliciousPkg.status}
</>
)}
{maliciousPkg.description && (
<>
<br />
<label className="font-medium">Description:</label>{" "}
{maliciousPkg.description}
</>
)}
</div>
);
}
return null;
}