-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): Alert Correlation Rule Badges (#1189)
Co-authored-by: Tal <[email protected]>
- Loading branch information
1 parent
9db23d8
commit 86a0358
Showing
9 changed files
with
290 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Badge } from "@tremor/react"; | ||
import Image from "next/image"; | ||
import { AlertDto } from "app/alerts/models"; | ||
|
||
type AlertsFoundBadgeProps = { | ||
alertsFound: AlertDto[]; | ||
isLoading: boolean; | ||
}; | ||
|
||
export const AlertsFoundBadge = ({ | ||
alertsFound, | ||
isLoading, | ||
}: AlertsFoundBadgeProps) => { | ||
if (alertsFound.length === 0) { | ||
return ( | ||
<Badge className="mt-3 w-full" color="gray"> | ||
{isLoading | ||
? "Getting your alerts..." | ||
: "No alerts were found with this condition. Please try something else."} | ||
</Badge> | ||
); | ||
} | ||
|
||
const images = alertsFound.reduce<string[]>( | ||
(acc, { source }) => [...new Set([...acc, ...source])], | ||
[] | ||
); | ||
|
||
return ( | ||
<Badge className="mt-3 w-full" color="teal"> | ||
<span className="flex items-center"> | ||
{images.map((source, index) => ( | ||
<Image | ||
className={`inline-block ${index == 0 ? "" : "-ml-2"}`} | ||
key={source} | ||
alt={source} | ||
height={24} | ||
width={24} | ||
title={source} | ||
src={`/icons/${source}-icon.png`} | ||
/> | ||
))} | ||
<span className="ml-4"> | ||
{alertsFound.length} alert(s) were found matching this condition | ||
</span> | ||
</span> | ||
</Badge> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.