import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { GitFork } from "lucide-react"; import { SiGithub, SiGitea } from "react-icons/si"; import type { Repository } from "@/lib/db/schema"; import { getStatusColor } from "@/lib/utils"; import { buildGiteaWebUrl } from "@/lib/gitea-url"; import { useGiteaConfig } from "@/hooks/useGiteaConfig"; import { withBase } from "@/lib/base-path"; interface RepositoryListProps { repositories: Repository[]; } export function RepositoryList({ repositories }: RepositoryListProps) { const { giteaConfig } = useGiteaConfig(); // Helper function to construct Gitea repository URL const getGiteaRepoUrl = (repository: Repository): string | null => { // Only provide Gitea links for repositories that have been or are being mirrored const validStatuses = ['mirroring', 'mirrored', 'syncing', 'synced']; if (!validStatuses.includes(repository.status)) { return null; } // Use mirroredLocation if available, otherwise construct from repository data let repoPath: string; if (repository.mirroredLocation) { repoPath = repository.mirroredLocation; } else { // Fallback: construct the path based on repository data // If repository has organization and preserveOrgStructure would be true, use org // Otherwise use the repository owner const owner = repository.organization || repository.owner; repoPath = `${owner}/${repository.name}`; } return buildGiteaWebUrl(giteaConfig, repoPath); }; return ( Repositories {repositories.length === 0 ? (

No repositories found

Configure your GitHub connection to start mirroring repositories.

) : (
{repositories.map((repo, index) => (

{repo.name}

{repo.isPrivate && ( Private )} {repo.isForked && ( Fork )}
{repo.owner} {repo.organization && ( <> / {repo.organization} )}
{repo.status}
{(() => { const giteaUrl = getGiteaRepoUrl(repo); const giteaEnabled = giteaUrl && ['mirrored', 'synced'].includes(repo.status); return giteaEnabled ? ( ) : ( ); })()}
))}
)} ); }