2025-10-17 21:32:28 +08:00
|
|
|
import React from "react";
|
|
|
|
|
import { Save } from "lucide-react";
|
2025-10-17 18:38:49 +08:00
|
|
|
import { useTranslation } from "react-i18next";
|
2025-10-17 21:32:28 +08:00
|
|
|
import {
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogContent,
|
|
|
|
|
DialogHeader,
|
|
|
|
|
DialogTitle,
|
|
|
|
|
DialogFooter,
|
|
|
|
|
} from "@/components/ui/dialog";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
2025-10-17 18:38:49 +08:00
|
|
|
|
|
|
|
|
interface CodexCommonConfigModalProps {
|
|
|
|
|
isOpen: boolean;
|
|
|
|
|
onClose: () => void;
|
|
|
|
|
value: string;
|
|
|
|
|
onChange: (value: string) => void;
|
|
|
|
|
error?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* CodexCommonConfigModal - Common Codex configuration editor modal
|
|
|
|
|
* Allows editing of common TOML configuration shared across providers
|
|
|
|
|
*/
|
|
|
|
|
export const CodexCommonConfigModal: React.FC<CodexCommonConfigModalProps> = ({
|
|
|
|
|
isOpen,
|
|
|
|
|
onClose,
|
|
|
|
|
value,
|
|
|
|
|
onChange,
|
|
|
|
|
error,
|
|
|
|
|
}) => {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
|
|
return (
|
2025-10-17 21:32:28 +08:00
|
|
|
<Dialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
|
2025-10-18 16:52:02 +08:00
|
|
|
<DialogContent
|
|
|
|
|
zIndex="nested"
|
|
|
|
|
className="max-w-2xl max-h-[90vh] flex flex-col p-0"
|
|
|
|
|
>
|
2025-10-17 21:32:28 +08:00
|
|
|
<DialogHeader className="px-6 pt-6 pb-0">
|
|
|
|
|
<DialogTitle>{t("codexConfig.editCommonConfigTitle")}</DialogTitle>
|
|
|
|
|
</DialogHeader>
|
2025-10-17 18:38:49 +08:00
|
|
|
|
2025-10-17 21:32:28 +08:00
|
|
|
<div className="flex-1 overflow-auto px-6 py-4 space-y-4">
|
2025-10-17 18:38:49 +08:00
|
|
|
<p className="text-sm text-gray-500 dark:text-gray-400">
|
|
|
|
|
{t("codexConfig.commonConfigHint")}
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<textarea
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={(e) => onChange(e.target.value)}
|
|
|
|
|
placeholder={`# Common Codex config
|
|
|
|
|
|
|
|
|
|
# Add your common TOML configuration here`}
|
|
|
|
|
rows={12}
|
|
|
|
|
className="w-full px-3 py-2 border border-gray-200 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 rounded-lg text-sm font-mono focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:focus:ring-blue-400/20 focus:border-blue-500 dark:focus:border-blue-400 transition-colors resize-y"
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
autoCorrect="off"
|
|
|
|
|
autoCapitalize="none"
|
|
|
|
|
spellCheck={false}
|
|
|
|
|
lang="en"
|
|
|
|
|
inputMode="text"
|
|
|
|
|
data-gramm="false"
|
|
|
|
|
data-gramm_editor="false"
|
|
|
|
|
data-enable-grammarly="false"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{error && (
|
|
|
|
|
<p className="text-sm text-red-500 dark:text-red-400">{error}</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-10-17 21:32:28 +08:00
|
|
|
<DialogFooter className="px-6 pb-6 pt-4 border-t border-gray-200 dark:border-gray-800 bg-gray-100 dark:bg-gray-800 m-0">
|
|
|
|
|
<Button type="button" variant="outline" onClick={onClose}>
|
2025-10-17 18:38:49 +08:00
|
|
|
{t("common.cancel")}
|
2025-10-17 21:32:28 +08:00
|
|
|
</Button>
|
|
|
|
|
<Button type="button" onClick={onClose} className="gap-2">
|
2025-10-17 18:38:49 +08:00
|
|
|
<Save className="w-4 h-4" />
|
|
|
|
|
{t("common.save")}
|
2025-10-17 21:32:28 +08:00
|
|
|
</Button>
|
|
|
|
|
</DialogFooter>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
2025-10-17 18:38:49 +08:00
|
|
|
);
|
|
|
|
|
};
|