The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
ref: Rework VercelSection component to be shared in proj/org settings (#18797)
Kamil Ogórek7c824cc5ef71
diff --git a/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx b/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsxindex 028ffd15ca0..8170824b0b1 100644--- a/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx+++ b/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx@@ -1,12 +1,11 @@-import Link from 'next/link'-import { useCallback, useMemo } from 'react'-import { Button, IconExternalLink } from 'ui'+import { useCallback } from 'react'import {EmptyIntegrationConnection,IntegrationConnectionHeader,IntegrationInstallation,} from 'components/interfaces/Integrations/IntegrationPanels'+import VercelSection from 'components/interfaces/Settings/Integrations/VercelIntegration/VercelSection'import { Markdown } from 'components/interfaces/Markdown'import {ScaffoldContainer,@@ -17,13 +16,10 @@ import {} from 'components/layouts/Scaffold'import { useIntegrationsGitHubInstalledConnectionDeleteMutation } from 'data/integrations/integrations-github-connection-delete-mutation'import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-org-only'-import { useIntegrationsVercelInstalledConnectionDeleteMutation } from 'data/integrations/integrations-vercel-installed-connection-delete-mutation'-import { useVercelProjectsQuery } from 'data/integrations/integrations-vercel-projects-query'import { IntegrationName, IntegrationProjectConnection } from 'data/integrations/integrations.types'import { useSelectedOrganization, useStore } from 'hooks'import { BASE_PATH } from 'lib/constants'import { pluralize } from 'lib/helpers'-import { getIntegrationConfigurationUrl } from 'lib/integration-utils'import { useSidePanelsStateSnapshot } from 'state/side-panels'import { IntegrationConnectionItem } from '../../Integrations/IntegrationConnection'import SidePanelGitHubRepoLinker from './SidePanelGitHubRepoLinker'@@ -45,17 +41,6 @@ const IntegrationSettings = () => {const { data } = useOrgIntegrationsQuery({ orgSlug: org?.slug })const sidePanelsStateSnapshot = useSidePanelsStateSnapshot()- const { mutate: deleteVercelConnection } = useIntegrationsVercelInstalledConnectionDeleteMutation(- {- onSuccess: () => {- ui.setNotification({- category: 'success',- message: 'Successfully deleted Vercel connection',- })- },- }- )-const { mutate: deleteGitHubConnection } = useIntegrationsGitHubInstalledConnectionDeleteMutation({onSuccess: () => {@@ -67,46 +52,10 @@ const IntegrationSettings = () => {})- const vercelIntegrations = useMemo(() => {- return data- ?.filter((integration) => integration.integration.name === 'Vercel')- .map((integration) => {- if (integration.metadata && integration.integration.name === 'Vercel') {- const avatarSrc =- !integration.metadata.account.avatar && integration.metadata.account.type === 'Team'- ? `https://vercel.com/api/www/avatar?teamId=${integration.metadata.account.team_id}&s=48`- : `https://vercel.com/api/www/avatar/${integration.metadata.account.avatar}?s=48`-- integration['metadata']['account']['avatar'] = avatarSrc- }-- return integration- })- }, [data])-const githubIntegrations = data?.filter((integration) => integration.integration.name === 'GitHub')- // We're only supporting one Vercel integration per org for now- // this will need to be updated when we support multiple integrations- const vercelIntegration = vercelIntegrations?.[0]- const { data: vercelProjectsData } = useVercelProjectsQuery(- {- organization_integration_id: vercelIntegration?.id,- },- { enabled: vercelIntegration?.id !== undefined }- )- const vercelProjectCount = vercelProjectsData?.length ?? 0-- const onAddVercelConnection = useCallback(- (integrationId: string) => {- sidePanelsStateSnapshot.setVercelConnectionsIntegrationId(integrationId)- sidePanelsStateSnapshot.setVercelConnectionsOpen(true)- },- [sidePanelsStateSnapshot]- )-const onAddGitHubConnection = useCallback((integrationId: string) => {sidePanelsStateSnapshot.setGithubConnectionsIntegrationId(integrationId)@@ -115,17 +64,6 @@ const IntegrationSettings = () => {[sidePanelsStateSnapshot])- const onDeleteVercelConnection = useCallback(- async (connection: IntegrationProjectConnection) => {- deleteVercelConnection({- id: connection.id,- organization_integration_id: connection.organization_integration_id,- orgSlug: org?.slug,- })- },- [deleteVercelConnection, org?.slug]- )-const onDeleteGitHubConnection = useCallback(async (connection: IntegrationProjectConnection) => {deleteGitHubConnection({@@ -137,110 +75,6 @@ const IntegrationSettings = () => {[deleteGitHubConnection, org?.slug])- /**- * Vercel markdown content- */-- const VercelTitle = `Vercel Integration`-- const VercelDetailsSection = `--Connect your Vercel teams to your Supabase organization.-`-- const VercelContentSectionTop = `--### How does the Vercel integration work?--Supabase will keep your environment variables up to date in each of the projects you assign to a Supabase project.-You can also link multiple Vercel Projects to the same Supabase project.-`-- const VercelContentSectionBottom =- vercelProjectCount > 0 && vercelIntegration !== undefined- ? `-Your Vercel connection has access to ${vercelProjectCount} Vercel Projects.-You can change the scope of the access for Supabase by configuring-[here](${getIntegrationConfigurationUrl(vercelIntegration)}).-`- : ''-- const integrationUrl =- process.env.NEXT_PUBLIC_ENVIRONMENT === 'staging'- ? 'https://vercel.com/integrations/supabase-v2-staging'- : 'https://vercel.com/integrations/supabase-v2'-- const VercelSection = () => (- <ScaffoldContainer>- <ScaffoldSection>- <ScaffoldSectionDetail title={VercelTitle}>- <Markdown content={VercelDetailsSection} />- <IntegrationImageHandler title="vercel" />- </ScaffoldSectionDetail>- <ScaffoldSectionContent>- <Markdown content={VercelContentSectionTop} />-- {vercelIntegrations && vercelIntegrations.length > 0 ? (- vercelIntegrations.map((integration, i) => {- const ConnectionHeaderTitle = `${integration.connections.length} project ${pluralize(- integration.connections.length,- 'connection'- )} `-- return (- <div key={integration.id}>- <IntegrationInstallation title={'Vercel'} integration={integration} />- {integration.connections.length > 0 ? (- <>- <IntegrationConnectionHeader- title={ConnectionHeaderTitle}- markdown={`Repository connections for Vercel`}- />- <ul className="flex flex-col">- {integration.connections.map((connection) => (- <IntegrationConnectionItem- key={connection.id}- connection={connection}- type={'Vercel' as IntegrationName}- onDeleteConnection={onDeleteVercelConnection}- />- ))}- </ul>- </>- ) : (- <IntegrationConnectionHeader- markdown={`### ${integration.connections.length} project ${pluralize(- integration.connections.length,- 'connection'- )} Repository connections for Vercel`}- />- )}- <EmptyIntegrationConnection- onClick={() => onAddVercelConnection(integration.id)}- orgSlug={org?.slug}- >- Add new project connection- </EmptyIntegrationConnection>- </div>- )- })- ) : (- <div>- <Button asChild type="default" iconRight={<IconExternalLink />}>- <Link href={integrationUrl} target="_blank">- Install Vercel Integration- </Link>- </Button>- </div>- )}- {VercelContentSectionBottom && (- <Markdown content={VercelContentSectionBottom} className="text-foreground-lighter" />- )}- </ScaffoldSectionContent>- </ScaffoldSection>- </ScaffoldContainer>- )-/*** GitHub markdown content*/@@ -324,7 +158,7 @@ These connections will be part of a GitHub workflow that is currently in develop<><GitHubSection /><ScaffoldDivider />- <VercelSection />+ <VercelSection isProjectScoped={false} /><SidePanelVercelProjectLinker /><SidePanelGitHubRepoLinker /></>diff --git a/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx b/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsxindex 81d382761e1..53154a6206b 100644--- a/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx+++ b/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx@@ -20,7 +20,7 @@ const IntegrationSettings = () => {<><GitHubSection /><ScaffoldDivider />- <VercelSection />+ <VercelSection isProjectScoped={true} /><SidePanelVercelProjectLinker /><SidePanelGitHubRepoLinker /></>diff --git a/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx b/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsxindex 6ce319c7812..ddbbe6af5d1 100644--- a/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx+++ b/studio/components/interfaces/Settings/Integrations/VercelIntegration/VercelSection.tsx@@ -25,8 +25,9 @@ import { getIntegrationConfigurationUrl } from 'lib/integration-utils'import { useSidePanelsStateSnapshot } from 'state/side-panels'import { IntegrationImageHandler } from '../IntegrationsSettings'import VercelIntegrationConnectionForm from './VercelIntegrationConnectionForm'+import clsx from 'clsx'-const VercelSection = () => {+const VercelSection = ({ isProjectScoped }: { isProjectScoped: boolean }) => {const { ui } = useStore()const project = useSelectedProject()const org = useSelectedOrganization()@@ -116,6 +117,23 @@ You can change the scope of the access for Supabase by configuring`: ''+ const integrationUrl =+ process.env.NEXT_PUBLIC_ENVIRONMENT === 'staging'+ ? 'https://vercel.com/integrations/supabase-v2-staging'+ : 'https://vercel.com/integrations/supabase-v2'++ let connections =+ (isProjectScoped+ ? vercelIntegration?.connections.filter(+ (connection) => connection.supabase_project_ref === project?.ref+ )+ : vercelIntegration?.connections) || []++ const ConnectionHeaderTitle = `${connections.length} project ${pluralize(+ connections.length,+ 'connection'+ )} `+return (<ScaffoldContainer><ScaffoldSection>@@ -125,63 +143,60 @@ You can change the scope of the access for Supabase by configuring</ScaffoldSectionDetail><ScaffoldSectionContent><Markdown content={VercelContentSectionTop} />- {vercelIntegrations && vercelIntegrations.length > 0 ? (- vercelIntegrations- .filter((x) =>- x.connections.find((x) => x.supabase_project_ref === project?.parentRef)- )- .map((integration, i) => {- return (- <div key={integration.id}>- <IntegrationInstallation title={'Vercel'} integration={integration} />- {integration.connections.length > 0 ? (- <>- <IntegrationConnectionHeader />- <ul className="flex flex-col">- {integration.connections.map((connection) => (- <div- key={connection.id}- className="relative flex flex-col -gap-[1px] [&>li]:pb-0"- >- <IntegrationConnectionItem+ {vercelIntegration ? (+ <div key={vercelIntegration.id}>+ <IntegrationInstallation title={'Vercel'} integration={vercelIntegration} />+ {connections.length > 0 ? (+ <>+ <IntegrationConnectionHeader+ title={ConnectionHeaderTitle}+ markdown={`Repository connections for Vercel`}+ />+ <ul className="flex flex-col">+ {connections.map((connection) => (+ <div+ key={connection.id}+ className={clsx(+ isProjectScoped && 'relative flex flex-col -gap-[1px] [&>li]:pb-0'+ )}+ >+ <IntegrationConnectionItem+ connection={connection}+ type={'Vercel' as IntegrationName}+ onDeleteConnection={onDeleteVercelConnection}+ className={clsx(isProjectScoped && '!rounded-b-none !mb-0')}+ />+ {isProjectScoped ? (+ <div className="relative pl-8 ml-6 border-l border-muted pb-6">+ <div className="border-b border-l border-r rounded-b-lg">+ <VercelIntegrationConnectionFormconnection={connection}- type={'Vercel' as IntegrationName}- onDeleteConnection={onDeleteVercelConnection}- className="!rounded-b-none !mb-0"+ integration={vercelIntegration}/>- <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- connection={connection}- integration={integration}- />- </div>- </div></div>- ))}- </ul>- </>- ) : (- <IntegrationConnectionHeader- markdown={`### ${integration.connections.length} project ${pluralize(- integration.connections.length,- 'connection'- )} Repository connections for Vercel`}- />- )}- <EmptyIntegrationConnection- onClick={() => onAddVercelConnection(integration.id)}- orgSlug={org?.slug}- >- Add new project connection- </EmptyIntegrationConnection>- </div>- )- })+ </div>+ ) : null}+ </div>+ ))}+ </ul>+ </>+ ) : (+ <IntegrationConnectionHeader+ title={ConnectionHeaderTitle}+ markdown={`Repository connections for Vercel`}+ />+ )}+ <EmptyIntegrationConnection+ onClick={() => onAddVercelConnection(vercelIntegration.id)}+ orgSlug={org?.slug}+ >+ Add new project connection+ </EmptyIntegrationConnection>+ </div>) : (<div><Button asChild type="default" iconRight={<IconExternalLink />}>- <Link href="https://vercel.com/integrations/supabase-v2" target="_blank">+ <Link href={integrationUrl} target="_blank">Install Vercel Integration</Link></Button>