import React from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Checkbox } from "../ui/checkbox"; import type { MirrorOptions } from "@/types/config"; import { RefreshCw, Info } from "lucide-react"; import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"; interface MirrorOptionsFormProps { config: MirrorOptions; setConfig: React.Dispatch>; onAutoSave?: (config: MirrorOptions) => Promise; isAutoSaving?: boolean; } export function MirrorOptionsForm({ config, setConfig, onAutoSave, isAutoSaving = false, }: MirrorOptionsFormProps) { const handleChange = (name: string, checked: boolean) => { let newConfig = { ...config }; if (name === "mirrorMetadata") { newConfig.mirrorMetadata = checked; // If disabling metadata, also disable all components if (!checked) { newConfig.metadataComponents = { issues: false, pullRequests: false, labels: false, milestones: false, wiki: false, }; } } else if (name.startsWith("metadataComponents.")) { const componentName = name.split(".")[1] as keyof typeof config.metadataComponents; newConfig.metadataComponents = { ...config.metadataComponents, [componentName]: checked, }; } else { newConfig = { ...config, [name]: checked, }; } setConfig(newConfig); // Auto-save if (onAutoSave) { onAutoSave(newConfig); } }; return ( Mirror Options {isAutoSaving && (
Auto-saving...
)}
{/* Repository Content */}

Repository Content

handleChange("mirrorReleases", Boolean(checked)) } />
handleChange("mirrorMetadata", Boolean(checked)) } />
{/* Metadata Components */} {config.mirrorMetadata && (
Metadata Components
handleChange("metadataComponents.issues", Boolean(checked)) } disabled={!config.mirrorMetadata} />
handleChange("metadataComponents.pullRequests", Boolean(checked)) } disabled={!config.mirrorMetadata} />
handleChange("metadataComponents.labels", Boolean(checked)) } disabled={!config.mirrorMetadata} />
handleChange("metadataComponents.milestones", Boolean(checked)) } disabled={!config.mirrorMetadata} />
handleChange("metadataComponents.wiki", Boolean(checked)) } disabled={!config.mirrorMetadata} />
)}
); }