Skip to content

Open-source status page, incident response and uptime monitoring

chore: add job type icon (#1025)

Maximilian Kaskeff99d321f717
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/layout.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/layout.tsx
index 319f1d734..c829f0134 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/layout.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/layout.tsx
@@ -4,6 +4,7 @@ import { Badge } from "@openstatus/ui/src/components/badge";
import { Header } from "@/components/dashboard/header";
import AppPageWithSidebarLayout from "@/components/layout/app-page-with-sidebar-layout";
+import { JobTypeIconWithTooltip } from "@/components/monitor/job-type-icon-with-tooltip";
import { StatusDotWithTooltip } from "@/components/monitor/status-dot-with-tooltip";
import { TagBadgeWithTooltip } from "@/components/monitor/tag-badge-with-tooltip";
import { api } from "@/trpc/server";
@@ -63,6 +64,8 @@ export default async function Layout({
<span className="text-sm">
every <code>{monitor.periodicity}</code>
</span>
+ <span className="text-muted-foreground/50 text-xs">•</span>
+ <JobTypeIconWithTooltip jobType={monitor.jobType} />
{monitor.public ? (
<>
<span className="text-muted-foreground/50 text-xs">•</span>
diff --git a/apps/web/src/components/icons.tsx b/apps/web/src/components/icons.tsx
index 706e8c5fb..bae04adac 100644
--- a/apps/web/src/components/icons.tsx
+++ b/apps/web/src/components/icons.tsx
@@ -18,7 +18,7 @@ import {
FileClock,
Fingerprint,
Gauge,
- Globe2,
+ Globe,
Hammer,
Hourglass,
Image,
@@ -44,6 +44,7 @@ import {
Ratio,
Search,
SearchCheck,
+ Server,
Siren,
Sparkles,
SunMedium,
@@ -62,6 +63,7 @@ import {
import type { LucideIcon, LucideProps } from "lucide-react";
export type Icon = LucideIcon;
+export type IconProps = LucideProps;
export type ValidIcon = keyof typeof Icons;
export const Icons = {
@@ -86,7 +88,7 @@ export const Icons = {
tag: Tag,
trash: Trash,
twitter: TwitterIcon,
- globe: Globe2,
+ globe: Globe,
plug: Plug,
copy: Copy,
check: Check,
@@ -124,6 +126,7 @@ export const Icons = {
camera: Camera,
"book-open-check": BookOpenCheck,
info: Info,
+ server: Server,
discord: ({ ...props }: LucideProps) => (
<svg viewBox="0 0 640 512" {...props}>
<path
diff --git a/apps/web/src/components/monitor/job-type-icon-with-tooltip.tsx b/apps/web/src/components/monitor/job-type-icon-with-tooltip.tsx
new file mode 100644
index 000000000..dcb1a4303
--- /dev/null
+++ b/apps/web/src/components/monitor/job-type-icon-with-tooltip.tsx
@@ -0,0 +1,46 @@
+import { cn } from "@/lib/utils";
+import type { Monitor } from "@openstatus/db/src/schema";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from "@openstatus/ui/src/components/tooltip";
+import { type IconProps, Icons, type ValidIcon } from "../icons";
+
+// TODO: extend once we have more job types
+function getIcon(jobType: Monitor["jobType"]): ValidIcon {
+ switch (jobType) {
+ case "http":
+ return "globe";
+ case "tcp":
+ return "server";
+ default:
+ return "cog";
+ }
+}
+
+interface JobTypeIconWithTooltipProps extends IconProps {
+ jobType: Monitor["jobType"];
+}
+
+export function JobTypeIconWithTooltip({
+ jobType,
+ className,
+ ...props
+}: JobTypeIconWithTooltipProps) {
+ const icon = getIcon(jobType);
+ const Icon = Icons[icon];
+ return (
+ <TooltipProvider delayDuration={50}>
+ <Tooltip>
+ <TooltipTrigger>
+ <Icon className={cn("h-3 w-3", className)} {...props} />
+ </TooltipTrigger>
+ <TooltipContent>
+ <p className="uppercase">{jobType}</p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ );
+}