import { useParams } from 'common' import { AlertCircle, ArrowUpRight, CheckCircle2 } from 'lucide-react' import Image from 'next/image' import Link from 'next/link' import { HoverCard, HoverCardContent, HoverCardTrigger } from 'ui' import { useBranchesQuery } from '@/data/branches/branches-query' import { useGitHubConnectionsQuery } from '@/data/integrations/github-connections-query' import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject' import { BASE_PATH } from '@/lib/constants' export const GitHubStatus = () => { const { ref: projectRef } = useParams() const { data: selectedProject } = useSelectedProjectQuery() const { data: selectedOrganization } = useSelectedOrganizationQuery() const parentProjectRef = selectedProject?.parent_project_ref || projectRef const { data: connections } = useGitHubConnectionsQuery( { organizationId: selectedOrganization?.id }, { enabled: !!selectedOrganization?.id } ) const { data: branches } = useBranchesQuery( { projectRef: parentProjectRef }, { enabled: !!parentProjectRef } ) const githubConnection = connections?.find( (connection) => connection.project.ref === parentProjectRef ) const mainBranch = branches?.find((branch) => branch.is_default) const isConnected = Boolean(githubConnection) const hasGitBranchSync = Boolean(mainBranch?.git_branch?.trim()) const hasAutomaticBranching = Boolean(githubConnection?.new_branch_per_pr) return (

GitHub Integration

{isConnected ? ( <> GitHub {githubConnection?.repository.name} ) : ( 'Not connected' )}

GitHub {isConnected ? githubConnection?.repository.name : 'Not connected'}
{isConnected ? (
{hasGitBranchSync ? ( ) : ( )} {hasGitBranchSync ? `Syncing production (${mainBranch?.git_branch})` : 'Production sync disabled'}
{hasAutomaticBranching ? ( ) : ( )} {hasAutomaticBranching ? 'Automatically creating branches' : 'Automatic branching disabled'}
) : (

Not connected to any repository

)}
) }