import { CircleAlert, Edit, KeyRound, Loader2 } from "lucide-react"; import type React from "react"; import type { UseFormReturn } from "react-hook-form"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Skeleton } from "@/components/ui/skeleton"; // Types needed from parent interface GithubRepo { id: number; name: string; full_name: string; private: boolean; url: string; description: string | null; last_updated: string | null; } type GithubPatFormValues = { github_pat: string }; type EditMode = "viewing" | "editing_repos"; interface EditGitHubConnectorConfigProps { // State from parent editMode: EditMode; originalPat: string; currentSelectedRepos: string[]; fetchedRepos: GithubRepo[] | null; newSelectedRepos: string[]; isFetchingRepos: boolean; // Forms from parent patForm: UseFormReturn; // Handlers from parent setEditMode: (mode: EditMode) => void; handleFetchRepositories: (values: GithubPatFormValues) => Promise; handleRepoSelectionChange: (repoFullName: string, checked: boolean) => void; setNewSelectedRepos: React.Dispatch>; setFetchedRepos: React.Dispatch>; } export function EditGitHubConnectorConfig({ editMode, originalPat, currentSelectedRepos, fetchedRepos, newSelectedRepos, isFetchingRepos, patForm, setEditMode, handleFetchRepositories, handleRepoSelectionChange, setNewSelectedRepos, setFetchedRepos, }: EditGitHubConnectorConfigProps) { return (

Repository Selection & Access

{/* Viewing Mode */} {editMode === "viewing" && (
Currently Indexed Repositories: {currentSelectedRepos.length > 0 ? (
    {currentSelectedRepos.map((repo) => (
  • {repo}
  • ))}
) : (

(No repositories currently selected)

)} To change repo selections or update the PAT, click above.
)} {/* Editing Mode */} {editMode === "editing_repos" && (
{/* PAT Input */}
( GitHub PAT Enter PAT to fetch/update repos or if you need to update the stored token. )} />
{/* Repo List */} {isFetchingRepos && } {!isFetchingRepos && fetchedRepos !== null && (fetchedRepos.length === 0 ? ( No Repositories Found Check PAT & permissions. ) : (
Select Repositories to Index ({newSelectedRepos.length} selected):
{fetchedRepos.map((repo) => (
handleRepoSelectionChange(repo.full_name, !!checked) } />
))}
))}
)}
); }