Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(studio): inline actions for projects list (#42141)

kemal.earth180925bc92b0
diff --git a/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx b/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
index ed36761b42f..6530d5a579c 100644
--- a/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
+++ b/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
@@ -1,8 +1,10 @@
-import { Github } from 'lucide-react'
+import { Github, MoreVertical, Trash, Copy } from 'lucide-react'
import InlineSVG from 'react-inlinesvg'
+import { useState } from 'react'
import CardButton from 'components/ui/CardButton'
import { ComputeBadgeWrapper } from 'components/ui/ComputeBadgeWrapper'
+import { DeleteProjectModal } from 'components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal'
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'
@@ -12,10 +14,21 @@ import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { BASE_PATH } from 'lib/constants'
import { inferProjectStatus } from './ProjectCard.utils'
import { ProjectCardStatus } from './ProjectCardStatus'
+import type { Organization } from 'types'
+import { toast } from 'sonner'
+import {
+ copyToClipboard,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ Button,
+} from 'ui'
export interface ProjectCardProps {
slug?: string
project: OrgProject
+ organization?: Organization
rewriteHref?: string
githubIntegration?: IntegrationProjectConnection
vercelIntegration?: IntegrationProjectConnection
@@ -25,12 +38,14 @@ export interface ProjectCardProps {
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 =
@@ -48,52 +63,105 @@ export const ProjectCard = ({
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"
- title={
- <div className="w-full flex flex-col gap-y-4 justify-between px-5">
- {/* Text */}
- <div className="flex flex-col gap-y-0.5">
- <h5 className="text-sm flex-shrink truncate pr-5">{name}</h5>
- <p className="text-sm text-foreground-lighter">{desc}</p>
- </div>
- {/* Compute and integrations */}
- <div className="flex items-center gap-x-1.5">
- {project.status !== 'INACTIVE' && projectHomepageShowInstanceSize && (
- <ComputeBadgeWrapper
- slug={slug}
- projectRef={project.ref}
- cloudProvider={project.cloud_provider}
- computeSize={getComputeSize(project)}
+ <>
+ <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 z-10">
+ <div className="flex flex-col gap-y-0.5 relative z-10">
+ <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 z-10">
+ <ProjectCardStatus
+ projectStatus={projectStatus}
+ resourceWarnings={resourceWarnings}
+ renderMode="badge"
/>
- )}
- {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"
+ {project.status !== 'INACTIVE' && projectHomepageShowInstanceSize && (
+ <ComputeBadgeWrapper
+ slug={slug}
+ projectRef={project.ref}
+ cloudProvider={project.cloud_provider}
+ computeSize={getComputeSize(project)}
/>
- </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} />
+ )}
+ {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>
- <p className="text-xs text-foreground-light truncate">{githubRepository}</p>
- </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>
- </div>
- }
- footer={
- <ProjectCardStatus projectStatus={projectStatus} resourceWarnings={resourceWarnings} />
- }
- containerElement={<ProjectIndexPageLink projectRef={projectRef} />}
+ }
+ footer={
+ <ProjectCardStatus projectStatus={projectStatus} resourceWarnings={resourceWarnings} />
+ }
+ containerElement={<ProjectIndexPageLink projectRef={projectRef} />}
+ />
+ </li>
+ <DeleteProjectModal
+ visible={isDeleteModalOpen}
+ onClose={() => setIsDeleteModalOpen(false)}
+ project={project}
+ organization={organization}
/>
- </li>
+ </>
)
}
diff --git a/apps/studio/components/interfaces/Home/ProjectList/ProjectList.tsx b/apps/studio/components/interfaces/Home/ProjectList/ProjectList.tsx
index 6e25f8fa504..f3c0c18b0d1 100644
--- a/apps/studio/components/interfaces/Home/ProjectList/ProjectList.tsx
+++ b/apps/studio/components/interfaces/Home/ProjectList/ProjectList.tsx
@@ -148,6 +148,7 @@ export const ProjectList = ({ organization: organization_, rewriteHref }: Projec
<TableHead className={cn(noResults && 'text-foreground-muted')}>Compute</TableHead>
<TableHead className={cn(noResults && 'text-foreground-muted')}>Region</TableHead>
<TableHead className={cn(noResults && 'text-foreground-muted')}>Created</TableHead>
+ <TableHead className={cn(noResults && 'text-foreground-muted')} />
</TableRow>
</TableHeader>
<TableBody>
diff --git a/apps/studio/components/interfaces/Home/ProjectList/ProjectTableRow.tsx b/apps/studio/components/interfaces/Home/ProjectList/ProjectTableRow.tsx
index 2c158b0d638..a6e3e94951a 100644
--- a/apps/studio/components/interfaces/Home/ProjectList/ProjectTableRow.tsx
+++ b/apps/studio/components/interfaces/Home/ProjectList/ProjectTableRow.tsx
@@ -1,6 +1,7 @@
-import { Github } from 'lucide-react'
+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'
@@ -9,10 +10,21 @@ 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 { TableCell, TableRow } from 'ui'
+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
@@ -34,93 +46,154 @@ export const ProjectTableRow = ({
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 infraInformation = project.databases.find((x) => x.identifier === project.ref)
-
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 (
- <TableRow
- className="cursor-pointer hover:bg-surface-200 inset-focus"
- onClick={handleNavigation}
- onAuxClick={handleNavigation}
- onKeyDown={handleNavigation}
- tabIndex={0}
- >
- <TableCell>
- <div className="flex flex-col gap-y-2">
- {/* Text */}
- <div>
- <h5 className="text-sm">{name}</h5>
- <p className="text-sm text-foreground-lighter">ID: {projectRef}</p>
- </div>
- {/* Integrations */}
- {(isGithubIntegrated || isVercelIntegrated) && (
- <div className="flex items-center gap-x-1.5">
- {isVercelIntegrated && (
- <div className="bg-surface-100 w-5 h-5 p-1 border border-strong rounded-md flex items-center text-black dark:text-white">
- <InlineSVG
- src={`${BASE_PATH}/img/icons/vercel-icon.svg`}
- title="Vercel Icon"
- className="w-3"
+ <>
+ <TableRow
+ className="cursor-pointer hover:bg-surface-200 inset-focus"
+ onClick={handleNavigation}
+ onAuxClick={handleNavigation}
+ onKeyDown={handleNavigation}
+ tabIndex={0}
+ >
+ <TableCell>
+ <div className="flex flex-col gap-y-2">
+ <div>
+ <h5 className="text-sm">{name}</h5>
+ <button
+ tabIndex={0}
+ onClick={handleCopyProjectRef}
+ onKeyDown={(e) => {
+ 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 ? (
+ <Check size={12} strokeWidth={1.25} className="text-brand" />
+ ) : (
+ <Copy
+ size={12}
+ strokeWidth={1.25}
+ className="opacity-0 group-hover:opacity-100 transition-opacity"
/>
- </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">
- <Github size={12} strokeWidth={1.5} />
- </div>
- {githubRepository && (
- <p className="text-xs text-foreground-light truncate">{githubRepository}</p>
- )}
- </div>
- )}
+ )}
+ </button>
</div>
- )}
- </div>
- </TableCell>
- <TableCell>
- <ProjectCardStatus
- projectStatus={projectStatus}
- resourceWarnings={resourceWarnings}
- renderMode="badge"
- />
- </TableCell>
- <TableCell>
- <div className="w-fit">
- {project.status !== 'INACTIVE' ? (
- <ComputeBadgeWrapper
- slug={organization?.slug}
- projectRef={project.ref}
- cloudProvider={project.cloud_provider}
- computeSize={getComputeSize(project)}
+ {(isGithubIntegrated || isVercelIntegrated) && (
+ <div className="flex items-center gap-x-1.5">
+ {isVercelIntegrated && (
+ <div className="bg-surface-100 w-5 h-5 p-1 border border-strong rounded-md flex items-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">
+ <Github size={12} strokeWidth={1.5} />
+ </div>
+ {githubRepository && (
+ <p className="text-xs text-foreground-light truncate">{githubRepository}</p>
+ )}
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ </TableCell>
+ <TableCell>
+ <ProjectCardStatus
+ projectStatus={projectStatus}
+ resourceWarnings={resourceWarnings}
+ renderMode="badge"
+ />
+ </TableCell>
+ <TableCell>
+ <div className="w-fit">
+ {project.status !== 'INACTIVE' ? (
+ <ComputeBadgeWrapper
+ slug={organization?.slug}
+ projectRef={project.ref}
+ cloudProvider={project.cloud_provider}
+ computeSize={getComputeSize(project)}
+ />
+ ) : (
+ <span className="text-xs text-foreground-muted">–</span>
+ )}
+ </div>
+ </TableCell>
+ <TableCell>
+ <span className="lowercase text-sm text-foreground-light">
+ {project.cloud_provider} | {project.region || 'N/A'}
+ </span>
+ </TableCell>
+ <TableCell>
+ {project.inserted_at ? (
+ <TimestampInfo
+ className="text-sm text-foreground-light"
+ utcTimestamp={project.inserted_at}
/>
) : (
- <span className="text-xs text-foreground-muted">–</span>
+ <span className="text-sm text-foreground-light">N/A</span>
)}
- </div>
- </TableCell>
- <TableCell>
- <span className="lowercase text-sm text-foreground-light">
- {project.cloud_provider} | {project.region || 'N/A'}
- </span>
- </TableCell>
- <TableCell>
- {project.inserted_at ? (
- <TimestampInfo
- className="text-sm text-foreground-light"
- utcTimestamp={project.inserted_at}
- />
- ) : (
- <span className="text-sm text-foreground-light">N/A</span>
- )}
- </TableCell>
- </TableRow>
+ </TableCell>
+ <TableCell className="text-right">
+ <div onClick={(e) => e.stopPropagation()}>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="default"
+ icon={<MoreVertical />}
+ aria-label="More actions"
+ className="w-7"
+ onClick={(e) => e.stopPropagation()}
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-48">
+ <DropdownMenuItem
+ className="gap-x-2"
+ onClick={(e) => {
+ e.stopPropagation()
+ setIsDeleteModalOpen(true)
+ }}
+ >
+ <Trash size={14} />
+ <span>Delete project</span>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </TableCell>
+ </TableRow>
+ <DeleteProjectModal
+ visible={isDeleteModalOpen}
+ onClose={() => setIsDeleteModalOpen(false)}
+ project={project}
+ organization={organization}
+ />
+ </>
)
}
diff --git a/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal.tsx b/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal.tsx
index 67fd5a83bea..32b76175d8a 100644
--- a/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal.tsx
+++ b/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal.tsx
@@ -7,22 +7,32 @@ import { CANCELLATION_REASONS } from 'components/interfaces/Billing/Billing.cons
import { TextConfirmModal } from 'components/ui/TextConfirmModalWrapper'
import { useSendDowngradeFeedbackMutation } from 'data/feedback/exit-survey-send'
import { useProjectDeleteMutation } from 'data/projects/project-delete-mutation'
+import type { OrgProject } from 'data/projects/org-projects-infinite-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+import type { Organization } from 'types'
import { Input } from 'ui'
export const DeleteProjectModal = ({
visible,
onClose,
+ project: projectProp,
+ organization: organizationProp,
}: {
visible: boolean
onClose: () => void
+ project?: OrgProject
+ organization?: Organization
}) => {
const router = useRouter()
- const { data: project } = useSelectedProjectQuery()
- const { data: organization } = useSelectedOrganizationQuery()
+ const { data: projectFromQuery } = useSelectedProjectQuery()
+ const { data: organizationFromQuery } = useSelectedOrganizationQuery()
+
+ // Use props if provided, otherwise fall back to hooks
+ const project = projectProp || projectFromQuery
+ const organization = organizationProp || organizationFromQuery
const [lastVisitedOrganization] = useLocalStorageQuery(
LOCAL_STORAGE_KEYS.LAST_VISITED_ORGANIZATION,