import React from 'react'; import { UseFormReturn } from 'react-hook-form'; import { FormField, FormItem, FormLabel, FormControl, FormDescription, FormMessage } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Skeleton } from "@/components/ui/skeleton"; import { Edit, KeyRound, Loader2, CircleAlert } from 'lucide-react'; // 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)} />
))}
) )}
)}
); }