import CardButton from 'components/ui/CardButton' import { ComputeBadgeWrapper } from 'components/ui/ComputeBadgeWrapper' import type { IntegrationProjectConnection } from 'data/integrations/integrations.types' import { ProjectIndexPageLink } from 'data/prefetchers/project.$ref' import { getComputeSize, OrgProject } from 'data/projects/org-projects-infinite-query' import type { ResourceWarning } from 'data/usage/resource-warnings-query' import { useCustomContent } from 'hooks/custom-content/useCustomContent' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { BASE_PATH } from 'lib/constants' import { Copy, Github, MoreVertical, Settings } from 'lucide-react' import { useRouter } from 'next/router' import InlineSVG from 'react-inlinesvg' import { toast } from 'sonner' import type { Organization } from 'types' import { Button, copyToClipboard, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from 'ui' import { inferProjectStatus } from './ProjectCard.utils' import { ProjectCardStatus } from './ProjectCardStatus' export interface ProjectCardProps { slug?: string project: OrgProject organization?: Organization rewriteHref?: string githubIntegration?: IntegrationProjectConnection vercelIntegration?: IntegrationProjectConnection resourceWarnings?: ResourceWarning } export const ProjectCard = ({ slug, project, rewriteHref, githubIntegration, vercelIntegration, resourceWarnings, }: ProjectCardProps) => { const router = useRouter() const { name, ref: projectRef } = project const { infraAwsNimbusLabel } = useCustomContent(['infra:aws_nimbus_label']) const providerLabel = project.cloud_provider === 'AWS_NIMBUS' ? infraAwsNimbusLabel : project.cloud_provider const desc = `${providerLabel} | ${project.region}` const { projectHomepageShowInstanceSize } = useIsFeatureEnabled([ 'project_homepage:show_instance_size', ]) const isGithubIntegrated = githubIntegration !== undefined const isVercelIntegrated = vercelIntegration !== undefined const githubRepository = githubIntegration?.metadata.name ?? undefined const projectStatus = inferProjectStatus(project.status) return ( <>
{desc}
{githubRepository}