mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 03:45:06 +03:00
* update deps + image codemod (studio) * update next links (studio) * update deps * update links (ui) * remove next-transpile-modules * move next-themes dependency * chore: update ConfirmDialog * chore: remove old ConfirmModal js file. migrated to TS * dependency wrangling * remove empty page * update next links (www) * First run bump react-data-grid-v7 beta 4 * fix package-lock.json * more deps wrangling * update recharts * update sentry options * fix some broken things in www * studio fixes * fix graphiql * fix studio build * fix menu hydration * small build error * update turbo * fix www typescript errors * docs image codemod * links codemod docs * fix docs typescript errors * move useConsent to ui to prevent circular deps * Fix links * Fix homepage * Fix links * move studio/ to apps/ * Revert "move studio/ to apps/" This reverts commit1b0a985fcb. * disable outputFileTracingRoot * remove outputFileTracingRoot * fix homepage product cards * fix PrivacySettings links * Fix links * Fix the build for www. * Minor fixes for JWTGenerator. * Fix the docs and ui tests. * Revert codehike back to 0.8.3 * remove ConfirmAlert() * reenable babel because mobx hates me * fix blog image and comparison page avatar * Fix svg errors * update image synthax * Fix code hike * Move the button in a div so that it doesn't inherit its parent height and make the button look weird. * When components are defined in a component, they get recreated on each render. This makes them unstable in certain cases and causes infinite rerenders. * Replace the next/head usage with next/script. * Chore/upgrade next 13 fix table editor (#18431) * fix table editor styling and fix row deletion logic * Fix deleting selected rows from header, and fix checkboxes not clearing up * Fix deleting all rows when filter applied, and fix deleting all rows * Fix grid size styling issue * Fix TS error * Hydration errors * studio org pages fixes * fix more studio links * audit logs fixes * dropdown icon styling fixes * fix some images in www * upgrade to next 14 * try new sentry wrapper for api * see if this is even invoked * Revert "see if this is even invoked" This reverts commit86c3973ffa. * Revert "try new sentry wrapper for api" This reverts commitf67623ebad. * Revert "upgrade to next 14" This reverts commita24dd6131e. * chore: allow node version 19/20 * Try to fix the LogTable so that it renders with the newer "react-data-grid" version. * Fix type errors in the log renderer code. * Fix the replication screen. * Add the CSS for the GraphiQL. * Fix SQL editor results rendering * Lint * Fix SQL editor results height issue * Fix auth RLS not invalidating RQ when toggling RLS * Fix database tables new/edit column regressed * Fix migrations page empty state if migrations schema not yet created * Fix API side panel docs temp remove postgrest text for column description PK and FK * Fix + improve timeout handling in SQL editor --------- Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Francesco Sansalvadore <f.sansalvadore@gmail.com> Co-authored-by: Terry Sutton <saltcod@gmail.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
200 lines
7.8 KiB
TypeScript
200 lines
7.8 KiB
TypeScript
import Link from 'next/link'
|
|
import { useCallback, useMemo } from 'react'
|
|
import { Button, IconExternalLink } from 'ui'
|
|
|
|
import { IntegrationConnectionItem } from 'components/interfaces/Integrations/IntegrationConnection'
|
|
import {
|
|
EmptyIntegrationConnection,
|
|
IntegrationConnectionHeader,
|
|
IntegrationInstallation,
|
|
} from 'components/interfaces/Integrations/IntegrationPanels'
|
|
import { Markdown } from 'components/interfaces/Markdown'
|
|
import {
|
|
ScaffoldContainer,
|
|
ScaffoldSection,
|
|
ScaffoldSectionContent,
|
|
ScaffoldSectionDetail,
|
|
} from 'components/layouts/Scaffold'
|
|
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, useSelectedProject, useStore } from 'hooks'
|
|
import { pluralize } from 'lib/helpers'
|
|
import { getIntegrationConfigurationUrl } from 'lib/integration-utils'
|
|
import { useSidePanelsStateSnapshot } from 'state/side-panels'
|
|
import { IntegrationImageHandler } from '../IntegrationsSettings'
|
|
import VercelIntegrationConnectionForm from './VercelIntegrationConnectionForm'
|
|
|
|
const VercelSection = () => {
|
|
const { ui } = useStore()
|
|
const project = useSelectedProject()
|
|
const org = useSelectedOrganization()
|
|
const { data } = useOrgIntegrationsQuery({ orgSlug: org?.slug })
|
|
const sidePanelsStateSnapshot = useSidePanelsStateSnapshot()
|
|
|
|
const { mutate: deleteVercelConnection } = useIntegrationsVercelInstalledConnectionDeleteMutation(
|
|
{
|
|
onSuccess: () => {
|
|
ui.setNotification({
|
|
category: 'success',
|
|
message: 'Successfully deleted Vercel connection',
|
|
})
|
|
},
|
|
}
|
|
)
|
|
|
|
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])
|
|
|
|
// 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 onDeleteVercelConnection = useCallback(
|
|
async (connection: IntegrationProjectConnection) => {
|
|
deleteVercelConnection({
|
|
id: connection.id,
|
|
organization_integration_id: connection.organization_integration_id,
|
|
orgSlug: org?.slug,
|
|
})
|
|
},
|
|
[deleteVercelConnection, org?.slug]
|
|
)
|
|
|
|
// 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)}).
|
|
`
|
|
: ''
|
|
|
|
return (
|
|
<ScaffoldContainer>
|
|
<ScaffoldSection>
|
|
<ScaffoldSectionDetail title={VercelTitle}>
|
|
<Markdown content={VercelDetailsSection} />
|
|
<IntegrationImageHandler title="vercel" />
|
|
</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
|
|
connection={connection}
|
|
type={'Vercel' as IntegrationName}
|
|
onDeleteConnection={onDeleteVercelConnection}
|
|
className="!rounded-b-none !mb-0"
|
|
/>
|
|
<div className="relative pl-8 ml-6 border-l border-scale-600 dark:border-scale-400 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>
|
|
<Button asChild type="default" iconRight={<IconExternalLink />}>
|
|
<Link href="https://vercel.com/integrations/supabase-v2" target="_blank">
|
|
Install Vercel Integration
|
|
</Link>
|
|
</Button>
|
|
</div>
|
|
)}
|
|
{VercelContentSectionBottom && (
|
|
<Markdown content={VercelContentSectionBottom} className="text-lighter" />
|
|
)}
|
|
</ScaffoldSectionContent>
|
|
</ScaffoldSection>
|
|
</ScaffoldContainer>
|
|
)
|
|
}
|
|
|
|
export default VercelSection
|