Skip to content

Commit

Permalink
feat: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shahargl committed Nov 24, 2024
2 parents 64e5c3b + fcb8bd6 commit 5f25edf
Show file tree
Hide file tree
Showing 164 changed files with 2,169 additions and 1,071 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

<div align="center">
<a href='http://makeapullrequest.com'>
<img alt='PRs Welcome' src='https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=shields'/>
</a>
<img alt='PRs Welcome' src='https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=shields'/></a>
<a href="https://slack.keephq.dev">
<img src="https://img.shields.io/badge/Join-important.svg?color=4A154B&label=Slack&logo=slack&labelColor=334155&logoColor=f5f5f5" alt="Join Slack" /></a>
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/keephq/keep"/>
<a href="https://github.com/keephq/keep/commits/main">
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/keephq/keep"/></a>
<a href="https://codecov.io/gh/keephq/keep" >
<img src="https://codecov.io/gh/keephq/keep/branch/main/graph/badge.svg?token=2VT6XYMRGS"/>
</a>
Expand Down
2 changes: 1 addition & 1 deletion keep-ui/app/(keep)/alerts/alert-assignee.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from "react";
import { NameInitialsAvatar } from "react-name-initials-avatar";
import { useUsers } from "utils/hooks/useUsers";
import { useUsers } from "@/entities/users/model/useUsers";

