import { Github, MoreVertical, Trash, Copy, Check } from 'lucide-react' import { useRouter } from 'next/router' import InlineSVG from 'react-inlinesvg' import { useState } from 'react' import { ComputeBadgeWrapper } from 'components/ui/ComputeBadgeWrapper' import type { IntegrationProjectConnection } from 'data/integrations/integrations.types' 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 { createNavigationHandler } from 'lib/navigation' import type { Organization } from 'types' import { DropdownMenuTrigger, DropdownMenuItem, DropdownMenuContent, DropdownMenu, TableCell, TableRow, Button, } from 'ui' import { TimestampInfo } from 'ui-patterns' import { inferProjectStatus } from './ProjectCard.utils' import { ProjectCardStatus } from './ProjectCardStatus' import { DeleteProjectModal } from 'components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal' import { toast } from 'sonner' import { copyToClipboard } from 'ui' 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 [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false) 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 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} { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault() handleCopyProjectRef(e) } }} className="inline-flex items-center gap-x-1 cursor-pointer border border-transparent border-dashed rounded transition-colors hover:bg-surface-100 hover:border hover:border-strong group font-mono text-xs text-foreground-lighter hover:text-foreground-light px-1 -ml-1" > {projectRef} {isCopied ? ( ) : ( )} {(isGithubIntegrated || isVercelIntegrated) && ( {isVercelIntegrated && ( )} {isGithubIntegrated && ( {githubRepository && ( {githubRepository} )} )} )} {project.status !== 'INACTIVE' ? ( ) : ( – )} {project.cloud_provider} | {project.region || 'N/A'} {project.inserted_at ? ( ) : ( N/A )} e.stopPropagation()}> } aria-label="More actions" className="w-7" onClick={(e) => e.stopPropagation()} /> { e.stopPropagation() setIsDeleteModalOpen(true) }} > Delete project setIsDeleteModalOpen(false)} project={project} organization={organization} /> > ) }
{githubRepository}