The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
ton of type fixes
Jonathan Summers-Muir5384dfbdf889
diff --git a/studio/components/interfaces/Integrations/IntegrationPanels.tsx b/studio/components/interfaces/Integrations/IntegrationPanels.tsxindex 455bbc5e5b7..fe875ec5a5c 100644--- a/studio/components/interfaces/Integrations/IntegrationPanels.tsx+++ b/studio/components/interfaces/Integrations/IntegrationPanels.tsx@@ -1,8 +1,5 @@import { Markdown } from 'components/interfaces/Markdown'-import {- Integration,- IntegrationProjectConnection,-} from 'data/integrations/integrations-query-org-only'+import { Integration, IntegrationProjectConnection } from 'data/integrations/integrations.types'import dayjs from 'dayjs'import { useStore } from 'hooks'import { BASE_PATH } from 'lib/constants'@@ -14,9 +11,10 @@ import { Badge, Button, IconArrowRight, IconGitHub, IconSquare, cn } from 'ui'const ICON_STROKE_WIDTH = 2const ICON_SIZE = 14-export interface IntegrationInstallationProps extends React.HTMLAttributes<HTMLLIElement> {++export interface IntegrationInstallationProps extends React.RefAttributes<HTMLLIElement> {title: string- connection: Integration+ integration: Integration}type HandleIconType = Integration['integration']['name'] | 'Supabase'@@ -52,59 +50,62 @@ const HandleIcon = ({ type }: { type: HandleIconType }) => {}}-const Avatar = ({ src }: { src: string }) => {+const Avatar = ({ src }: { src: string | undefined }) => {return (<div className="relative border shadow-lg w-8 h-8 rounded-full overflow-hidden">- <Image src={src} width={30} height={30} layout="fill" alt="avatar" className="relative" />+ <Image+ src={src || ''}+ width={30}+ height={30}+ layout="fill"+ alt="avatar"+ className="relative"+ /></div>)}const IntegrationInstallation = React.forwardRef<HTMLLIElement, IntegrationInstallationProps>(- ({ className, title, connection, ...props }, ref) => {+ ({ title, integration, ...props }, ref) => {const IntegrationIconBlock = () => {return (<div className="bg-scale-100 w-8 h-8 rounded flex items-center justify-center">- <HandleIcon type={connection.integration.name} />+ <HandleIcon type={integration.integration.name} /></div>)}- console.log(connection)-return (<li- key={connection.id}+ ref={ref}+ key={integration.id}className="bg border shadow-sm flex justify-between items-center px-8 py-4 rounded-lg"+ {...props}><div className="flex gap-6 items-center"><div className="flex gap-3 items-center">- {/* <span className="relative flex h-3 w-3">- <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-brand-1100 opacity-75"></span>- <span className="relative inline-flex rounded-full h-3 w-3 bg-brand-900"></span>- </span> */}<div className="flex -space-x-1"><IntegrationIconBlock />- <Avatar src={connection?.metadata?.account?.avatar} />+ <Avatar src={integration?.metadata?.account.avatar} /></div></div><div className="flex flex-col gap-0"><div className="flex items-center gap-2"><span className="text-scale-1200 font-medium">{/* {title} integration connection •{' '} */}- {connection.metadata?.account.name || connection.metadata?.gitHubConnectionOwner}+ {integration.metadata?.account.name || integration.metadata?.gitHubConnectionOwner}</span><Badge color="scale" className="capitalize">- {connection.metadata.account.type}+ {integration.metadata?.account.type}</Badge></div><div className="flex gap-3 items-center"><span className="text-scale-900 text-sm">- Created {dayjs(connection.created_at).fromNow()}+ Created {dayjs(integration.inserted_at).fromNow()}</span><span className="text-scale-900 text-sm">- Added by {connection?.added_by?.primary_email}+ Added by {integration?.added_by?.primary_email}</span></div></div>@@ -119,7 +120,7 @@ const IntegrationInstallation = React.forwardRef<HTMLLIElement, IntegrationInstaexport interface IntegrationConnectionProps extends React.HTMLAttributes<HTMLLIElement> {connection: IntegrationProjectConnectiontype: Integration['integration']['name']- actions: React.ReactNode+ actions?: React.ReactNode}const IntegrationConnection = React.forwardRef<HTMLLIElement, IntegrationConnectionProps>(@@ -140,7 +141,7 @@ const IntegrationConnection = React.forwardRef<HTMLLIElement, IntegrationConnect<div className="flex flex-col gap-1"><div className="flex gap-2 items-center"><HandleIcon type={'Supabase'} />- <span>{projects.byId(connection.supabase_project_id)?.name}</span>+ <span>{projects.byId(connection.supabase_project_ref)?.name}</span><IconArrowRight size={14} className="text-scale-900" strokeWidth={1.5} />{!connection?.metadata?.framework ? (<HandleIcon type={type} />@@ -157,7 +158,7 @@ const IntegrationConnection = React.forwardRef<HTMLLIElement, IntegrationConnect<div className="flex gap-3 items-center"><span className="text-scale-900 text-sm">- Connected {dayjs(connection?.created_at).fromNow()}+ Connected {dayjs(connection?.inserted_at).fromNow()}</span><span className="text-scale-900 text-sm">Added by {connection?.added_by?.primary_email}@@ -187,14 +188,14 @@ const IntegrationConnectionOption = React.forwardRef<HTMLLIElement, IntegrationC<div className="flex flex-col gap-1"><div className="flex gap-2 items-center"><HandleIcon type={'Supabase'} />- <span>{projects.byId(connection.project_ref)?.name}</span>+ <span>{projects.byId(connection.supabase_project_ref)?.name}</span><IconArrowRight size={14} className="text-scale-900" strokeWidth={1.5} /><HandleIcon type={type} /><span>{connection.metadata.name}</span></div><span className="text-scale-900 text-sm">- Connected {dayjs(connection.created_at).fromNow()}+ Connected {dayjs(connection.inserted_at).fromNow()}</span></div>diff --git a/studio/components/interfaces/Integrations/ProjectsLinker.tsx b/studio/components/interfaces/Integrations/ProjectsLinker.tsxdeleted file mode 100644index 81e9ca7e6d2..00000000000--- a/studio/components/interfaces/Integrations/ProjectsLinker.tsx+++ /dev/null@@ -1,245 +0,0 @@-import { databaseIcon, vercelIcon } from 'components/to-be-cleaned/ListIcons'-import { useIntegrationConnectionsCreateMutation } from 'data/integrations/integration-connections-create-mutation'-import { VercelProjectsResponse } from 'data/integrations/integrations-vercel-projects-query'-import { useState } from 'react'-import { Button, IconArrowRight, IconPlus, IconX, Listbox, Select } from 'ui'--interface Project {- id: string- name: string-}--// to do: move this somewhere-const INTEGRATION_INTERNAL_ID = 1--export interface ProjectLinkerProps {- organizationIntegrationId: string- foreignProjects: VercelProjectsResponse[]- supabaseProjects: Project[]- onCreateConnections?: () => void- installedConnections?: any[]-}--const UNDEFINED_SELECT_VALUE = 'undefined'-const UNDEFINED_METADATA_VALUE = {}--const ProjectLinker = ({- organizationIntegrationId,- foreignProjects,- supabaseProjects,- onCreateConnections: _onCreateConnections,- installedConnections,-}: ProjectLinkerProps) => {- const [connections, setConnections] = useState(- installedConnections && installedConnections.length > 0- ? installedConnections?.map((connection) => {- return {- foreign_project_id: connection?.foreign_project_id,- supabase_project_id: connection?.supabase_project_id,- integrationId: INTEGRATION_INTERNAL_ID,- metadata: UNDEFINED_METADATA_VALUE,- }- })- : [- {- foreign_project_id: UNDEFINED_SELECT_VALUE,- supabase_project_id: UNDEFINED_SELECT_VALUE,- integrationId: INTEGRATION_INTERNAL_ID,- metadata: UNDEFINED_METADATA_VALUE,- },- ]- )-- console.log('installedConnections', installedConnections)- console.log('connections', connections)- console.log('foreignProjects', foreignProjects)- console.log('supabaseProjects', supabaseProjects)-- function onSetForeignProjectId(idx: number, id: string) {- const newConnections = [...connections]- const projectDetails = foreignProjects.filter((x) => x.id === id)[0]- newConnections[idx].metadata = { ...projectDetails }- newConnections[idx].foreign_project_id = id- newConnections[idx].supabaseConfig = {- projectEnvVars: {- write: true,- },- }-- setConnections(newConnections)- }-- function onSetSupabaseProjectId(idx: number, id: string) {- const newConnections = [...connections]- newConnections[idx].supabase_project_id = id- setConnections(newConnections)- }-- function addConnection() {- setConnections([- ...connections,- {- foreign_project_id: UNDEFINED_SELECT_VALUE,- supabase_project_id: UNDEFINED_SELECT_VALUE,- integrationId: INTEGRATION_INTERNAL_ID,- metadata: UNDEFINED_METADATA_VALUE,- },- ])- }-- function removeConnection(idx: number) {- const newConnections = [...connections]- newConnections.splice(idx, 1)- setConnections(newConnections)- }-- const { mutate: createConnections, isLoading } = useIntegrationConnectionsCreateMutation({- onSuccess() {- _onCreateConnections?.()- },- })-- function onCreateConnections() {- createConnections({- organizationIntegrationId,- connections,- })- }-- console.log(connections)-- return (- <div className="flex flex-col gap-4">- <ul>- {connections.map((connection, i) => (- <ProjectLinkerItem- key={i}- connections={connections}- foreignProjects={foreignProjects}- supabaseProjects={supabaseProjects}- foreignProjectId={connection.foreign_project_id}- setForeignProjectId={(id) => onSetForeignProjectId(i, id)}- supabaseProjectId={connection.supabase_project_id}- setSupabaseProjectId={(id) => onSetSupabaseProjectId(i, id)}- removeConnection={() => removeConnection(i)}- canRemove={connections.length > 1}- />- ))}- </ul>-- <Button- onClick={addConnection}- type="default"- icon={<IconPlus strokeWidth={2} />}- className="self-start"- >- Add Connection- </Button>-- <hr className="h-px bg-scale-500" role="separator" />-- <Button- className="self-end"- onClick={onCreateConnections}- loading={isLoading}- disabled={isLoading}- >- Continue- </Button>- </div>- )-}--export default ProjectLinker--interface ProjectLinkerItemProps {- foreignProjects: Project[]- supabaseProjects: Project[]- foreignProjectId: string- setForeignProjectId: (id: string) => void- supabaseProjectId: string- setSupabaseProjectId: (id: string) => void- removeConnection: () => void- canRemove: boolean- connections: any[]-}--const ProjectLinkerItem = ({- foreignProjects,- supabaseProjects,- foreignProjectId,- setForeignProjectId,- supabaseProjectId,- setSupabaseProjectId,- removeConnection,- canRemove,-}: ProjectLinkerItemProps) => {- console.log(supabaseProjectId)- return (- <li className="py-2">- <div className="relative flex w-full space-x-2">- <div className="w-1/2 flex-grow">- <Select value={supabaseProjectId} onChange={(e) => setSupabaseProjectId(e.target.value)}>- <Select.Option value={UNDEFINED_SELECT_VALUE} label="Choose a project" disabled>- Choose a project- </Select.Option>-- {supabaseProjects.map((project) => (- <Select.Option- key={project.id}- value={project.id}- // label={project.name}- // addOnBefore={() => databaseIcon}- >- {project.name}- </Select.Option>- ))}- </Select>- </div>- <div className="flex flex-shrink items-center">- <IconArrowRight className="text-scale-1000" />- </div>- <div className="w-1/2 flex-grow">- <Listbox- value={foreignProjectId ?? UNDEFINED_SELECT_VALUE}- onChange={setForeignProjectId}- >- <Listbox.Option value={UNDEFINED_SELECT_VALUE} label="Choose a project" disabled>- Choose a project- </Listbox.Option>-- {foreignProjects.map((project) => (- <Listbox.Option- key={project.id}- value={project.id}- label={project.name}- addOnBefore={() => {- return (- <>- {!project?.framework ? (- vercelIcon- ) : (- <img- src={`/img/icons/frameworks/${project.framework}.svg`}- width={21}- height={21}- alt={`icon`}- />- )}- </>- )- }}- >- {project.name}- </Listbox.Option>- ))}- </Listbox>- </div>-- {canRemove && (- <Button type="text" icon={<IconX strokeWidth={2} />} onClick={removeConnection} />- )}- </div>- </li>- )-}diff --git a/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx b/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsxindex cddef1fdb79..39b23288760 100644--- a/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx+++ b/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx@@ -11,8 +11,9 @@ import {ScaffoldSectionContent,ScaffoldSectionDetail,} from 'components/layouts/Scaffold'-import { Integration as TIntegration } from 'data/integrations/integrations-query-org-only'+import { Integration as TIntegration } from 'data/integrations/integrations.types'import { useIntegrationsVercelInstalledConnectionDeleteMutation } from 'data/integrations/integrations-vercel-installed-connection-delete-mutation'+import { IntegrationProjectConnection } from 'data/integrations/integrations.types'import { useStore } from 'hooks'import { BASE_PATH } from 'lib/constants'import { pluralize } from 'lib/helpers'@@ -62,7 +63,7 @@ Repository connections for ${title?.toLowerCase()}const variables = {organization_integration_id: organizationIntegrationId,id: projectIntegrationId,- orgId: ui.selectedOrganization?.id,+ orgSlug: ui.selectedOrganization?.slug,}deleteMutate(variables)@@ -85,63 +86,63 @@ Repository connections for ${title?.toLowerCase()}<div className="flex flex-col gap-12">{integrations.length > 0 &&integrations.map((integration, i) => {- console.log('integration.id', integration?.id)return (<div key={i}>- <IntegrationInstallation- title={title}- key={i}- // orgName={orgName}- connection={integration}- />+ <IntegrationInstallation title={title} key={i} integration={integration} />{integration.connections.length > 0 ? (<><ConnectionHeading integration={integration} /><ul className="flex flex-col">- {integration.connections.map((connection, i) => (- <IntegrationConnection- key={i}- connection={connection}- type={integration.integration.name}- actions={- <Dropdown- side="bottom"- align="end"- size="large"- overlay={- <>- <Dropdown.Item- icon={- <div>- <IconRefreshCcw size={14} />+ {integration.connections.map(+ (connection: IntegrationProjectConnection, i) => (+ <IntegrationConnection+ key={i}+ connection={connection}+ type={integration.integration.name}+ actions={+ <Dropdown+ side="bottom"+ align="end"+ size="large"+ overlay={+ <>+ <Dropdown.Item+ icon={+ <div>+ <IconRefreshCcw size={14} />+ </div>+ }+ >+ <div>Refresh Enviroment Variables</div>+ <div className="text-scale-900 text-xs">+ Reapply env vars in vercel.</div>- }- >- <div>Refresh Enviroment Variables</div>- <div className="text-scale-900 text-xs">- Reapply env vars in vercel.- </div>- </Dropdown.Item>- <Dropdown.Separator />- <Dropdown.Item- icon={<IconTrash size={14} />}- onSelect={() =>- handleDelete(integration.id, connection.id)- }- >- Delete- </Dropdown.Item>- </>- }- >- <Button asChild iconRight={<IconChevronDown />} type="default">- <span>Manage</span>- </Button>- </Dropdown>- }- />- ))}+ </Dropdown.Item>+ <Dropdown.Separator />+ <Dropdown.Item+ icon={<IconTrash size={14} />}+ onSelect={() =>+ handleDelete(integration.id, connection.id)+ }+ >+ Delete+ </Dropdown.Item>+ </>+ }+ >+ <Button+ asChild+ iconRight={<IconChevronDown />}+ type="default"+ >+ <span>Manage</span>+ </Button>+ </Dropdown>+ }+ />+ )+ )}</ul></>) : (diff --git a/studio/components/interfaces/Organization/IntegrationSettings/IntegrationGitHub.tsx b/studio/components/interfaces/Organization/IntegrationSettings/IntegrationGitHub.tsxdeleted file mode 100644index e1b92add11b..00000000000--- a/studio/components/interfaces/Organization/IntegrationSettings/IntegrationGitHub.tsx+++ /dev/null@@ -1,95 +0,0 @@-import {- EmptyIntegrationConnection,- IntegrationConnection,- IntegrationConnectionHeader,- IntegrationInstallation,-} from 'components/interfaces/Integrations/IntegrationPanels'-import { Markdown } from 'components/interfaces/Markdown'-import {- ScaffoldContainer,- ScaffoldSection,- ScaffoldSectionContent,- ScaffoldSectionDetail,-} from 'components/layouts/Scaffold'-import { Integration as TIntegration } from 'data/integrations/integrations-query-org-only'-import { pluralize } from 'lib/helpers'-import { EMPTY_ARR } from 'lib/void'-import { useMemo } from 'react'--export interface IntegrationProps {- title: string- orgName?: string- description?: string- note?: string- integrations?: TIntegration[]-}--const Integration = ({- title,- orgName,- description,- note,- integrations = EMPTY_ARR,-}: IntegrationProps) => {- const projectConnections = useMemo(- () => integrations.flatMap((integration) => integration.connections),- [integrations]- )-- return (- <>- <ScaffoldContainer>- <ScaffoldSection>- <ScaffoldSectionDetail>- <h2 className="text-2xl text-scale-1200">{title}</h2>- </ScaffoldSectionDetail>- <ScaffoldSectionContent>- {description !== undefined && (- <Markdown- content={`### How does the ${title} integration work?-${description}`}- />- )}- <div className="flex flex-col gap-12">- {integrations.length > 0 &&- integrations.map((integraton, i) => {- return (- <div key={i}>- <IntegrationInstallation- title={title}- key={i}- orgName={orgName}- connection={integraton}- />- {integraton.connections.length > 0 && (- <>- <IntegrationConnectionHeader- title={`${integraton.connections.length} project- ${pluralize(integraton.connections.length, 'connection')}`}- />-- <ul className="flex flex-col">- {integraton.connections.map((connection, i) => (- <IntegrationConnection key={i} connection={connection} />- ))}- </ul>-- <EmptyIntegrationConnection>- Add new project connection- </EmptyIntegrationConnection>- </>- )}- </div>- )- })}- </div>-- <Markdown content={`${note}`} className="text-scale-900" />- </ScaffoldSectionContent>- </ScaffoldSection>- </ScaffoldContainer>- </>- )-}--export default Integrationdiff --git a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoSelection.tsx b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoSelection.tsxindex 9331baf205d..4b978dd0ae2 100644--- a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoSelection.tsx+++ b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoSelection.tsx@@ -1,26 +1,27 @@import { useParams } from 'common'import { Markdown } from 'components/interfaces/Markdown'-import { useIntegrationsQuery } from 'data/integrations/integrations-query-org-only'+// import { useIntegrationsQuery } from 'data/integrations/integrations-query-org-only'import { useStore } from 'hooks'import { observer } from 'mobx-react-lite'import { useGithubConnectionConfigPanelSnapshot } from 'state/github-connection-config-panel'import { IconGitHub, IconSearch, Input, Select, SidePanel } from 'ui'+// TO DO+const GitHubRepoSelection = () => {const { ui } = useStore()const { slug } = useParams()- const { data } = useIntegrationsQuery({ orgSlug: slug })+ // const { data } = useIntegrationsQuery({ orgSlug: slug })const githubConnectionConfigPanelSnapshot = useGithubConnectionConfigPanelSnapshot()- const githubIntegrations = data?.filter((integration) => integration.type === 'GITHUB')-return (<SidePanelheader={'Add GitHub repository'}size="large"- visible={githubConnectionConfigPanelSnapshot.visible}- onCancel={() => githubConnectionConfigPanelSnapshot.setVisible(false)}+ visible={false}+ // visible={githubConnectionConfigPanelSnapshot.visible}+ // onCancel={() => githubConnectionConfigPanelSnapshot.setVisible(false)}><div className="my-10 flex flex-col gap-6"><SidePanel.Content>diff --git a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsxindex 9e86712d86c..606857d6f5f 100644--- a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx+++ b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx@@ -1,6 +1,7 @@import { useParams } from 'common'import ProjectLinker from 'components/interfaces/Integrations/ProjectLinker'import { Markdown } from 'components/interfaces/Markdown'+import { Project } from 'data/config/project-api-query'import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-org-only'import { useVercelProjectConnectionsQuery } from 'data/integrations/integrations-vercel-installed-connections-query'import { useVercelProjectsQuery } from 'data/integrations/integrations-vercel-projects-query'@@ -49,7 +50,8 @@ const SidePanelVercelProjectLinker = () => {() =>supabaseProjectsData?.filter((project) => project.organization_id === selectedOrg?.id)- .map((project) => ({ id: project.id.toString(), name: project.name })) ?? EMPTY_ARR,+ .map((project) => ({ id: project.id.toString(), name: project.name, ref: project.ref })) ??+ EMPTY_ARR,[selectedOrg?.id, supabaseProjectsData])@@ -62,8 +64,6 @@ const SidePanelVercelProjectLinker = () => {const { data: vercelProjectsData } = useVercelProjectsQuery({- orgId: selectedOrg?.id,- orgSlug: selectedOrg?.slug,organization_integration_id: organizationIntegrationId,},{ enabled: organizationIntegrationId !== null }diff --git a/studio/components/ui/OrganizationPicker.tsx b/studio/components/ui/OrganizationPicker.tsxindex 4b89efa3b3e..7f5da7a550e 100644--- a/studio/components/ui/OrganizationPicker.tsx+++ b/studio/components/ui/OrganizationPicker.tsx@@ -106,6 +106,7 @@ const OrganizationPicker = ({<Listbox.Optionkey={org.id}value={org.slug}+ // @ts-expect-errorlabel={label}addOnBefore={({ active, selected }: any) => <IconHexagon />}>diff --git a/studio/data/integrations/integrations-github-repos-query.ts b/studio/data/integrations/integrations-github-repos-query.tsindex 6498b583b2b..753d196b6f2 100644--- a/studio/data/integrations/integrations-github-repos-query.ts+++ b/studio/data/integrations/integrations-github-repos-query.ts@@ -131,7 +131,7 @@ export const useIntegrationsQuery = <TData = IntegrationsData>({ enabled = true, ...options }: UseQueryOptions<IntegrationsData, IntegrationsError, TData> = {}) =>useQuery<IntegrationsData, IntegrationsError, TData>(- integrationKeys.list(orgSlug),+ integrationKeys.integrationsList(),({ signal }) => getIntegrations({ orgSlug }, signal),{ enabled: enabled && typeof orgSlug !== 'undefined', ...options })diff --git a/studio/data/integrations/integrations-vercel-installed-connection-delete-mutation.ts b/studio/data/integrations/integrations-vercel-installed-connection-delete-mutation.tsindex dbcac04ee61..2f33b13ad9b 100644--- a/studio/data/integrations/integrations-vercel-installed-connection-delete-mutation.ts+++ b/studio/data/integrations/integrations-vercel-installed-connection-delete-mutation.ts@@ -5,9 +5,9 @@ import { UserContent } from 'types'import { integrationKeys } from './keys'type DeleteVariables = {- organization_integration_id: stringid: string- orgId: number | undefined+ organization_integration_id: string+ orgSlug: string | undefined}export async function deleteConnection(@@ -40,7 +40,13 @@ export const useIntegrationsVercelInstalledConnectionDeleteMutation = ({{async onSuccess(data, variables, context) {console.log('variables in mutate delete onSuccess', variables)- await Promise.all([queryClient.invalidateQueries(integrationKeys.list(variables.orgId))])+ await Promise.all([+ queryClient.invalidateQueries(integrationKeys.integrationsList()),+ queryClient.invalidateQueries(integrationKeys.integrationsListWithOrg(variables.orgSlug)),+ queryClient.invalidateQueries(+ integrationKeys.vercelProjectList(variables.organization_integration_id)+ ),+ ])await onSuccess?.(data, variables, context)},...options,diff --git a/studio/data/integrations/integrations.types.ts b/studio/data/integrations/integrations.types.tsindex c109395510d..e0a84f9fa78 100644--- a/studio/data/integrations/integrations.types.ts+++ b/studio/data/integrations/integrations.types.ts@@ -115,24 +115,23 @@ export type VercelGitLink =}export type Imetadata = {- metadata: {- id: string- supabaseConfig: {- projectEnvVars: {- write: boolean- }+ id: string+ supabaseConfig: {+ projectEnvVars: {+ write: boolean}- link?: VercelGitLink- name: string- framework: VercelFramework}+ link?: VercelGitLink+ name: string+ framework: VercelFramework}+export type IntegrationProjectConnection = {id: string- created_at: string+ inserted_at: stringupdated_at: stringadded_by: addedBy- supabase_project_id: string+ supabase_project_ref: stringforeign_project_id: stringorganization_integration_id: stringmetadata: Imetadata@@ -158,14 +157,16 @@ type addedBy = userDetailstype updatedBy = userDetailsexport type IntegrationName = 'Vercel' | 'Netlify' | 'GitHub'+export type VercelAcccountType = 'team' | 'personal'+export type VercelSource = 'marketplace' | 'deploy button'+export type Integration = {id: stringintegration: {- id: string- name: 'Vercel' | 'Netlify' | 'GitHub'+ name: IntegrationName}added_by: addedBy- created_at: string+ inserted_at: stringupdated_at: stringconnections: IntegrationProjectConnection[] | []organization: {@@ -174,5 +175,13 @@ export type Integration = {metadata?: {vercelTeam?: stringgitHubConnectionOwner?: string+ account: {+ name: string+ type: VercelAcccountType+ avatar: string+ source: VercelSource+ owner_id: string+ }+ configuration_id: string}}diff --git a/studio/pages/integrations/vercel.tsx b/studio/pages/integrations/vercel.tsxindex 0d6bac721bb..a156f70e419 100644--- a/studio/pages/integrations/vercel.tsx+++ b/studio/pages/integrations/vercel.tsx@@ -24,171 +24,7 @@ const VercelIntegration: NextPageWithLayout = () => {router.push({ pathname: '/integrations/vercel/install', query: router.query })}, [router])- /**- *- * remove everything here- */- const { ui } = useStore()- const { code, configurationId, next, teamId, source, externalId } = useParams()- const params = useParams()- const [selectedOrg, setSelectedOrg] = useState<Organization | null>(null)- const [organizationIntegrationId, setOrganizationIntegrationId] = useState<string | null>(null)-- const { mutate, isLoading } = useVercelIntegrationCreateMutation({- onSuccess({ id }) {- setOrganizationIntegrationId(id)- },- })-- console.log('params', params)- console.log('externalId', externalId)-- function onInstall() {- const orgSlug = selectedOrg?.slug- if (!orgSlug) {- return ui.setNotification({ category: 'error', message: 'Please select an organization' })- }-- if (!code) {- return ui.setNotification({ category: 'error', message: 'Vercel code missing' })- }-- if (!configurationId) {- return ui.setNotification({ category: 'error', message: 'Vercel Configuration ID missing' })- }-- if (!source) {- return ui.setNotification({- category: 'error',- message: 'Vercel Configuration source missing',- })- }-- const metadata = {}-- mutate({- code,- configurationId,- orgSlug,- metadata,- source,- teamId: teamId,- })- }-- const { data: supabaseProjectsData } = useProjectsQuery({- enabled: organizationIntegrationId !== null,- })-- const supabaseProjects = useMemo(- () =>- supabaseProjectsData- ?.filter((project) => project.organization_id === selectedOrg?.id)- .map((project) => ({ id: project.id.toString(), name: project.name, ref: project.ref })) ??- EMPTY_ARR,- [selectedOrg?.id, supabaseProjectsData]- )-- const { data: vercelProjectsData } = useVercelProjectsQuery(- {- orgId: selectedOrg?.id,- orgSlug: selectedOrg?.slug,- organization_integration_id: organizationIntegrationId,- },- { enabled: organizationIntegrationId !== null }- )-- console.log('vercelProjectsData', vercelProjectsData)- const vercelProjects = useMemo(() => vercelProjectsData ?? EMPTY_ARR, [vercelProjectsData])-- return (- <>- <main className="overflow-auto flex flex-col h-full">- <LoadingLine loading={isLoading} />- {organizationIntegrationId === null && (- <>- <ScaffoldContainer className="max-w-md flex flex-col gap-6 grow py-8">- <h1 className="text-xl text-scale-1200">Install Integration</h1>- <>- <Markdown content={`Choose the Supabase Organization you wish to install to`} />- <OrganizationPicker onSelectedOrgChange={setSelectedOrg} />- <div className="flex flex-row w-full justify-end">- <Button- size="medium"- className="self-end"- disabled={isLoading}- loading={isLoading}- onClick={onInstall}- >- Install integration- </Button>- </div>- </>- </ScaffoldContainer>- <ScaffoldContainer className="flex flex-col gap-6 py-3">- <Alert- withIcon- variant="info"- title="You can uninstall this Integration at any time."- >- <Markdown- content={`You can remove this integration at any time either via Vercel or the Supabase dashboard.`}- />- </Alert>- </ScaffoldContainer>- </>- )}-- {organizationIntegrationId !== null && (- <>- <ScaffoldContainer className="flex flex-col gap-6 grow py-8">- <header>- <h1 className="text-xl text-scale-1200">- Link a Supabase project to a Vercel project- </h1>- <Markdown- className="text-scale-900"- content={`-This Supabase integration manages your envioemnt variables automatically to provide the latest keys in the unlikely event that you will need to refresh your JWT token.-`}- />- </header>- {/* <ProjectLinker- organizationIntegrationId={organizationIntegrationId}- foreignProjects={vercelProjects}- supabaseProjects={supabaseProjects}- onCreateConnections={() => {- if (next) {- window.location.href = next- }- }}- /> */}-- <ProjectLinker- organizationIntegrationId={organizationIntegrationId}- foreignProjects={vercelProjects}- supabaseProjects={supabaseProjects}- onCreateConnections={() => {- if (next) {- window.location.href = next- }- }}- />- </ScaffoldContainer>- </>- )}- <ScaffoldDivider />- </main>- <ScaffoldContainer className="bg-body flex flex-row gap-6 py-6 border-t">- <div className="flex items-center gap-2 text-xs text-scale-900">- <IconBook size={16} /> Docs- </div>- <div className="flex items-center gap-2 text-xs text-scale-900">- <IconLifeBuoy size={16} /> Support- </div>- </ScaffoldContainer>- </>- )+ return <></>}VercelIntegration.getLayout = (page) => <IntegrationWindowLayout>{page}</IntegrationWindowLayout>diff --git a/studio/pages/integrations/vercel/[slug]/marketplace/choose-project.tsx b/studio/pages/integrations/vercel/[slug]/marketplace/choose-project.tsxindex dbb54eed465..cae0c637d86 100644--- a/studio/pages/integrations/vercel/[slug]/marketplace/choose-project.tsx+++ b/studio/pages/integrations/vercel/[slug]/marketplace/choose-project.tsx@@ -6,29 +6,24 @@ import ProjectLinker from 'components/interfaces/Integrations/ProjectLinker'import { Markdown } from 'components/interfaces/Markdown'import IntegrationWindowLayout from 'components/layouts/IntegrationWindowLayout'import { ScaffoldContainer, ScaffoldDivider } from 'components/layouts/Scaffold'+import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-org-only'import { useVercelProjectsQuery } from 'data/integrations/integrations-vercel-projects-query'-import { useVercelIntegrationCreateMutation } from 'data/integrations/vercel-integration-create-mutation'+import { useOrganizationsQuery } from 'data/organizations/organizations-query'import { useProjectsQuery } from 'data/projects/projects-query'import { useStore } from 'hooks'import { EMPTY_ARR } from 'lib/void'+import { useRouter } from 'next/router'import { NextPageWithLayout, Organization } from 'types'import { IconBook, IconLifeBuoy, LoadingLine } from 'ui'-import { useIntegrationsQuery } from 'data/integrations/integrations-github-repos-query'-import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-org-only'-import { useRouter } from 'next/router'const VercelIntegration: NextPageWithLayout = () => {- const { ui } = useStore()const router = useRouter()- const { code, configurationId, next, teamId, source, externalId } = useParams()+ const { configurationId, next, organizationSlug } = useParams()const [loading, setLoading] = useState<boolean>(false)- const [selectedOrg, setSelectedOrg] = useState<Organization | null>(null)- // const [organizationIntegrationId, setOrganizationIntegrationId] = useState<string | undefined>(- // undefined- // )const { slug } = router.query+/*** Fetch the list of organization based integration installations for Vercel.*@@ -38,36 +33,34 @@ const VercelIntegration: NextPageWithLayout = () => {orgSlug: slug?.toString(),})- console.log('integrationData', integrationData)+ const { data, isLoading: isLoadingOrganizationsQuery } = useOrganizationsQuery({+ enabled: slug !== undefined,+ })- const organizationIntegrationId = integrationData?.find(- (x) => x.metadata?.configuration_id === configurationId- )?.id+ const organization = data?.find((organization: Organization) => organization.slug === slug)- console.log('organizationIntegrationId', organizationIntegrationId)+ const integration = integrationData?.find((x) => x.metadata?.configuration_id === configurationId)const { data: supabaseProjectsData } = useProjectsQuery({- enabled: organizationIntegrationId !== null,+ enabled: integration?.id !== undefined,})const supabaseProjects = useMemo(() =>supabaseProjectsData- ?.filter((project) => project.organization_id === selectedOrg?.id)+ ?.filter((project) => project.organization_id === organization?.id).map((project) => ({ id: project.id.toString(), name: project.name, ref: project.ref })) ??EMPTY_ARR,- [selectedOrg?.id, supabaseProjectsData]+ [organizationSlug, supabaseProjectsData])const { data: vercelProjectsData } = useVercelProjectsQuery({- organization_integration_id: organizationIntegrationId,+ organization_integration_id: integration?.id,},- { enabled: organizationIntegrationId !== undefined }+ { enabled: integration?.id !== undefined })- console.log('vercelProjectsData', vercelProjectsData)-const vercelProjects = useMemo(() => vercelProjectsData ?? EMPTY_ARR, [vercelProjectsData])return (@@ -88,7 +81,7 @@ This Supabase integration manages your envioemnt variables automatically to prov/></header><ProjectLinker- organizationIntegrationId={organizationIntegrationId}+ organizationIntegrationId={integration?.id}foreignProjects={vercelProjects}supabaseProjects={supabaseProjects}onCreateConnections={() => {@@ -96,6 +89,7 @@ This Supabase integration manages your envioemnt variables automatically to provwindow.location.href = next}}}+ installedConnections={integration?.connections}/></ScaffoldContainer></>diff --git a/studio/pages/integrations/vercel/install.tsx b/studio/pages/integrations/vercel/install.tsxindex 4b8dc7b38bf..72c46376e1a 100644--- a/studio/pages/integrations/vercel/install.tsx+++ b/studio/pages/integrations/vercel/install.tsx@@ -48,15 +48,18 @@ const VercelIntegration: NextPageWithLayout = () => {*/const { data: integrationData, isLoading: integrationDataLoading } = useIntegrationsQuery({})- const { data, isLoading: isLoadingOrganizationsQuery } = useOrganizationsQuery({- onSuccess(organizations) {- const firstOrg = organizations?.[0]- if (firstOrg && selectedOrg === null) {- setSelectedOrg(firstOrg)- snapshot.setSelectedOrganizationSlug(firstOrg.slug)- }- },- })+ const { data: organizationsData, isLoading: isLoadingOrganizationsQuery } = useOrganizationsQuery(+ {+ onSuccess(organizations) {+ const firstOrg = organizations?.[0]+ if (firstOrg && selectedOrg === null) {+ setSelectedOrg(firstOrg)+ snapshot.setSelectedOrganizationSlug(firstOrg.slug)+ router.query.organizationSlug = firstOrg.slug+ }+ },+ }+ )/*** Flat array of org slugs that have integration installed@@ -67,14 +70,16 @@ const VercelIntegration: NextPageWithLayout = () => {? integrationData?.map((x) => x.organization.slug): []+ console.log('flatInstalledConnectionsIds', flatInstalledConnectionsIds)+/*** Organizations with extra `installationInstalled` attribute** Used to show label/badge and allow/disallow installing**/- const organizationsWithInstalledData: OrganizationsResponseWithInstalledData[] = data- ? data.map((org) => {+ const organizationsWithInstalledData: OrganizationsResponseWithInstalledData[] = organizationsData+ ? organizationsData.map((org) => {return {...org,installationInstalled: flatInstalledConnectionsIds.includes(org.slug) ? true : false,@@ -91,6 +96,15 @@ const VercelIntegration: NextPageWithLayout = () => {function onInstall() {const orgSlug = selectedOrg?.slug++ const isIntegrationInstalled = organizationsWithInstalledData.find(+ (x) => x.slug === orgSlug && x.installationInstalled+ )+ ? true+ : false++ console.log('isIntegrationInstalled', isIntegrationInstalled)+if (!orgSlug) {return ui.setNotification({ category: 'error', message: 'Please select an organization' })}@@ -110,14 +124,15 @@ const VercelIntegration: NextPageWithLayout = () => {})}- const metadata = {}-- if (!flatInstalledConnectionsIds.includes(orgSlug)) {+ /**+ * Only install if instgration hasn't already been installed+ */+ if (!isIntegrationInstalled) {mutate({code,configurationId,orgSlug,- metadata,+ metadata: {},source,teamId: teamId,})@@ -151,7 +166,10 @@ const VercelIntegration: NextPageWithLayout = () => {<OrganizationPickerintegrationName="Vercel"organizationsWithInstalledData={organizationsWithInstalledData}- onSelectedOrgChange={setSelectedOrg}+ onSelectedOrgChange={(e) => {+ router.query.organizationSlug = e.slug+ setSelectedOrg(e)+ }}dataLoading={dataLoading}/><div className="flex flex-row w-full justify-end">