Files
cc-switch/src/components/providers/ProviderActions.tsx

83 lines
2.1 KiB
TypeScript
Raw Normal View History

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(
"w-20",
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" />
{t("provider.inUse")}
2025-10-16 10:49:56 +08:00
</>
) : (
<>
<Play className="h-4 w-4" />
{t("provider.enable")}
2025-10-16 10:49:56 +08:00
</>
)}
</Button>
<div className="flex items-center gap-1">
<Button
size="icon"
variant="ghost"
onClick={onEdit}
title={t("common.edit")}
>
<Edit className="h-4 w-4" />
</Button>
2025-10-16 10:49:56 +08:00
<Button
size="icon"
variant="ghost"
onClick={onConfigureUsage}
title={t("provider.configureUsage")}
>
<BarChart3 className="h-4 w-4" />
</Button>
2025-10-16 10:49:56 +08:00
<Button
size="icon"
variant="ghost"
onClick={isCurrent ? undefined : onDelete}
title={t("common.delete")}
className={cn(
!isCurrent && "hover:text-red-500 dark:hover:text-red-400",
isCurrent && "opacity-40 cursor-not-allowed text-muted-foreground",
)}
>
<Trash2 className="h-4 w-4" />
</Button>
</div>
2025-10-16 10:49:56 +08:00
</div>
);
}