Files
CC-Switch/src/components/providers/ProviderActions.tsx
T
Jason eb6948a562 i18n: complete internationalization for provider and usage query panels
- Add 45+ new translation keys for usage query and usage script features
- Fix duplicate provider object in translation files that caused missing translations
- Remove all hardcoded Chinese text and defaultValue fallbacks from components
- Add proper translations for:
  * Usage footer (query status, plan usage display)
  * Usage script modal (script editor, validation, test controls)
  * Provider forms (basic fields, endpoints, model selectors)
  * Provider dialogs (add/edit hints and titles)

Modified 16 files:
- 2 translation files (zh.json, en.json)
- 14 component files (removed defaultValue, added t() calls)

All UI text now properly supports Chinese/English switching.
2025-10-19 11:55:46 +08:00

77 lines
1.8 KiB
TypeScript

import { BarChart3, Check, Play, Trash2 } from "lucide-react";
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-[96px]",
isCurrent && "text-muted-foreground hover:text-muted-foreground",
)}
>
{isCurrent ? (
<>
<Check className="h-4 w-4" />
{t("provider.inUse")}
</>
) : (
<>
<Play className="h-4 w-4" />
{t("provider.enable")}
</>
)}
</Button>
<Button size="sm" variant="outline" onClick={onEdit}>
{t("common.edit")}
</Button>
<Button
size="sm"
variant="outline"
onClick={onConfigureUsage}
title={t("provider.configureUsage")}
>
<BarChart3 className="h-4 w-4" />
</Button>
<Button
size="sm"
variant="ghost"
onClick={onDelete}
disabled={isCurrent}
className={cn(
"hover:text-red-500 hover:bg-red-100 dark:hover:text-red-400 dark:hover:bg-red-500/10",
isCurrent &&
"text-muted-foreground hover:text-muted-foreground hover:bg-transparent",
)}
>
<Trash2 className="h-4 w-4" />
</Button>
</div>
);
}