Skip to content

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

improve integration creation and deletion

Alaister Young0b7295ced463
diff --git a/studio/components/interfaces/Integrations/IntegrationPanels.tsx b/studio/components/interfaces/Integrations/IntegrationPanels.tsx
index e4e6d36cb9f..6863006001c 100644
--- a/studio/components/interfaces/Integrations/IntegrationPanels.tsx
+++ b/studio/components/interfaces/Integrations/IntegrationPanels.tsx
@@ -6,7 +6,6 @@ import { Markdown } from 'components/interfaces/Markdown'
import { Integration, IntegrationProjectConnection } from 'data/integrations/integrations.types'
import { useProjectsQuery } from 'data/projects/projects-query'
import { BASE_PATH } from 'lib/constants'
-import { getVercelConfigurationUrl } from 'lib/integration-utils'
import { Badge, Button, IconArrowRight, IconExternalLink, IconGitHub, IconSquare, cn } from 'ui'
const ICON_STROKE_WIDTH = 2
@@ -15,6 +14,7 @@ const ICON_SIZE = 14
export interface IntegrationInstallationProps extends React.RefAttributes<HTMLLIElement> {
title: string
integration: Integration
+ getManageUrl: (integration: Integration) => string
}
type HandleIconType = Integration['integration']['name'] | 'Supabase'
@@ -66,7 +66,7 @@ const Avatar = ({ src }: { src: string | undefined }) => {
}
const IntegrationInstallation = React.forwardRef<HTMLLIElement, IntegrationInstallationProps>(
- ({ title, integration, ...props }, ref) => {
+ ({ title, integration, getManageUrl, ...props }, ref) => {
const IntegrationIconBlock = () => {
return (
<div className="bg-black text-white w-8 h-8 rounded flex items-center justify-center">
@@ -112,12 +112,7 @@ const IntegrationInstallation = React.forwardRef<HTMLLIElement, IntegrationInsta
</div>
<Button type="default" asChild iconRight={<IconExternalLink />}>
- {/* hard coded to vercel for now, TODO: move to a prop */}
- <a
- href={getVercelConfigurationUrl(integration)}
- target="_blank"
- rel="noopener noreferrer"
- >
+ <a href={getManageUrl(integration)} target="_blank" rel="noopener noreferrer">
Manage
</a>
</Button>
@@ -153,7 +148,7 @@ const IntegrationConnection = React.forwardRef<HTMLLIElement, IntegrationConnect
<IconArrowRight size={14} className="text-scale-900" strokeWidth={1.5} />
{!connection?.metadata?.framework ? (
<div className="bg-black text-white w-4 h-4 rounded flex items-center justify-center">
- <HandleIcon type={'Vercel'} className={'!w-2.5'} />
+ <HandleIcon type={type} className={'!w-2.5'} />
</div>
) : (
<img
diff --git a/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx b/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx
index c0a351aff61..624d050743b 100644
--- a/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx
+++ b/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx
@@ -11,42 +11,39 @@ import {
ScaffoldSectionContent,
ScaffoldSectionDetail,
} from 'components/layouts/Scaffold'
-import { useIntegrationsVercelInstalledConnectionDeleteMutation } from 'data/integrations/integrations-vercel-installed-connection-delete-mutation'
+import ConfirmationModal from 'components/ui/ConfirmationModal'
import {
+ IntegrationName,
IntegrationProjectConnection,
Integration as TIntegration,
} from 'data/integrations/integrations.types'
-import { useSelectedOrganization } from 'hooks'
import { BASE_PATH } from 'lib/constants'
import { pluralize } from 'lib/helpers'
import { EMPTY_ARR } from 'lib/void'
-import { useGithubConnectionConfigPanelSnapshot } from 'state/github-connection-config-panel'
-import { Button, Dropdown, IconChevronDown, IconTrash } from 'ui'
+import { useCallback, useState } from 'react'
+import { Button, Dropdown, IconChevronDown, IconTrash, Modal } from 'ui'
export interface IntegrationProps {
title: string
- orgName?: string
description?: string
note?: string
detail?: string
integrations?: TIntegration[]
+ getManageUrl: (integration: TIntegration) => string
+ onAddConnection: (integrationId: string) => void
+ onDeleteConnection: (connection: IntegrationProjectConnection) => void | Promise<void>
}
const Integration = ({
title,
- orgName,
description,
note,
detail,
integrations = EMPTY_ARR,
+ getManageUrl,
+ onAddConnection,
+ onDeleteConnection,
}: IntegrationProps) => {
- const snapshot = useGithubConnectionConfigPanelSnapshot()
-
- const selectedOrganization = useSelectedOrganization()
-
- const { mutate: deleteMutate, isLoading: isDeleteLoading } =
- useIntegrationsVercelInstalledConnectionDeleteMutation()
-
const ConnectionHeading = ({ integration }: { integration: TIntegration }) => {
return (
<IntegrationConnectionHeader
@@ -60,17 +57,6 @@ Repository connections for ${title?.toLowerCase()}
)
}
- // Call the mutation when needed
- const handleDelete = (organizationIntegrationId: string, projectIntegrationId: string) => {
- const variables = {
- organization_integration_id: organizationIntegrationId,
- id: projectIntegrationId,
- orgSlug: selectedOrganization?.slug,
- }
-
- deleteMutate(variables)
- }
-
return (
<>
<ScaffoldContainer>
@@ -89,60 +75,32 @@ Repository connections for ${title?.toLowerCase()}
{integrations.length > 0 &&
integrations.map((integration, i) => {
return (
- <div key={i}>
- <IntegrationInstallation title={title} key={i} integration={integration} />
+ <div key={integration.id}>
+ <IntegrationInstallation
+ title={title}
+ integration={integration}
+ getManageUrl={getManageUrl}
+ />
+
{integration.connections.length > 0 ? (
<>
<ConnectionHeading integration={integration} />
<ul className="flex flex-col">
- {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={<IconTrash size={14} />}
- onSelect={() =>
- handleDelete(integration.id, connection.id)
- }
- >
- Delete
- </Dropdown.Item>
- </>
- }
- >
- <Button
- asChild
- iconRight={<IconChevronDown />}
- type="default"
- >
- <span>Manage</span>
- </Button>
- </Dropdown>
- }
- />
- )
- )}
+ {integration.connections.map((connection) => (
+ <IntegrationConnectionItem
+ key={connection.id}
+ connection={connection}
+ type={title as IntegrationName}
+ onDeleteConnection={onDeleteConnection}
+ />
+ ))}
</ul>
</>
) : (
<ConnectionHeading integration={integration} />
)}
- <EmptyIntegrationConnection
- onClick={() => {
- snapshot.setOrganizationIntegrationId(integration.id)
- snapshot.setOpen(true)
- }}
- >
+ <EmptyIntegrationConnection onClick={() => onAddConnection(integration.id)}>
Add new project connection
</EmptyIntegrationConnection>
</div>
@@ -158,3 +116,71 @@ Repository connections for ${title?.toLowerCase()}
}
export default Integration
+
+type IntegrationConnectionItemProps = {
+ connection: IntegrationProjectConnection
+ type: IntegrationName
+ onDeleteConnection: (connection: IntegrationProjectConnection) => void | Promise<void>
+}
+
+const IntegrationConnectionItem = ({
+ connection,
+ type,
+ onDeleteConnection,
+}: IntegrationConnectionItemProps) => {
+ const [isOpen, setIsOpen] = useState(false)
+
+ const onConfirm = useCallback(async () => {
+ try {
+ await onDeleteConnection(connection)
+ } finally {
+ setIsOpen(false)
+ }
+ }, [connection, onDeleteConnection])
+
+ const onCancel = useCallback(() => {
+ setIsOpen(false)
+ }, [])
+
+ return (
+ <>
+ <IntegrationConnection
+ connection={connection}
+ type={type}
+ actions={
+ <Dropdown
+ side="bottom"
+ align="end"
+ size="large"
+ overlay={
+ <>
+ <Dropdown.Item icon={<IconTrash size={14} />} onSelect={() => setIsOpen(true)}>
+ Delete
+ </Dropdown.Item>
+ </>
+ }
+ >
+ <Button asChild iconRight={<IconChevronDown />} type="default">
+ <span>Manage</span>
+ </Button>
+ </Dropdown>
+ }
+ />
+
+ <ConfirmationModal
+ visible={isOpen}
+ danger={true}
+ header="Confirm to delete"
+ buttonLabel="Delete"
+ onSelectCancel={onCancel}
+ onSelectConfirm={onConfirm}
+ >
+ <Modal.Content>
+ <p className="py-4 text-sm text-scale-1100">
+ {`This action cannot be undone. Are you sure you want to delete this connection?`}
+ </p>
+ </Modal.Content>
+ </ConfirmationModal>
+ </>
+ )
+}
diff --git a/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx b/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
index 73ecdfb1e36..1f122d5462e 100644
--- a/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
+++ b/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
@@ -1,15 +1,20 @@
+import { useCallback, useState } from 'react'
+
+import { useParams } from 'common'
import { ScaffoldDivider } 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 { useSelectedOrganization } from 'hooks'
-import { getVercelConfigurationUrl } from 'lib/integration-utils'
+import { IntegrationProjectConnection } from 'data/integrations/integrations.types'
+import { getGitHubConfigurationUrl, getVercelConfigurationUrl } from 'lib/integration-utils'
import Integration from './Integration'
import SidePanelGitHubRepoLinker from './SidePanelGitHubRepoLinker'
import SidePanelVercelProjectLinker from './SidePanelVercelProjectLinker'
const IntegrationSettings = () => {
- const org = useSelectedOrganization()
- const { data } = useOrgIntegrationsQuery({ orgSlug: org?.slug })
+ const { slug } = useParams()
+ const { data } = useOrgIntegrationsQuery({ orgSlug: slug })
const vercelIntegrations = data
?.filter((integration) => integration.integration.name === 'Vercel')
@@ -40,11 +45,56 @@ const IntegrationSettings = () => {
)
const vercelProjectCount = vercelProjectsData?.length ?? 0
+ const [addPanelOpen, setAddPanelOpen] = useState<undefined | 'VERCEL' | 'GITHUB'>(undefined)
+ const [addPanelIntegrationId, setAddPanelIntegrationId] = useState<string | undefined>(undefined)
+
+ const onAddVercelConnection = useCallback((integrationId: string) => {
+ setAddPanelIntegrationId(integrationId)
+ setAddPanelOpen('VERCEL')
+ }, [])
+
+ const onAddGitHubConnection = useCallback((integrationId: string) => {
+ setAddPanelIntegrationId(integrationId)
+ setAddPanelOpen('GITHUB')
+ }, [])
+
+ const onCloseAddPanel = useCallback(() => {
+ setAddPanelOpen(undefined)
+ setAddPanelIntegrationId(undefined)
+ }, [])
+
+ const { mutateAsync: deleteVercelConnection } =
+ useIntegrationsVercelInstalledConnectionDeleteMutation()
+
+ const onDeleteVercelConnection = useCallback(
+ async (connection: IntegrationProjectConnection) => {
+ await deleteVercelConnection({
+ id: connection.id,
+ organization_integration_id: connection.organization_integration_id,
+ orgSlug: slug,
+ })
+ },
+ [deleteVercelConnection, slug]
+ )
+
+ const { mutateAsync: deleteGitHubConnection } =
+ useIntegrationsGitHubInstalledConnectionDeleteMutation()
+
+ const onDeleteGitHubConnection = useCallback(
+ async (connection: IntegrationProjectConnection) => {
+ await deleteGitHubConnection({
+ connectionId: connection.id,
+ integrationId: connection.organization_integration_id,
+ orgSlug: slug,
+ })
+ },
+ [deleteGitHubConnection, slug]
+ )
+
return (
<>
<Integration
title="Vercel"
- orgName={org?.name}
detail={`
## Vercel Integration
@@ -67,11 +117,13 @@ You can change the scope of the access for Supabase by configuring [here](${getV
: undefined
}
integrations={vercelIntegrations}
+ getManageUrl={getVercelConfigurationUrl}
+ onAddConnection={onAddVercelConnection}
+ onDeleteConnection={onDeleteVercelConnection}
/>
<ScaffoldDivider />
<Integration
title="GitHub"
- orgName={org?.name}
detail={`
## GitHub Connections
@@ -86,9 +138,20 @@ The GitHub app will watch for changes in your repository such as file changes, b
These connections will be part of a GitHub workflow that is currently in development.
`}
integrations={githubIntegrations}
+ getManageUrl={getGitHubConfigurationUrl}
+ onAddConnection={onAddGitHubConnection}
+ onDeleteConnection={onDeleteGitHubConnection}
+ />
+ <SidePanelVercelProjectLinker
+ isOpen={addPanelOpen === 'VERCEL'}
+ organizationIntegrationId={addPanelIntegrationId}
+ onClose={onCloseAddPanel}
+ />
+ <SidePanelGitHubRepoLinker
+ isOpen={addPanelOpen === 'GITHUB'}
+ organizationIntegrationId={addPanelIntegrationId}
+ onClose={onCloseAddPanel}
/>
- <SidePanelVercelProjectLinker />
- <SidePanelGitHubRepoLinker />
</>
)
}
diff --git a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx
index 4ff69b1585e..48b4fc77db7 100644
--- a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx
+++ b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx
@@ -1,4 +1,4 @@
-import { useCallback, useMemo } from 'react'
+import { useMemo } from 'react'
import ProjectLinker from 'components/interfaces/Integrations/ProjectLinker'
import { Markdown } from 'components/interfaces/Markdown'
@@ -8,7 +8,6 @@ import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-or
import { useProjectsQuery } from 'data/projects/projects-query'
import { useSelectedOrganization } from 'hooks'
import { EMPTY_ARR } from 'lib/void'
-import { useGithubConnectionConfigPanelSnapshot } from 'state/github-connection-config-panel'
import { SidePanel } from 'ui'
const GITHUB_ICON = (
@@ -22,7 +21,17 @@ const GITHUB_ICON = (
</svg>
)
-const SidePanelGitHubRepoLinker = () => {
+export type SidePanelGitHubRepoLinkerProps = {
+ isOpen?: boolean
+ onClose?: () => void
+ organizationIntegrationId?: string
+}
+
+const SidePanelGitHubRepoLinker = ({
+ isOpen = false,
+ onClose,
+ organizationIntegrationId,
+}: SidePanelGitHubRepoLinkerProps) => {
const selectedOrganization = useSelectedOrganization()
const { data: integrationData } = useOrgIntegrationsQuery({
@@ -32,19 +41,12 @@ const SidePanelGitHubRepoLinker = () => {
(integration) => integration.integration.name === 'GitHub'
) // github
- const snapshot = useGithubConnectionConfigPanelSnapshot()
-
/**
* Find the right integration
*
* we use the snapshot.organizationIntegrationId which should be set whenever this sidepanel is opened
*/
- const selectedIntegration = githubIntegrations?.find(
- (x) => x.id === snapshot.organizationIntegrationId
- )
-
- const organizationIntegrationId = snapshot.organizationIntegrationId
- const open = snapshot.open
+ const selectedIntegration = githubIntegrations?.find((x) => x.id === organizationIntegrationId)
/**
* Supabase projects available
@@ -81,24 +83,17 @@ const SidePanelGitHubRepoLinker = () => {
const { mutate: createConnections, isLoading: isCreatingConnection } =
useIntegrationGitHubConnectionsCreateMutation({
onSuccess() {
- snapshot.setOpen(false)
+ onClose?.()
},
})
- const onCreateConnections = useCallback(
- (vars) => {
- createConnections(vars)
- },
- [createConnections]
- )
-
return (
<SidePanel
header={'Add GitHub repository'}
size="large"
- visible={open}
+ visible={isOpen}
hideFooter
- onCancel={() => snapshot.setOpen(false)}
+ onCancel={() => onClose?.()}
>
<div className="py-10 flex flex-col gap-6 bg-body h-full">
<SidePanel.Content>
@@ -115,7 +110,7 @@ Check the details below before proceeding
organizationIntegrationId={selectedIntegration?.id}
foreignProjects={githubRepos}
supabaseProjects={supabaseProjects}
- onCreateConnections={onCreateConnections}
+ onCreateConnections={createConnections}
installedConnections={selectedIntegration?.connections}
isLoading={isCreatingConnection}
integrationIcon={GITHUB_ICON}
diff --git a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx
index e3ac21e5850..f2b092bf758 100644
--- a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx
+++ b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx
@@ -12,7 +12,6 @@ import { useProjectsQuery } from 'data/projects/projects-query'
import { useSelectedOrganization } from 'hooks'
import { BASE_PATH } from 'lib/constants'
import { EMPTY_ARR } from 'lib/void'
-import { useGithubConnectionConfigPanelSnapshot } from 'state/github-connection-config-panel'
import { SidePanel } from 'ui'
const VERCEL_ICON = (
@@ -21,7 +20,17 @@ const VERCEL_ICON = (
</svg>
)
-const SidePanelVercelProjectLinker = () => {
+export type SidePanelVercelProjectLinkerProps = {
+ isOpen?: boolean
+ onClose?: () => void
+ organizationIntegrationId?: string
+}
+
+const SidePanelVercelProjectLinker = ({
+ isOpen = false,
+ onClose,
+ organizationIntegrationId,
+}: SidePanelVercelProjectLinkerProps) => {
const selectedOrganization = useSelectedOrganization()
const { data: integrationData } = useOrgIntegrationsQuery({
@@ -31,19 +40,12 @@ const SidePanelVercelProjectLinker = () => {
(integration) => integration.integration.name === 'Vercel'
) // vercel
- const snapshot = useGithubConnectionConfigPanelSnapshot()
-
/**
* Find the right integration
*
* we use the snapshot.organizationIntegrationId which should be set whenever this sidepanel is opened
*/
- const selectedIntegration = vercelIntegrations?.find(
- (x) => x.id === snapshot.organizationIntegrationId
- )
-
- const organizationIntegrationId = snapshot.organizationIntegrationId
- const open = snapshot.open
+ const selectedIntegration = vercelIntegrations?.find((x) => x.id === organizationIntegrationId)
/**
* Supabase projects available
@@ -92,7 +94,7 @@ const SidePanelVercelProjectLinker = () => {
const { mutate: createConnections, isLoading: isCreatingConnection } =
useIntegrationVercelConnectionsCreateMutation({
onSuccess() {
- snapshot.setOpen(false)
+ onClose?.()
},
})
@@ -120,9 +122,9 @@ const SidePanelVercelProjectLinker = () => {
<SidePanel
header={'Add GitHub repository'}
size="large"
- visible={open}
+ visible={isOpen}
hideFooter
- onCancel={() => snapshot.setOpen(false)}
+ onCancel={() => onClose?.()}
>
<div className="py-10 flex flex-col gap-6 bg-body h-full">
<SidePanel.Content>
diff --git a/studio/data/integrations/integrations-github-connection-delete-mutation.ts b/studio/data/integrations/integrations-github-connection-delete-mutation.ts
new file mode 100644
index 00000000000..f61d2495a13
--- /dev/null
+++ b/studio/data/integrations/integrations-github-connection-delete-mutation.ts
@@ -0,0 +1,46 @@
+import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
+
+import { del } from 'data/fetchers'
+import { integrationKeys } from './keys'
+
+type DeleteVariables = {
+ connectionId: string
+
+ integrationId: string
+ orgSlug: string | undefined
+}
+
+export async function deleteConnection({ connectionId }: DeleteVariables, signal?: AbortSignal) {
+ const { data, error } = await del('/platform/integrations/github/connections/{connection_id}', {
+ params: { path: { connection_id: connectionId } },
+ })
+ if (error) throw error
+
+ return data
+}
+
+type DeleteContentData = Awaited<ReturnType<typeof deleteConnection>>
+
+export const useIntegrationsGitHubInstalledConnectionDeleteMutation = ({
+ onSuccess,
+ ...options
+}: Omit<UseMutationOptions<DeleteContentData, unknown, DeleteVariables>, 'mutationFn'> = {}) => {
+ const queryClient = useQueryClient()
+ return useMutation<DeleteContentData, unknown, DeleteVariables>(
+ (args) => deleteConnection(args),
+ {
+ async onSuccess(data, variables, context) {
+ await Promise.all([
+ queryClient.invalidateQueries(integrationKeys.integrationsList()),
+ queryClient.invalidateQueries(integrationKeys.integrationsListWithOrg(variables.orgSlug)),
+ queryClient.invalidateQueries(integrationKeys.githubRepoList(variables.integrationId)),
+ queryClient.invalidateQueries(
+ integrationKeys.githubConnectionsList(variables.integrationId)
+ ),
+ ])
+ await onSuccess?.(data, variables, context)
+ },
+ ...options,
+ }
+ )
+}
diff --git a/studio/data/integrations/integrations-vercel-installed-connection-delete-mutation.ts b/studio/data/integrations/integrations-vercel-installed-connection-delete-mutation.ts
index 58ab5c10fee..41c65d99018 100644
--- a/studio/data/integrations/integrations-vercel-installed-connection-delete-mutation.ts
+++ b/studio/data/integrations/integrations-vercel-installed-connection-delete-mutation.ts
@@ -39,7 +39,6 @@ export const useIntegrationsVercelInstalledConnectionDeleteMutation = ({
(args) => deleteConnection(args),
{
async onSuccess(data, variables, context) {
- console.log('variables in mutate delete onSuccess', variables)
await Promise.all([
queryClient.invalidateQueries(integrationKeys.integrationsList()),
queryClient.invalidateQueries(integrationKeys.integrationsListWithOrg(variables.orgSlug)),
diff --git a/studio/lib/integration-utils.ts b/studio/lib/integration-utils.ts
index b16b53efdfc..278cc5b93da 100644
--- a/studio/lib/integration-utils.ts
+++ b/studio/lib/integration-utils.ts
@@ -122,3 +122,11 @@ export function getVercelConfigurationUrl(integration: Integration) {
: ''
}integrations/${integration.metadata?.configuration_id}`
}
+
+export function getGitHubConfigurationUrl(integration: Integration) {
+ return `https://github.com/${
+ integration.metadata?.account.type === 'Organization'
+ ? `organizations/${integration.metadata?.account.name}/`
+ : ''
+ }settings/installations/${integration.metadata.installation_id}`
+}
diff --git a/studio/pages/integrations/github/[integrationId]/choose-project.tsx b/studio/pages/integrations/github/[integrationId]/choose-project.tsx
index dc1d7545f93..c49ed89439c 100644
--- a/studio/pages/integrations/github/[integrationId]/choose-project.tsx
+++ b/studio/pages/integrations/github/[integrationId]/choose-project.tsx
@@ -84,9 +84,7 @@ This Supabase integration will allow you to link a Supabase project to a GitHub
organizationIntegrationId={integration?.id}
foreignProjects={repos ?? EMPTY_ARR}
supabaseProjects={projects}
- onCreateConnections={(vars) => {
- createConnections(vars)
- }}
+ onCreateConnections={createConnections}
installedConnections={integration?.connections}
isLoading={isCreatingConnection}
integrationIcon={GITHUB_ICON}
diff --git a/studio/pages/integrations/github/install.tsx b/studio/pages/integrations/github/install.tsx
index 1d0637d223f..08987421df3 100644
--- a/studio/pages/integrations/github/install.tsx
+++ b/studio/pages/integrations/github/install.tsx
@@ -97,7 +97,9 @@ const GitHubIntegration: NextPageWithLayout = () => {
function onInstall() {
const orgSlug = selectedOrg?.slug
- const installedIntegration = integrationData?.find((x) => x.organization.slug === orgSlug)
+ const installedIntegration = integrationData?.find(
+ (x) => x.organization.slug === orgSlug && x.metadata?.installation_id === installationId
+ )
const isIntegrationInstalled = Boolean(installedIntegration)
if (!orgSlug) {
diff --git a/studio/pages/integrations/vercel/install.tsx b/studio/pages/integrations/vercel/install.tsx
index 67016004b90..0ef60b6f003 100644
--- a/studio/pages/integrations/vercel/install.tsx
+++ b/studio/pages/integrations/vercel/install.tsx
@@ -9,7 +9,6 @@ import { useOrganizationsQuery } from 'data/organizations/organizations-query'
import { useStore } from 'hooks'
import { useRouter } from 'next/router'
import { useState } from 'react'
-import { useVercelIntegrationInstallationState } from 'state/vercel-integration-installation'
import { NextPageWithLayout, Organization } from 'types'
import { Alert, Badge, Button, IconBook, IconHexagon, IconLifeBuoy, Listbox, LoadingLine } from 'ui'
@@ -33,14 +32,10 @@ export type VercelIntegrationFlow = 'deploy-button' | 'marketing'
const VercelIntegration: NextPageWithLayout = () => {
const router = useRouter()
const { ui } = useStore()
- const { code, configurationId, next, teamId, source, externalId } = useParams()
+ const { code, configurationId, teamId, source, externalId } = useParams()
const [selectedOrg, setSelectedOrg] = useState<Organization | null>(null)
const [organizationIntegrationId, setOrganizationIntegrationId] = useState<string | null>(null)
- const snapshot = useVercelIntegrationInstallationState()
-
- const flow: VercelIntegrationFlow = externalId ? 'marketing' : 'deploy-button'
-
/**
* Fetch the list of organization based integration installations for Vercel.
*
@@ -54,7 +49,6 @@ const VercelIntegration: NextPageWithLayout = () => {
const firstOrg = organizations?.[0]
if (firstOrg && selectedOrg === null) {
setSelectedOrg(firstOrg)
- snapshot.setSelectedOrganizationSlug(firstOrg.slug)
router.query.organizationSlug = firstOrg.slug
}
},
diff --git a/studio/state/github-connection-config-panel.ts b/studio/state/github-connection-config-panel.ts
deleted file mode 100644
index 78feb1a3615..00000000000
--- a/studio/state/github-connection-config-panel.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { proxy, snapshot, useSnapshot } from 'valtio'
-
-export const githubConnectionConfigPanelState = proxy({
- open: false as boolean,
- setOpen: (open: boolean) => {
- githubConnectionConfigPanelState.open = open
- },
- organizationIntegrationId: undefined as string | undefined,
- setOrganizationIntegrationId: (organizationIntegrationId: string) => {
- githubConnectionConfigPanelState.organizationIntegrationId = organizationIntegrationId
- },
-})
-
-export const getGithubConnectionConfigPanelSnapshot = () =>
- snapshot(githubConnectionConfigPanelState)
-
-export const useGithubConnectionConfigPanelSnapshot = (
- options?: Parameters<typeof useSnapshot>[1]
-) => useSnapshot(githubConnectionConfigPanelState, options)
diff --git a/studio/state/vercel-integration-installation.ts b/studio/state/vercel-integration-installation.ts
deleted file mode 100644
index 737879f6fe1..00000000000
--- a/studio/state/vercel-integration-installation.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { proxy, snapshot, useSnapshot } from 'valtio'
-
-export const vercelIntegrationInstallationState = proxy({
- selectedOrganizationSlug: '' as string,
- setSelectedOrganizationSlug: (selectedOrganizationSlug: string) => {
- vercelIntegrationInstallationState.selectedOrganizationSlug = selectedOrganizationSlug
- },
-})
-
-export const getVercelIntegrationInstallationState = () =>
- snapshot(vercelIntegrationInstallationState)
-
-export const useVercelIntegrationInstallationState = (
- options?: Parameters<typeof useSnapshot>[1]
-) => useSnapshot(vercelIntegrationInstallationState, options)