Skip to content

Commit

Permalink
chore(ui): better empty states in incident view (#1979)
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Sep 22, 2024
1 parent 94e696c commit 1fb5e54
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
19 changes: 18 additions & 1 deletion keep-ui/app/incidents/[id]/incident-timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { useIncidentAlerts } from "utils/hooks/useIncidents";
import { IncidentDto } from "../models";
import Image from "next/image";
import AlertSeverity from "app/alerts/alert-severity";
import { EmptyStateCard } from "@/components/ui/EmptyStateCard";
import { useRouter } from "next/navigation";

const severityColors = {
critical: "bg-red-300",
Expand Down Expand Up @@ -237,6 +239,20 @@ const AlertBar: React.FC<AlertBarProps> = ({
);
};

const IncidentTimelineNoAlerts: React.FC = () => {
const router = useRouter();
return (
<div className="h-80">
<EmptyStateCard
title="Timeline not available"
description="No alerts found for this incident. Go to the alerts feed and assign alerts to view the timeline."
buttonText="Assign alerts to this incident"
onClick={() => router.push("/alerts/feed")}
/>
</div>
);
};

export default function IncidentTimeline({
incident,
}: {
Expand Down Expand Up @@ -313,7 +329,8 @@ export default function IncidentTimeline({
return {};
}, [auditEvents, alerts]);

if (auditEventsLoading || !auditEvents || alertsLoading) return <>No Data</>;
if (auditEventsLoading || !auditEvents || alertsLoading)
return <IncidentTimelineNoAlerts />;

const {
startTime,
Expand Down
12 changes: 11 additions & 1 deletion keep-ui/app/incidents/[id]/incident.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useRouter } from "next/navigation";
import IncidentTimeline from "./incident-timeline";
import { CiBellOn, CiViewTimeline } from "react-icons/ci";
import { IoIosGitNetwork } from "react-icons/io";
import { EmptyStateCard } from "@/components/ui/EmptyStateCard";

interface Props {
incidentId: string;
Expand Down Expand Up @@ -72,7 +73,16 @@ export default function IncidentView({ incidentId }: Props) {
<TabPanel>
<IncidentTimeline incident={incident} />
</TabPanel>
<TabPanel>Coming Soon...</TabPanel>
<TabPanel>
<div className="h-80">
<EmptyStateCard
title="Coming Soon..."
description="Topology view of the incident is coming soon."
buttonText="Go to Topology"
onClick={() => router.push("/topology")}
/>
</div>
</TabPanel>
</TabPanels>
</TabGroup>
</div>
Expand Down
2 changes: 1 addition & 1 deletion keep-ui/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
8 changes: 4 additions & 4 deletions keep-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion keep-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
"postcss-nested": "^6.0.1",
"postcss-selector-parser": "^6.0.12",
"postcss-value-parser": "^4.2.0",
"posthog-js": "^1.161.6",
"posthog-js": "^1.163.0",
"posthog-node": "^3.1.1",
"preact-render-to-string": "^5.2.6",
"prelude-ls": "^1.2.1",
Expand Down

0 comments on commit 1fb5e54

Please sign in to comment.