Skip to content

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

Add metadata in project cards

Joshen Lim645ef6e645ed
diff --git a/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx b/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
index ad3689be4f9..f6be017b7ee 100644
--- a/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
+++ b/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
@@ -1,20 +1,40 @@
-import { Badge, IconAlertTriangle, IconLoader, IconPauseCircle } from 'ui'
+import {
+ Badge,
+ IconAlertTriangle,
+ IconGitBranch,
+ IconGitHub,
+ IconLoader,
+ IconPauseCircle,
+ IconTriangle,
+} from 'ui'
import CardButton from 'components/ui/CardButton'
import { useProjectReadOnlyStatus } from 'hooks/misc/useProjectReadOnlyStatus'
import { PROJECT_STATUS } from 'lib/constants'
import { Project } from 'types'
+import { IntegrationProjectConnection } from 'data/integrations/integrations.types'
export interface ProjectCardProps {
project: Project
rewriteHref?: string
+ githubIntegration?: IntegrationProjectConnection
+ vercelIntegration?: IntegrationProjectConnection
}
-const ProjectCard = ({ project, rewriteHref }: ProjectCardProps) => {
+const ProjectCard = ({
+ project,
+ rewriteHref,
+ githubIntegration,
+ vercelIntegration,
+}: ProjectCardProps) => {
const { name, ref: projectRef } = project
const desc = `${project.cloud_provider} | ${project.region}`
const isReadonly = useProjectReadOnlyStatus(projectRef)
+ const isBranchingEnabled = project.preview_branch_refs.length > 0
+ const isGithubIntegrated = githubIntegration !== undefined
+ const isVercelIntegrated = vercelIntegration !== undefined
+ const githubRepository = githubIntegration?.metadata.name ?? undefined
// Project status should supersede is read only status
const isHealthy = project.status === PROJECT_STATUS.ACTIVE_HEALTHY
@@ -28,8 +48,29 @@ const ProjectCard = ({ project, rewriteHref }: ProjectCardProps) => {
<CardButton
linkHref={rewriteHref ? rewriteHref : `/project/${projectRef}`}
title={
- <div className="flex w-full flex-row justify-between gap-1">
- <span className="flex-shrink truncate">{name}</span>
+ <div className="w-full justify-between space-y-1">
+ <p className="flex-shrink truncate">{name}</p>
+ <div className="flex items-center space-x-1.5">
+ {isVercelIntegrated && (
+ // [Joshen TODO] Need proper vercel's logo in SVG
+ <div className="w-fit p-1 border rounded-md flex items-center border-scale-600">
+ <IconTriangle size={12} strokeWidth={1.5} className="fill-scale-1200" />
+ </div>
+ )}
+ {isBranchingEnabled && (
+ <div className="w-fit p-1 border rounded-md flex items-center border-scale-600">
+ <IconGitBranch size={12} strokeWidth={1.5} />
+ </div>
+ )}
+ {isGithubIntegrated && (
+ <>
+ <div className="w-fit p-1 border rounded-md flex items-center border-scale-600">
+ <IconGitHub size={12} strokeWidth={1.5} />
+ </div>
+ <p className="text-xs !ml-2 text-scale-1100">{githubRepository}</p>
+ </>
+ )}
+ </div>
</div>
}
footer={
diff --git a/studio/components/interfaces/Home/ProjectList/ProjectList.tsx b/studio/components/interfaces/Home/ProjectList/ProjectList.tsx
index 1868b9c2689..d24aa81b1d0 100644
--- a/studio/components/interfaces/Home/ProjectList/ProjectList.tsx
+++ b/studio/components/interfaces/Home/ProjectList/ProjectList.tsx
@@ -18,6 +18,7 @@ import { makeRandomString } from 'lib/helpers'
import { Organization, Project, ResponseError } from 'types'
import ProjectCard from './ProjectCard'
import ShimmeringCard from './ShimmeringCard'
+import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-org-only'
export interface ProjectListProps {
rewriteHref?: (projectRef: string) => string
diff --git a/studio/components/ui/CardButton.tsx b/studio/components/ui/CardButton.tsx
index ab4e0a954a4..cd8016d9788 100644
--- a/studio/components/ui/CardButton.tsx
+++ b/studio/components/ui/CardButton.tsx
@@ -1,8 +1,8 @@
-import React, { FC } from 'react'
-import { IconChevronRight, IconLoader } from 'ui'
import Link from 'next/link'
+import React from 'react'
+import { IconChevronRight, IconLoader } from 'ui'
-interface Props {
+interface CardButtonProps {
title: string | React.ReactNode
description?: string
children?: React.ReactNode
@@ -17,7 +17,7 @@ interface Props {
loading?: boolean
}
-const CardButton: FC<Props> = ({
+const CardButton = ({
title,
description,
children,
@@ -30,7 +30,7 @@ const CardButton: FC<Props> = ({
icon,
containerHeightClassName = 'h-32',
loading = false,
-}) => {
+}: CardButtonProps) => {
const LinkContainer = ({ children }: { children: React.ReactNode }) => (
<Link href={linkHref}>
<a>{children}</a>
@@ -84,14 +84,14 @@ const CardButton: FC<Props> = ({
)}
{icon && <ImageContainer>{icon}</ImageContainer>}
<div className="flex h-full w-full flex-col space-y-2">
- <h5 className="text-scale-1200">{title}</h5>
+ {typeof title === 'string' ? <h5 className="text-scale-1200">{title}</h5> : title}
{(children || description) && (
<div className="flex w-full flex-1 flex-col">
<p className="text-sm text-scale-1100">{description}</p>
<div className="w-full">{children && children}</div>
</div>
)}
- {footer && <div className="w-full">{footer}</div>}
+ {footer && <div className="w-full !mt-auto">{footer}</div>}
</div>
{isLink && (
<div
diff --git a/studio/pages/org/[slug]/index.tsx b/studio/pages/org/[slug]/index.tsx
index b1e1245555c..75b39afef21 100644
--- a/studio/pages/org/[slug]/index.tsx
+++ b/studio/pages/org/[slug]/index.tsx
@@ -9,6 +9,7 @@ import AlertError from 'components/ui/AlertError'
import { useProjectsQuery } from 'data/projects/projects-query'
import { useSelectedOrganization } from 'hooks'
import { NextPageWithLayout } from 'types'
+import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-org-only'
const ProjectsPage: NextPageWithLayout = () => {
const {
@@ -21,6 +22,10 @@ const ProjectsPage: NextPageWithLayout = () => {
const organization = useSelectedOrganization()
const projects = allProjects?.filter((project) => project.organization_id === organization?.id)
+ const { data: integrations } = useOrgIntegrationsQuery({ orgSlug: organization?.slug })
+ const githubIntegrations = integrations?.find(
+ (integration) => integration.integration.name === 'GitHub'
+ )
return (
<ScaffoldContainer>
@@ -65,7 +70,13 @@ const ProjectsPage: NextPageWithLayout = () => {
) : (
<ul className="mx-auto grid grid-cols-1 gap-4 sm:grid-cols-1 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3">
{projects?.map((project) => (
- <ProjectCard key={project.ref} project={project} />
+ <ProjectCard
+ key={project.ref}
+ project={project}
+ githubIntegration={githubIntegrations?.connections.find(
+ (connection) => connection.supabase_project_ref === project.ref
+ )}
+ />
))}
</ul>
)}