Files
supabase/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
Austin Tran 2f4cb194ed fix: Cannot access list projects on self-host (#21748)
* fix: cannot access list projects on self-host

* chore: direct to default project
2024-03-14 14:48:43 +01:00

79 lines
2.9 KiB
TypeScript

import { GitBranch, Github } from 'lucide-react'
import CardButton from 'components/ui/CardButton'
import type { IntegrationProjectConnection } from 'data/integrations/integrations.types'
import type { ProjectInfo } from 'data/projects/projects-query'
import type { ResourceWarning } from 'data/usage/resource-warnings-query'
import { BASE_PATH } from 'lib/constants'
import { inferProjectStatus } from './ProjectCard.utils'
import { ProjectCardStatus } from './ProjectCardStatus'
export interface ProjectCardProps {
project: ProjectInfo
rewriteHref?: string
githubIntegration?: IntegrationProjectConnection
vercelIntegration?: IntegrationProjectConnection
resourceWarnings?: ResourceWarning
}
const ProjectCard = ({
project,
rewriteHref,
githubIntegration,
vercelIntegration,
resourceWarnings,
}: ProjectCardProps) => {
const { name, ref: projectRef } = project
const desc = `${project.cloud_provider} | ${project.region}`
const isBranchingEnabled = project.preview_branch_refs?.length > 0
const isGithubIntegrated = githubIntegration !== undefined
const isVercelIntegrated = vercelIntegration !== undefined
const githubRepository = githubIntegration?.metadata.name ?? undefined
const projectStatus = inferProjectStatus(project)
return (
<li className="list-none">
<CardButton
linkHref={rewriteHref ? rewriteHref : `/project/${projectRef}`}
className="h-44 !px-0 group pt-5 pb-0"
title={
<div className="w-full justify-between space-y-1.5 px-5">
<p className="flex-shrink truncate text-sm pr-4">{name}</p>
<span className="text-sm lowercase text-foreground-light">{desc}</span>
<div className="flex items-center space-x-1.5">
{isVercelIntegrated && (
<div className="w-fit p-1 border rounded-md flex items-center border-controler">
<img
src={`${BASE_PATH}/img/icons/vercel-icon.svg`}
alt="Vercel Icon"
className="w-3"
/>
</div>
)}
{isBranchingEnabled && (
<div className="w-fit p-1 border rounded-md flex items-center border-controler">
<GitBranch size={12} strokeWidth={1.5} />
</div>
)}
{isGithubIntegrated && (
<>
<div className="w-fit p-1 border rounded-md flex items-center border-controler">
<Github size={12} strokeWidth={1.5} />
</div>
<p className="text-xs !ml-2 text-foreground-light">{githubRepository}</p>
</>
)}
</div>
</div>
}
footer={
<ProjectCardStatus projectStatus={projectStatus} resourceWarnings={resourceWarnings} />
}
/>
</li>
)
}
export default ProjectCard