import { Check, Copy, Github, MoreVertical, Settings } from 'lucide-react' import { useRouter } from 'next/router' import { useState } from 'react' import InlineSVG from 'react-inlinesvg' import { toast } from 'sonner' import { Button, copyToClipboard, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, TableCell, TableRow, } from 'ui' import { TimestampInfo } from 'ui-patterns' import { inferProjectStatus } from './ProjectCard.utils' import { ProjectCardStatus } from './ProjectCardStatus' import { ComputeBadgeWrapper } from '@/components/ui/ComputeBadgeWrapper' import PartnerIcon from '@/components/ui/PartnerIcon' import type { IntegrationProjectConnection } from '@/data/integrations/integrations.types' import { getManagedByFromOrganizationPartner } from '@/data/organizations/managed-by-utils' import { getComputeSize, OrgProject } from '@/data/projects/org-projects-infinite-query' import type { ResourceWarning } from '@/data/usage/resource-warnings-query' import { BASE_PATH } from '@/lib/constants' import { MANAGED_BY } from '@/lib/constants/infrastructure' import { createNavigationHandler } from '@/lib/navigation' import type { Organization } from '@/types' export interface ProjectTableRowProps { project: OrgProject organization?: Organization rewriteHref?: string githubIntegration?: IntegrationProjectConnection vercelIntegration?: IntegrationProjectConnection resourceWarnings?: ResourceWarning } export const ProjectTableRow = ({ project, organization, rewriteHref, githubIntegration, vercelIntegration, resourceWarnings, }: ProjectTableRowProps) => { const router = useRouter() const { name, ref: projectRef } = project const projectStatus = inferProjectStatus(project.status) const [isCopied, setIsCopied] = useState(false) const url = rewriteHref ?? `/project/${project.ref}` const isGithubIntegrated = githubIntegration !== undefined const isVercelIntegrated = vercelIntegration !== undefined const githubRepository = githubIntegration?.metadata.name ?? undefined const projectManagedBy = getManagedByFromOrganizationPartner( undefined, project.integration_source ) const hasPartnerIcon = projectManagedBy !== MANAGED_BY.BRIVEN const handleNavigation = createNavigationHandler(url, router) const handleCopyProjectRef = (e: React.SyntheticEvent) => { e.stopPropagation() copyToClipboard(projectRef) setIsCopied(true) toast.success('Copied project ID to clipboard') setTimeout(() => setIsCopied(false), 2000) } return ( <>
{name}
{(isGithubIntegrated || isVercelIntegrated || hasPartnerIcon) && (
{isVercelIntegrated && (
)} {isGithubIntegrated && (
{githubRepository && (

{githubRepository}

)}
)}
)}
{project.status !== 'INACTIVE' ? ( ) : ( )}
{project.cloud_provider} | {project.region || 'N/A'} {project.inserted_at ? ( ) : ( N/A )}
e.stopPropagation()}>
) }