2025-10-19 21:46:16 +08:00
|
|
|
import { BarChart3, Check, Edit, Play, Trash2 } from "lucide-react";
|
2025-10-16 10:49:56 +08:00
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
|
|
|
|
|
interface ProviderActionsProps {
|
|
|
|
|
isCurrent: boolean;
|
|
|
|
|
onSwitch: () => void;
|
|
|
|
|
onEdit: () => void;
|
|
|
|
|
onConfigureUsage: () => void;
|
|
|
|
|
onDelete: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function ProviderActions({
|
|
|
|
|
isCurrent,
|
|
|
|
|
onSwitch,
|
|
|
|
|
onEdit,
|
|
|
|
|
onConfigureUsage,
|
|
|
|
|
onDelete,
|
|
|
|
|
}: ProviderActionsProps) {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<Button
|
|
|
|
|
size="sm"
|
|
|
|
|
variant={isCurrent ? "secondary" : "default"}
|
|
|
|
|
onClick={onSwitch}
|
|
|
|
|
disabled={isCurrent}
|
|
|
|
|
className={cn(
|
2025-10-19 21:46:16 +08:00
|
|
|
"w-20",
|
2025-10-24 13:02:35 +08:00
|
|
|
isCurrent &&
|
|
|
|
|
"bg-gray-200 text-muted-foreground hover:bg-gray-200 hover:text-muted-foreground dark:bg-gray-700 dark:hover:bg-gray-700",
|
2025-10-16 10:49:56 +08:00
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{isCurrent ? (
|
|
|
|
|
<>
|
|
|
|
|
<Check className="h-4 w-4" />
|
2025-10-19 11:55:46 +08:00
|
|
|
{t("provider.inUse")}
|
2025-10-16 10:49:56 +08:00
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<Play className="h-4 w-4" />
|
2025-10-19 11:55:46 +08:00
|
|
|
{t("provider.enable")}
|
2025-10-16 10:49:56 +08:00
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Button>
|
|
|
|
|
|
2025-10-19 23:29:13 +08:00
|
|
|
<div className="flex items-center gap-1">
|
2025-10-19 21:46:16 +08:00
|
|
|
<Button
|
2025-10-19 23:29:13 +08:00
|
|
|
size="icon"
|
2025-10-19 21:46:16 +08:00
|
|
|
variant="ghost"
|
|
|
|
|
onClick={onEdit}
|
|
|
|
|
title={t("common.edit")}
|
|
|
|
|
>
|
|
|
|
|
<Edit className="h-4 w-4" />
|
|
|
|
|
</Button>
|
2025-10-16 10:49:56 +08:00
|
|
|
|
2025-10-19 21:46:16 +08:00
|
|
|
<Button
|
2025-10-19 23:29:13 +08:00
|
|
|
size="icon"
|
2025-10-19 21:46:16 +08:00
|
|
|
variant="ghost"
|
|
|
|
|
onClick={onConfigureUsage}
|
|
|
|
|
title={t("provider.configureUsage")}
|
|
|
|
|
>
|
|
|
|
|
<BarChart3 className="h-4 w-4" />
|
|
|
|
|
</Button>
|
2025-10-16 10:49:56 +08:00
|
|
|
|
2025-10-19 21:46:16 +08:00
|
|
|
<Button
|
2025-10-19 23:29:13 +08:00
|
|
|
size="icon"
|
2025-10-19 21:46:16 +08:00
|
|
|
variant="ghost"
|
2025-10-19 22:53:33 +08:00
|
|
|
onClick={isCurrent ? undefined : onDelete}
|
2025-10-19 21:46:16 +08:00
|
|
|
title={t("common.delete")}
|
|
|
|
|
className={cn(
|
2025-10-19 23:29:13 +08:00
|
|
|
!isCurrent && "hover:text-red-500 dark:hover:text-red-400",
|
2025-10-19 22:53:33 +08:00
|
|
|
isCurrent && "opacity-40 cursor-not-allowed text-muted-foreground",
|
2025-10-19 21:46:16 +08:00
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<Trash2 className="h-4 w-4" />
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
2025-10-16 10:49:56 +08:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|