interface Props {
assignee: string | undefined;
Expand Down
90 changes: 74 additions & 16 deletions keep-ui/app/(keep)/alerts/alert-severity-border.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,59 @@
import clsx from "clsx";
import { Severity } from "./models";

const getSeverityBgClassName = (severity?: Severity) => {
switch (severity) {
case "critical":
return "bg-red-500";
case "high":
case "error":
return "bg-orange-500";
case "warning":
return "bg-yellow-500";
case "info":
return "bg-blue-500";
default:
return "bg-emerald-500";
}
};

const getSeverityLabelClassName = (severity?: Severity) => {
switch (severity) {
case "critical":
return "bg-red-100";
case "high":
case "error":
return "bg-orange-100";
case "warning":
return "bg-yellow-100";
case "info":
return "bg-blue-100";
default:
return "bg-emerald-100";
}
};

const getSeverityTextClassName = (severity?: Severity) => {
switch (severity) {
case "critical":
return "text-red-500";
case "high":
case "error":
return "text-orange-500";
case "warning":
return "text-amber-900";
case "info":
return "text-blue-500";
default:
return "text-emerald-500";
}
};

export function AlertSeverityBorder({
severity,
}: {
severity: Severity | undefined;
}) {
const getSeverityBgClassName = (severity?: Severity) => {
switch (severity) {
case "critical":
return "bg-red-500";
case "high":
case "error":
return "bg-orange-500";
case "warning":
return "bg-yellow-500";
case "info":
return "bg-blue-500";
default:
return "bg-emerald-500";
}
};

return (
<div
className={clsx(
Expand All @@ -32,3 +64,29 @@ export function AlertSeverityBorder({
/>
);
}

export function AlertSeverityBorderIcon({ severity }: { severity: Severity }) {
return (
<div
className={clsx("w-1 h-4 rounded-lg", getSeverityBgClassName(severity))}
/>
);
}

export function AlertSeverityLabel({ severity }: { severity: Severity }) {
return (
<span
className={clsx(
"flex items-center gap-1 text-sm font-medium py-0.5 px-2 overflow-hidden relative",
getSeverityLabelClassName(severity)
)}
>
<div
className={clsx("w-1 h-4 rounded-lg", getSeverityBgClassName(severity))}
/>
<span className={clsx("capitalize", getSeverityTextClassName(severity))}>
{severity}
</span>
</span>
);
}
117 changes: 74 additions & 43 deletions keep-ui/app/(keep)/alerts/alert-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ import { Fragment } from "react";
import Image from "next/image";
import { Dialog, Transition } from "@headlessui/react";
import { AlertDto } from "./models";
import { Button, Title, Card, Badge } from "@tremor/react";
import { Button, Title, Badge } from "@tremor/react";
import { IoMdClose } from "react-icons/io";
import AlertTimeline from "./alert-timeline";
import { useAlerts } from "utils/hooks/useAlerts";
import { TopologyMap } from "../topology/ui/map";
import { TopologySearchProvider } from "@/app/(keep)/topology/TopologySearchContext";
import {
AlertSeverityBorderIcon,
AlertSeverityLabel,
} from "./alert-severity-border";
import { FieldHeader } from "@/shared/ui/FieldHeader";
import { QuestionMarkCircleIcon } from "@heroicons/react/20/solid";
import { Tooltip } from "@/shared/ui/Tooltip";
import { Link } from "@/components/ui";

type AlertSidebarProps = {
isOpen: boolean;
Expand Down Expand Up @@ -57,11 +65,14 @@ const AlertSidebar = ({ isOpen, toggle, alert }: AlertSidebarProps) => {
{/*Will add soon*/}
{/*<AlertMenu alert={alert} presetName="feed" isInSidebar={true} />*/}
{/*<Divider></Divider>*/}
<Dialog.Title className="text-3xl font-bold" as={Title}>
Alert Details
<Badge className="ml-4" color="orange">
Beta
</Badge>
<Dialog.Title
className="text-xl font-bold flex flex-col gap-2 items-start"
as={Title}
>
{alert?.severity && (
<AlertSeverityLabel severity={alert.severity} />
)}
{alert?.name ? alert.name : "Alert Details"}
</Dialog.Title>
</div>
<div>
Expand All @@ -72,43 +83,63 @@ const AlertSidebar = ({ isOpen, toggle, alert }: AlertSidebarProps) => {
</div>
{alert && (
<div className="space-y-4">
<Card>
<div className="mt-4 space-y-2">
<p>
<strong>Name:</strong> {alert.name}
</p>
<p>
<strong>Service:</strong> {alert.service}
</p>
<p>
<strong>Severity:</strong> {alert.severity}
</p>
<p>
<Image
src={`/icons/${alert.source![0]}-icon.png`}
alt={alert.source![0]}
width={24}
height={24}
className="inline-block w-6 h-6"
/>
</p>
<p>
<strong>Description:</strong> {alert.description}
</p>
<p>
<strong>Fingerprint:</strong> {alert.fingerprint}
</p>
</div>
</Card>
<Card className="flex-grow">
<AlertTimeline
key={auditData ? auditData.length : 1}
alert={alert}
auditData={auditData || []}
isLoading={isLoading}
onRefresh={handleRefresh}
/>
</Card>
<div className="space-y-2">
<p>
<FieldHeader>Name</FieldHeader>
{alert.name}
</p>
<p>
<FieldHeader>Service</FieldHeader>
<Badge size="sm" color="gray">
{alert.service}
</Badge>
</p>
<p>
<FieldHeader>Source</FieldHeader>
<Image
src={`/icons/${alert.source![0]}-icon.png`}
alt={alert.source![0]}
width={24}
height={24}
className="inline-block w-6 h-6"
/>
</p>
<p>
<FieldHeader>Description</FieldHeader>
{alert.description}
</p>
<p>
<FieldHeader className="flex items-center gap-1">
Fingerprint
<Tooltip
content={
<>
Fingerprints are unique identifiers associated with
alert instances in Keep. Every provider declares the
fields fingerprints are calculated upon.{" "}
<Link
href="https://docs.keephq.dev/providers/fingerprints#fingerprints"
className="text-white"
>
Docs
</Link>
</>
}
className="z-50"
>
<QuestionMarkCircleIcon className="w-4 h-4" />
</Tooltip>
</FieldHeader>
{alert.fingerprint}
</p>
</div>
<AlertTimeline
key={auditData ? auditData.length : 1}
alert={alert}
auditData={auditData || []}
isLoading={isLoading}
onRefresh={handleRefresh}
/>
<Title>Related Services</Title>
<TopologySearchProvider>
<TopologyMap
Expand Down
12 changes: 4 additions & 8 deletions keep-ui/app/(keep)/alerts/alert-table-alert-facets.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import React, { useCallback, useEffect } from "react";
import {
AlertFacetsProps,
FacetValue,
FacetFilters,
} from "./alert-table-facet-types";
import React, { useCallback } from "react";
import { AlertFacetsProps, FacetValue } from "./alert-table-facet-types";
import { Facet } from "./alert-table-facet";
import {
getFilteredAlertsForFacet,
Expand Down Expand Up @@ -148,7 +144,7 @@ export const AlertFacets: React.FC<AlertFacetsProps> = ({
if (a.label === "n/a") return 1;
if (b.label === "n/a") return -1;
const orderDiff =
getSeverityOrder(a.label) - getSeverityOrder(b.label);
getSeverityOrder(b.label) - getSeverityOrder(a.label);
if (orderDiff !== 0) return orderDiff;
return b.count - a.count;
});
Expand Down Expand Up @@ -253,7 +249,7 @@ export const AlertFacets: React.FC<AlertFacetsProps> = ({
showSkeleton={showSkeleton}
/>
<Facet
name="Incident Related"
name="Incident"
facetKey="incident"
values={getFacetValues("incident")}
onSelect={(value, exclusive, isAllOnly) =>
Expand Down
39 changes: 1 addition & 38 deletions keep-ui/app/(keep)/alerts/alert-table-facet-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import { FacetFilters } from "./alert-table-facet-types";
import { AlertDto, Severity } from "./models";
import {
ChevronDownIcon,
ChevronRightIcon,
UserCircleIcon,
BellIcon,
ExclamationCircleIcon,
CheckCircleIcon,
CircleStackIcon,
BellSlashIcon,
FireIcon,
} from "@heroicons/react/24/outline";
import { AlertDto } from "./models";
import { isQuickPresetRange } from "@/components/ui/DateRangePicker";

export const getFilteredAlertsForFacet = (
Expand Down Expand Up @@ -83,32 +72,6 @@ export const getFilteredAlertsForFacet = (
});
};

export const getStatusIcon = (status: string) => {
switch (status.toLowerCase()) {
case "firing":
return ExclamationCircleIcon;
case "resolved":
return CheckCircleIcon;
case "acknowledged":
return CircleStackIcon;
default:
return CircleStackIcon;
}
};

export const getStatusColor = (status: string) => {
switch (status.toLowerCase()) {
case "firing":
return "red";
case "resolved":
return "green";
case "acknowledged":
return "blue";
default:
return "gray";
}
};

export const getSeverityOrder = (severity: string): number => {
switch (severity) {
case "low":
Expand Down
Loading

0 comments on commit 5f25edf

Please sign in to comment.