2024-12-19 00:16:54 -08:00
|
|
|
import { CircleHelp } from "lucide-react";
|
2024-11-04 23:55:08 +01:00
|
|
|
import React from "react";
|
|
|
|
|
|
2025-06-28 00:38:09 +02:00
|
|
|
import type { BadgeProps } from "@/components/ui/badge";
|
|
|
|
|
import type { Script } from "@/lib/types";
|
|
|
|
|
|
|
|
|
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
|
|
|
|
import { Badge } from "@/components/ui/badge";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
|
|
|
|
|
type TooltipProps = {
|
2025-04-12 17:45:07 +02:00
|
|
|
variant: BadgeProps["variant"];
|
2024-11-04 23:55:08 +01:00
|
|
|
label: string;
|
2025-04-12 17:45:07 +02:00
|
|
|
content?: string;
|
2025-06-28 00:38:09 +02:00
|
|
|
};
|
2024-11-04 23:55:08 +01:00
|
|
|
|
|
|
|
|
const TooltipBadge: React.FC<TooltipProps> = ({ variant, label, content }) => (
|
|
|
|
|
<TooltipProvider>
|
|
|
|
|
<Tooltip delayDuration={100}>
|
2025-04-12 17:45:07 +02:00
|
|
|
<TooltipTrigger className={cn("flex items-center", !content && "cursor-default")}>
|
2024-12-19 00:16:54 -08:00
|
|
|
<Badge variant={variant} className="flex items-center gap-1">
|
2025-06-28 00:38:09 +02:00
|
|
|
{label}
|
|
|
|
|
{" "}
|
|
|
|
|
{content && <CircleHelp className="size-3" />}
|
2024-12-19 00:16:54 -08:00
|
|
|
</Badge>
|
2024-11-04 23:55:08 +01:00
|
|
|
</TooltipTrigger>
|
2025-04-12 17:45:07 +02:00
|
|
|
{content && (
|
|
|
|
|
<TooltipContent side="bottom" className="text-sm max-w-64">
|
|
|
|
|
{content}
|
|
|
|
|
</TooltipContent>
|
|
|
|
|
)}
|
2024-11-04 23:55:08 +01:00
|
|
|
</Tooltip>
|
|
|
|
|
</TooltipProvider>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export default function Tooltips({ item }: { item: Script }) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
{item.privileged && (
|
2025-04-12 17:45:07 +02:00
|
|
|
<TooltipBadge variant="warning" label="Privileged" content="This script will be run in a privileged LXC" />
|
2024-11-04 23:55:08 +01:00
|
|
|
)}
|
2025-06-29 14:00:01 +02:00
|
|
|
{item.updateable && item.type !== "pve" && (
|
2024-11-04 23:55:08 +01:00
|
|
|
<TooltipBadge
|
|
|
|
|
variant="success"
|
|
|
|
|
label="Updateable"
|
2024-11-06 23:47:04 +01:00
|
|
|
content={`To Update ${item.name}, run the command below (or type update) in the LXC Console.`}
|
2024-11-04 23:55:08 +01:00
|
|
|
/>
|
|
|
|
|
)}
|
2025-06-25 20:39:02 +02:00
|
|
|
{!item.updateable && item.type !== "pve" && <TooltipBadge variant="failure" label="Not Updateable" />}
|
2024-11-04 23:55:08 +01:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|