Files
supabase/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
T
Francesco Sansalvadore 4b7367b004 fix(studio): org project card z-index (#42424)
## What kind of change does this PR introduce?

Fix project card z index issue.

## What is the current behavior?

<img width="718" height="573" alt="Screenshot 2026-02-03 at 18 32 40"
src="https://github.com/user-attachments/assets/565e397d-6cfb-4d66-8b79-7cf21019fc4f"
/>

## What is the new behavior?

<img width="344" height="405" alt="Screenshot 2026-02-03 at 18 32 22"
src="https://github.com/user-attachments/assets/6969e581-dc44-42c0-b144-216be66b33f1"
/>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Updated project card component structure and styling for improved
layout consistency.
  * Enhanced project status display presentation on project cards.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-04 10:32:25 +00:00

168 lines
6.7 KiB
TypeScript

import { DeleteProjectModal } from 'components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal'
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 { OrgProject, getComputeSize } 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, Trash } from 'lucide-react'
import { useState } from 'react'
import InlineSVG from 'react-inlinesvg'
import { toast } from 'sonner'
import type { Organization } from 'types'
import {
Button,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
copyToClipboard,
} 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,
organization,
rewriteHref,
githubIntegration,
vercelIntegration,
resourceWarnings,
}: ProjectCardProps) => {
const { name, ref: projectRef } = project
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false)
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 (
<>
<li className="list-none h-min">
<CardButton
linkHref={rewriteHref ? rewriteHref : `/project/${projectRef}`}
className="h-44 !px-0 group pt-5 pb-0 overflow-hidden relative"
hideChevron
title={
<div className="w-full flex flex-col gap-y-4 justify-between px-5">
<div className="flex flex-col gap-y-0.5 relative">
<div className="flex items-center justify-between">
<h5 className="text-sm flex-shrink truncate pr-5">{name}</h5>
<div onClick={(e) => e.preventDefault()}>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
type="text"
icon={<MoreVertical size={14} />}
className="w-6 h-6 px-0"
onClick={(e) => {
e.stopPropagation()
e.preventDefault()
}}
onPointerDown={(e) => e.stopPropagation()}
/>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-48">
<DropdownMenuItem
className="gap-x-2"
onClick={(e) => {
e.stopPropagation()
copyToClipboard(projectRef)
toast.success('Copied project ID to clipboard')
}}
>
<Copy size={14} />
<span>Copy project ID</span>
</DropdownMenuItem>
<DropdownMenuItem
className="gap-x-2"
onClick={(e) => {
e.stopPropagation()
setIsDeleteModalOpen(true)
}}
>
<Trash size={14} />
<span>Delete project</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
<p className="text-sm text-foreground-lighter">{desc}</p>
</div>
<div className="flex items-center gap-x-1.5 relative">
<ProjectCardStatus
projectStatus={projectStatus}
resourceWarnings={resourceWarnings}
renderMode="badge"
/>
{project.status !== 'INACTIVE' && projectHomepageShowInstanceSize && (
<ComputeBadgeWrapper
slug={slug}
projectRef={project.ref}
cloudProvider={project.cloud_provider}
computeSize={getComputeSize(project)}
/>
)}
{isVercelIntegrated && (
<div className="bg-surface-100 w-5 h-5 p-1 border border-strong rounded-md flex items-center justify-center text-black dark:text-white">
<InlineSVG
src={`${BASE_PATH}/img/icons/vercel-icon.svg`}
title="Vercel Icon"
className="w-3"
/>
</div>
)}
{isGithubIntegrated && (
<div className="bg-surface-100 flex items-center gap-x-0.5 h-5 pr-1 border border-strong rounded-md">
<div className="w-5 h-5 p-1 flex items-center justify-center">
<Github size={12} strokeWidth={1.5} />
</div>
<p className="text-xs text-foreground-light truncate">{githubRepository}</p>
</div>
)}
</div>
</div>
}
footer={
<ProjectCardStatus projectStatus={projectStatus} resourceWarnings={resourceWarnings} />
}
containerElement={<ProjectIndexPageLink projectRef={projectRef} />}
/>
</li>
<DeleteProjectModal
visible={isDeleteModalOpen}
onClose={() => setIsDeleteModalOpen(false)}
project={project}
organization={organization}
/>
</>
)
}