-
-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add job type icon * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2679604
commit ff99d32
Showing
3 changed files
with
54 additions
and
2 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
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
46 changes: 46 additions & 0 deletions
46
apps/web/src/components/monitor/job-type-icon-with-tooltip.tsx
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,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> | ||
); | ||
} |