Skip to content

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

Make project vercel integrations collapsible (#51585)

Joshen Lim0f238b52967e
diff --git a/apps/studio/components/interfaces/Integrations/VercelGithub/IntegrationConnection.tsx b/apps/studio/components/interfaces/Integrations/VercelGithub/IntegrationConnection.tsx
index 251ca03bfc2..4e0a683f705 100644
--- a/apps/studio/components/interfaces/Integrations/VercelGithub/IntegrationConnection.tsx
+++ b/apps/studio/components/interfaces/Integrations/VercelGithub/IntegrationConnection.tsx
@@ -1,6 +1,5 @@
-import { ChevronDown, Loader2, RefreshCw, Trash } from 'lucide-react'
+import { ChevronDown, Loader2, MoreVertical, RefreshCw, SettingsIcon, Trash } from 'lucide-react'
import Link from 'next/link'
-import { useRouter } from 'next/router'
import { forwardRef, useCallback, useState } from 'react'
import { toast } from 'sonner'
import {
@@ -25,12 +24,12 @@ import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganizati
interface IntegrationConnectionItemProps extends IntegrationConnectionProps {
disabled?: boolean
+ isProjectScoped?: boolean
onDeleteConnection: (connection: IntegrationProjectConnection) => void | Promise<void>
}
export const IntegrationConnectionItem = forwardRef<HTMLLIElement, IntegrationConnectionItemProps>(
- ({ disabled, onDeleteConnection, ...props }, _ref) => {
- const router = useRouter()
+ ({ disabled, isProjectScoped = false, onDeleteConnection, ...props }, _ref) => {
const { data: org } = useSelectedOrganizationQuery()
const { type, connection } = props
@@ -71,6 +70,13 @@ export const IntegrationConnectionItem = forwardRef<HTMLLIElement, IntegrationCo
const projectIntegrationUrl = `/project/[ref]/settings/integrations`
+ // Project-scoped Vercel rows have their own "Edit" toggle, so "Manage" collapses to an icon
+ const isManageCompact = isProjectScoped && type === 'Vercel'
+ const triggerLabel = isManageCompact ? null : 'Manage'
+ const triggerProps = isManageCompact
+ ? { icon: <MoreVertical />, className: 'px-1.5', 'aria-label': 'Manage connection' }
+ : { iconRight: <ChevronDown size={14} /> }
+
return (
<>
<IntegrationConnection
@@ -79,7 +85,7 @@ export const IntegrationConnectionItem = forwardRef<HTMLLIElement, IntegrationCo
disabled ? (
<ButtonTooltip
disabled
- iconRight={<ChevronDown size={14} />}
+ {...triggerProps}
tooltip={{
content: {
side: 'bottom',
@@ -87,7 +93,7 @@ export const IntegrationConnectionItem = forwardRef<HTMLLIElement, IntegrationCo
},
}}
>
- Manage
+ {triggerLabel}
</ButtonTooltip>
) : (
<DropdownMenu
@@ -96,19 +102,18 @@ export const IntegrationConnectionItem = forwardRef<HTMLLIElement, IntegrationCo
modal={false}
>
<DropdownMenuTrigger asChild>
- <Button iconRight={<ChevronDown size={14} />}>
- <span>Manage</span>
- </Button>
+ <Button {...triggerProps}>{triggerLabel}</Button>
</DropdownMenuTrigger>
- <DropdownMenuContent side="bottom" align="end">
- {router.pathname !== projectIntegrationUrl && (
- <DropdownMenuItem asChild>
+ <DropdownMenuContent side="bottom" align="end" className="w-56">
+ {!isProjectScoped && (
+ <DropdownMenuItem asChild className="gap-x-2">
<Link
- href={projectIntegrationUrl.replace(
- '[ref]',
- connection.supabase_project_ref
- )}
+ href={
+ projectIntegrationUrl.replace('[ref]', connection.supabase_project_ref) +
+ `#${type.toLowerCase()}`
+ }
>
+ <SettingsIcon size={14} />
Configure connection
</Link>
</DropdownMenuItem>
@@ -131,7 +136,7 @@ export const IntegrationConnectionItem = forwardRef<HTMLLIElement, IntegrationCo
</DropdownMenuItem>
)}
{((type === 'Vercel' && org?.managed_by !== 'vercel-marketplace') ||
- router.pathname !== projectIntegrationUrl) && <DropdownMenuSeparator />}
+ !isProjectScoped) && <DropdownMenuSeparator />}
<DropdownMenuItem className="space-x-2" onSelect={() => setIsOpen(true)}>
<Trash size={14} />
<p>Delete connection</p>
diff --git a/apps/studio/components/interfaces/Integrations/VercelGithub/IntegrationPanels.tsx b/apps/studio/components/interfaces/Integrations/VercelGithub/IntegrationPanels.tsx
index 1731a89d5d6..b8d505761be 100644
--- a/apps/studio/components/interfaces/Integrations/VercelGithub/IntegrationPanels.tsx
+++ b/apps/studio/components/interfaces/Integrations/VercelGithub/IntegrationPanels.tsx
@@ -140,13 +140,23 @@ export interface IntegrationConnectionProps extends HTMLAttributes<HTMLLIElement
connection: IntegrationProjectConnection
type: Integration['integration']['name']
actions?: ReactNode
+ leadingAction?: ReactNode
showNode?: boolean
orientation?: 'horizontal' | 'vertical'
}
export const IntegrationConnection = forwardRef<HTMLLIElement, IntegrationConnectionProps>(
(
- { connection, type, actions, showNode = true, orientation = 'horizontal', className, ...props },
+ {
+ connection,
+ type,
+ actions,
+ leadingAction,
+ showNode = true,
+ orientation = 'horizontal',
+ className,
+ ...props
+ },
ref
) => {
const { data: project } = useProjectDetailQuery({ ref: connection.supabase_project_ref })
@@ -222,7 +232,10 @@ export const IntegrationConnection = forwardRef<HTMLLIElement, IntegrationConnec
</div>
</div>
- <div className="shrink-0">{actions}</div>
+ <div className="shrink-0 flex items-center gap-x-2">
+ {leadingAction}
+ {actions}
+ </div>
</div>
</li>
)
diff --git a/apps/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx b/apps/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
index 01f43f3d848..11e677bc91a 100644
--- a/apps/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
+++ b/apps/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
@@ -8,10 +8,10 @@ export const IntegrationSettings = () => {
return (
<>
- <GitHubSection isProjectScoped={false} />
+ <GitHubSection />
{showVercelIntegration && (
<>
- <VercelSection isProjectScoped={false} />
+ <VercelSection />
<SidePanelVercelProjectLinker />
</>
)}
diff --git a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
index 39a8244c032..e1f03081552 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
@@ -58,7 +58,7 @@ const toIntegrationProjectConnection = (
} as IntegrationProjectConnection['metadata'],
})
-export const GitHubSection = ({ isProjectScoped }: { isProjectScoped: boolean }) => {
+export const GitHubSection = ({ isProjectScoped = false }: { isProjectScoped?: boolean }) => {
const router = useRouter()
const { ref: projectRef } = useParams()
const { data: org } = useSelectedOrganizationQuery()
@@ -121,7 +121,7 @@ export const GitHubSection = ({ isProjectScoped }: { isProjectScoped: boolean })
)
return (
- <PageSection>
+ <PageSection id="github">
<PageSectionMeta>
<div className="flex flex-1 items-start gap-5">
<IntegrationSectionIcon title="github" />
@@ -150,6 +150,7 @@ export const GitHubSection = ({ isProjectScoped }: { isProjectScoped: boolean })
disabled={!canUpdateGitHubConnection}
connection={toIntegrationProjectConnection(connection)}
type="GitHub"
+ isProjectScoped={isProjectScoped}
onDeleteConnection={onDeleteGitHubConnection}
/>
))}
diff --git a/apps/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx b/apps/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx
index 709d78ae9cb..58dc5754fa6 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx
@@ -93,11 +93,11 @@ export const IntegrationSettings = () => {
</Admonition>
)}
- <GitHubSection isProjectScoped={true} />
+ <GitHubSection isProjectScoped />
{showVercelIntegration && (
<>
- <VercelSection isProjectScoped={true} />
+ <VercelSection isProjectScoped />
<SidePanelVercelProjectLinker />
</>
)}
diff --git a/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx b/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx
index e7f48840b45..d2abba8e69b 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx
@@ -1,8 +1,8 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { ExternalLink } from 'lucide-react'
+import { ChevronDown, ExternalLink } from 'lucide-react'
import { useCallback, useMemo } from 'react'
import { toast } from 'sonner'
-import { cn } from 'ui'
+import { Button, cn, Collapsible, CollapsibleContent, CollapsibleTrigger } from 'ui'
import {
PageSection,
PageSectionContent,
@@ -38,7 +38,7 @@ import { pluralize } from '@/lib/helpers'
import { getIntegrationConfigurationUrl } from '@/lib/integration-utils'
import { useSidePanelsStateSnapshot } from '@/state/side-panels'
-export const VercelSection = ({ isProjectScoped }: { isProjectScoped: boolean }) => {
+export const VercelSection = ({ isProjectScoped = false }: { isProjectScoped?: boolean }) => {
const { data: project } = useSelectedProjectQuery()
const { data: org } = useSelectedOrganizationQuery()
const { data } = useOrgIntegrationsQuery({ orgSlug: org?.slug })
@@ -143,7 +143,7 @@ export const VercelSection = ({ isProjectScoped }: { isProjectScoped: boolean })
: 'Connect your Vercel teams to this Supabase organization. Supabase keeps environment variables up to date in each connected project. You can also link multiple Vercel projects to the same Supabase project.'
return (
- <PageSection>
+ <PageSection id="vercel">
<PageSectionMeta>
<div className="flex flex-1 items-start gap-6">
<IntegrationSectionIcon title="vercel" />
@@ -160,32 +160,52 @@ export const VercelSection = ({ isProjectScoped }: { isProjectScoped: boolean })
<NoPermission resourceText="view this organization's Vercel connections" />
) : (
<div className="space-y-6">
- <div>
- {vercelIntegration ? (
- <div key={vercelIntegration.id}>
- <IntegrationInstallation title="Vercel" integration={vercelIntegration} />
- <IntegrationConnectionHeader
- title={ConnectionHeaderTitle}
- className={connections.length === 0 ? 'pb-0' : undefined}
- markdown="Project connections for Vercel"
- />
- {connections.length > 0 && (
- <ul className="flex flex-col gap-y-2">
- {connections.map((connection) => (
- <div
- key={connection.id}
- className={cn(
- isProjectScoped && 'relative flex flex-col -gap-[1px] [&>li]:pb-0'
- )}
- >
- <IntegrationConnectionItem
- connection={connection}
- disabled={isBranch || !canUpdateVercelConnection}
- type={'Vercel' as IntegrationName}
- onDeleteConnection={onDeleteVercelConnection}
- className={cn(isProjectScoped && 'rounded-b-none! mb-0!')}
- />
- {isProjectScoped ? (
+ {vercelIntegration ? (
+ <div key={vercelIntegration.id}>
+ <IntegrationInstallation title="Vercel" integration={vercelIntegration} />
+ <IntegrationConnectionHeader
+ title={ConnectionHeaderTitle}
+ className={connections.length === 0 ? 'pb-0' : undefined}
+ markdown="Project connections for Vercel"
+ />
+ {connections.length > 0 && (
+ <ul>
+ {connections.map((connection) => (
+ <Collapsible
+ key={connection.id}
+ className={cn(
+ 'group/collapsible',
+ 'relative flex flex-col',
+ '[&>li>div]:rounded-none [&>li>div]:border-b-0',
+ '[&:first-child>li>div]:rounded-t-lg',
+ '[&[data-state=open]>li>div]:border-b',
+ '[&:last-child>li>div]:border-b',
+ '[&:last-child[data-state=closed]>li>div]:rounded-b-lg'
+ )}
+ >
+ <IntegrationConnectionItem
+ connection={connection}
+ disabled={isBranch || !canUpdateVercelConnection}
+ isProjectScoped={isProjectScoped}
+ type={'Vercel' as IntegrationName}
+ onDeleteConnection={onDeleteVercelConnection}
+ leadingAction={
+ isProjectScoped ? (
+ <CollapsibleTrigger asChild>
+ <Button
+ className="group"
+ iconRight={
+ <ChevronDown className="transition-transform group-data-[state=open]:rotate-180" />
+ }
+ >
+ Edit
+ </Button>
+ </CollapsibleTrigger>
+ ) : undefined
+ }
+ />
+ {isProjectScoped && (
+ <CollapsibleContent className="overflow-hidden data-closed:animate-collapsible-up data-open:animate-collapsible-down">
<div className="relative pl-8 ml-6 border-l border-muted pb-6">
<div className="border-b border-l border-r rounded-b-lg">
<VercelIntegrationConnectionForm
@@ -195,30 +215,30 @@ export const VercelSection = ({ isProjectScoped }: { isProjectScoped: boolean })
/>
</div>
</div>
- ) : null}
- </div>
- ))}
- </ul>
- )}
- <EmptyIntegrationConnection
- disabled={isBranch || !canCreateVercelConnection}
- onClick={() => onAddVercelConnection(vercelIntegration.id)}
- >
- Add new project connection
- </EmptyIntegrationConnection>
- </div>
- ) : (
+ </CollapsibleContent>
+ )}
+ </Collapsible>
+ ))}
+ </ul>
+ )}
<EmptyIntegrationConnection
- showNode={false}
- disabled={isBranch}
- href={integrationUrl}
- icon={<ExternalLink />}
- disabledTooltip="Install the Vercel integration on your project's main branch"
+ disabled={isBranch || !canCreateVercelConnection}
+ onClick={() => onAddVercelConnection(vercelIntegration.id)}
>
- Install Vercel integration
+ Add new project connection
</EmptyIntegrationConnection>
- )}
- </div>
+ </div>
+ ) : (
+ <EmptyIntegrationConnection
+ showNode={false}
+ disabled={isBranch}
+ href={integrationUrl}
+ icon={<ExternalLink />}
+ disabledTooltip="Install the Vercel integration on your project's main branch"
+ >
+ Install Vercel integration
+ </EmptyIntegrationConnection>
+ )}
{vercelProjectCount > 0 && vercelIntegration !== undefined && (
<p className="text-sm text-foreground-light">
Your Vercel connection can access {vercelProjectCount} Vercel projects. To change