Skip to content

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

started moving all the integration UI stuff around

Jonathan Summers-Muir11cd7e684db7
diff --git a/packages/ui/build/css/source/global.css b/packages/ui/build/css/source/global.css
index 7116e19977a..52e14d357ee 100644
--- a/packages/ui/build/css/source/global.css
+++ b/packages/ui/build/css/source/global.css
@@ -1,6 +1,6 @@
/**
* Do not edit directly
- * Generated on Mon, 17 Jul 2023 15:59:23 GMT
+ * Generated on Tue, 01 Aug 2023 21:25:15 GMT
*/
:root {
diff --git a/packages/ui/build/css/themes/dark.css b/packages/ui/build/css/themes/dark.css
index 3748b607d97..3f33a0fe1b7 100644
--- a/packages/ui/build/css/themes/dark.css
+++ b/packages/ui/build/css/themes/dark.css
@@ -1,13 +1,15 @@
/**
* Do not edit directly
- * Generated on Mon, 17 Jul 2023 15:59:23 GMT
+ * Generated on Tue, 01 Aug 2023 21:25:15 GMT
*/
.dark {
--brand-default: 152.9deg 60% 52.9%;
- --brand-400: 153.6deg 41% 12%;
- --brand-300: 152.7deg 48.5% 26.7%;
- --brand-200: 148.5deg 43.5% 82%;
+ --brand-600: 153deg 59.5% 70%;
+ --brand-500: 153.5deg 61.8% 21.6%;
+ --brand-400: 153.3deg 65.2% 13.5%;
+ --brand-300: 153.8deg 69.6% 9%;
+ --brand-200: 152.5deg 75% 6.3%;
--warning-default: 38.9deg 100% 57.1%;
--warning-600: 38.9deg 89.8% 49.8%;
--warning-500: 34.8deg 90.9% 21.6%;
diff --git a/packages/ui/build/css/themes/light.css b/packages/ui/build/css/themes/light.css
index 41927d7bc60..490d97179d3 100644
--- a/packages/ui/build/css/themes/light.css
+++ b/packages/ui/build/css/themes/light.css
@@ -1,13 +1,15 @@
/**
* Do not edit directly
- * Generated on Mon, 17 Jul 2023 15:59:23 GMT
+ * Generated on Tue, 01 Aug 2023 21:25:15 GMT
*/
.light {
- --brand-primary: 152.9deg 60% 52.9%;
- --brand-400: 153.7deg 68.7% 83.7%;
- --brand-300: 153deg 46% 65.9%;
- --brand-200: 148.5deg 43.5% 82%;
+ --brand-default: 152.9deg 60% 52.9%;
+ --brand-600: 153.2deg 49.7% 33.5%;
+ --brand-500: 148.7deg 42.7% 69.2%;
+ --brand-400: 149.1deg 59.3% 88.4%;
+ --brand-300: 148.6deg 77.8% 94.7%;
+ --brand-200: 156deg 71.4% 98.6%;
--warning-default: 38.9deg 100% 57.1%;
--warning-600: 30.2deg 100% 33.9%;
--warning-500: 36.3deg 85.7% 67.1%;
diff --git a/packages/ui/build/css/tw-extend/color.js b/packages/ui/build/css/tw-extend/color.js
index e9a280e3825..937addc4752 100644
--- a/packages/ui/build/css/tw-extend/color.js
+++ b/packages/ui/build/css/tw-extend/color.js
@@ -529,15 +529,23 @@ module.exports = {
},
"brand-200": {
cssVariable: "var(--brand-200)",
- value: "hsl(148.5, 43.5%, 82%)"
+ value: "hsl(152.5, 75%, 6.3%)"
},
"brand-300": {
cssVariable: "var(--brand-300)",
- value: "hsl(152.70000000000005, 48.5%, 26.7%)"
+ value: "hsl(153.79999999999995, 69.6%, 9%)"
},
"brand-400": {
cssVariable: "var(--brand-400)",
- value: "hsl(153.60000000000002, 41%, 12%)"
+ value: "hsl(153.29999999999995, 65.2%, 13.5%)"
+},
+"brand-500": {
+ cssVariable: "var(--brand-500)",
+ value: "hsl(153.5, 61.8%, 21.6%)"
+},
+"brand-600": {
+ cssVariable: "var(--brand-600)",
+ value: "hsl(153, 59.5%, 70%)"
},
"brand-DEFAULT": {
cssVariable: "var(--brand-default)",
diff --git a/packages/ui/index.tsx b/packages/ui/index.tsx
index e53f54d332f..ab3cdaaf5fa 100644
--- a/packages/ui/index.tsx
+++ b/packages/ui/index.tsx
@@ -146,6 +146,10 @@ export {
AccordionContent as AccordionContent_Shadcn_,
} from './src/components/shadcn/ui/accordion'
+export { Input as Input_Shadcn_ } from './src/components/shadcn/ui/input'
+export { Switch as Switch } from './src/components/shadcn/ui/switch'
+export { Checkbox as Checkbox_Shadcn_ } from './src/components/shadcn/ui/checkbox'
+
// links
export * from './src/components/TextLink'
diff --git a/packages/ui/src/components/shadcn/ui/form.tsx b/packages/ui/src/components/shadcn/ui/form.tsx
index 9bc41202999..2f5d966df0a 100644
--- a/packages/ui/src/components/shadcn/ui/form.tsx
+++ b/packages/ui/src/components/shadcn/ui/form.tsx
@@ -128,7 +128,7 @@ const FormDescription = React.forwardRef<
<p
ref={ref}
id={formDescriptionId}
- className={cn('text-sm text-muted-foreground', className)}
+ className={cn('text-sm text-light', className)}
{...props}
/>
)
diff --git a/packages/ui/src/components/shadcn/ui/input.tsx b/packages/ui/src/components/shadcn/ui/input.tsx
index 3455be14a2b..a942c99abf9 100644
--- a/packages/ui/src/components/shadcn/ui/input.tsx
+++ b/packages/ui/src/components/shadcn/ui/input.tsx
@@ -1,6 +1,6 @@
import * as React from 'react'
-import { cn } from 'src/lib/utils'
+import { cn } from '@ui/lib/utils'
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
diff --git a/packages/ui/src/components/shadcn/ui/label.tsx b/packages/ui/src/components/shadcn/ui/label.tsx
index 001ae15c35e..b0363cca619 100644
--- a/packages/ui/src/components/shadcn/ui/label.tsx
+++ b/packages/ui/src/components/shadcn/ui/label.tsx
@@ -5,7 +5,7 @@ import { cva, type VariantProps } from 'class-variance-authority'
import { cn } from '@ui/lib/utils'
const labelVariants = cva(
- 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70'
+ 'text-sm text-light leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70'
)
const Label = React.forwardRef<
diff --git a/packages/ui/src/components/shadcn/ui/switch.tsx b/packages/ui/src/components/shadcn/ui/switch.tsx
index 144b58197fa..e5ca7f68467 100644
--- a/packages/ui/src/components/shadcn/ui/switch.tsx
+++ b/packages/ui/src/components/shadcn/ui/switch.tsx
@@ -11,7 +11,7 @@ const Switch = React.forwardRef<
>(({ className, ...props }, ref) => (
<SwitchPrimitives.Root
className={cn(
- 'peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
+ 'peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-brand data-[state=unchecked]:bg-control data-[state=unchecked]:hover:bg-border',
className
)}
{...props}
@@ -19,7 +19,7 @@ const Switch = React.forwardRef<
>
<SwitchPrimitives.Thumb
className={cn(
- 'pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0'
+ 'pointer-events-none block h-[18px] w-[18px] rounded-full bg-foreground-light data-[state=checked]:bg-foreground shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-[22px] data-[state=unchecked]:translate-x-[3px]'
)}
/>
</SwitchPrimitives.Root>
diff --git a/packages/ui/src/lib/tailwind-demo-classes.ts b/packages/ui/src/lib/tailwind-demo-classes.ts
index 8fd22a61deb..e9d0afb240a 100644
--- a/packages/ui/src/lib/tailwind-demo-classes.ts
+++ b/packages/ui/src/lib/tailwind-demo-classes.ts
@@ -41,6 +41,8 @@ export default {
"bg-brand-200",
"bg-brand-300",
"bg-brand-400",
+ "bg-brand-500",
+ "bg-brand-600",
"bg-brand"
],
"palletes": [
diff --git a/studio/components/interfaces/Integrations/IntegrationPanels.tsx b/studio/components/interfaces/Integrations/IntegrationPanels.tsx
index 26028c0a79f..df3117397fc 100644
--- a/studio/components/interfaces/Integrations/IntegrationPanels.tsx
+++ b/studio/components/interfaces/Integrations/IntegrationPanels.tsx
@@ -93,7 +93,7 @@ const IntegrationInstallation = React.forwardRef<HTMLLIElement, IntegrationInsta
</div>
<div className="flex flex-col gap-0">
<div className="flex items-center gap-2">
- <span className="text font-medium">
+ <span className="text text-sm font-medium">
{integration.metadata?.account.name ||
(integration.metadata !== undefined &&
'gitHubConnectionOwner' in integration.metadata &&
@@ -140,7 +140,7 @@ export interface IntegrationConnectionProps extends React.HTMLAttributes<HTMLLIE
const IntegrationConnection = React.forwardRef<HTMLLIElement, IntegrationConnectionProps>(
(
- { className, connection, type, actions, showNode = true, orientation = 'horizontal', ...props },
+ { connection, type, actions, showNode = true, orientation = 'horizontal', className, ...props },
ref
) => {
const { data: projects } = useProjectsQuery()
@@ -152,7 +152,7 @@ const IntegrationConnection = React.forwardRef<HTMLLIElement, IntegrationConnect
key={connection.id}
{...props}
className={cn(
- showNode && 'pl-8 ml-6 border-l border-scale-600 dark:border-scale-400',
+ showNode && 'pl-8 ml-6 border-l border-scale-600 dark:border-scale-400',
'pb-2',
'relative'
)}
@@ -165,7 +165,8 @@ const IntegrationConnection = React.forwardRef<HTMLLIElement, IntegrationConnect
orientation === 'horizontal'
? 'flex items-center justify-between'
: 'flex flex-col gap-3',
- 'bg-surface-100 border shadow-sm px-8 py-4 rounded-lg'
+ 'bg-surface-100 border shadow-sm px-8 py-4 rounded-lg',
+ className
)}
>
<div className={'flex flex-col gap-1'}>
@@ -222,10 +223,10 @@ const IntegrationConnectionOption = React.forwardRef<HTMLLIElement, IntegrationC
<div className="flex flex-col gap-1">
<div className="flex gap-2 items-center">
<HandleIcon type={'Supabase'} />
- <span>{project?.name}</span>
+ <span className="text-sm">{project?.name}</span>
<IconArrowRight size={14} className="text-scale-900" strokeWidth={1.5} />
<HandleIcon type={type} />
- <span>{connection.metadata.name}</span>
+ <span className="text-sm">{connection.metadata.name}</span>
</div>
<span className="text-lighter text-xs">
@@ -275,19 +276,23 @@ const EmptyIntegrationConnection = React.forwardRef<
interface IntegrationConnectionHeader extends React.HTMLAttributes<HTMLDivElement> {
name?: string
markdown?: string
+ showNode?: boolean
}
const IntegrationConnectionHeader = React.forwardRef<HTMLDivElement, IntegrationConnectionHeader>(
- ({ className, name, markdown = '', ...props }, ref) => {
+ ({ className, name, markdown = '', showNode = true, ...props }, ref) => {
return (
<div
{...props}
ref={ref}
className={cn(
- 'border-l border-scale-600 dark:border-scale-400 ml-6 pl-8 pt-6 pb-3',
+ showNode && 'border-l border-scale-600 dark:border-scale-400 ml-6 pl-8',
+ 'pt-6 pb-3',
+ 'prose text-sm',
className
)}
>
+ {props.title && <h5 className="text">{props.title}</h5>}
<Markdown content={markdown} className="" />
</div>
)
diff --git a/studio/components/interfaces/Markdown.tsx b/studio/components/interfaces/Markdown.tsx
index 8aff7074cd5..baed3111240 100644
--- a/studio/components/interfaces/Markdown.tsx
+++ b/studio/components/interfaces/Markdown.tsx
@@ -7,7 +7,7 @@ interface Props extends Omit<ReactMarkdownProps, 'children' | 'node'> {
content: string
}
-const Markdown = ({ className, content, ...props }: Props) => {
+const Markdown = ({ className, content = '', ...props }: Props) => {
return (
<ReactMarkdown
components={{ h3: ({ children }) => <h3 className="mb-1">{children}</h3> }}
diff --git a/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx b/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx
deleted file mode 100644
index ffd8d671337..00000000000
--- a/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx
+++ /dev/null
@@ -1,180 +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 ConfirmationModal from 'components/ui/ConfirmationModal'
-import {
- IntegrationName,
- IntegrationProjectConnection,
- Integration as TIntegration,
-} from 'data/integrations/integrations.types'
-import { BASE_PATH } from 'lib/constants'
-import { pluralize } from 'lib/helpers'
-import { EMPTY_ARR } from 'lib/void'
-import { useCallback, useState } from 'react'
-import { Button, Dropdown, IconChevronDown, IconTrash, Modal } from 'ui'
-
-export interface IntegrationProps {
- title: string
- description?: string
- note?: string
- detail?: string
- integrations?: TIntegration[]
- onAddConnection: (integrationId: string) => void
- onDeleteConnection: (connection: IntegrationProjectConnection) => void | Promise<void>
-}
-
-const Integration = ({
- title,
- description,
- note,
- detail,
- integrations = EMPTY_ARR,
- onAddConnection,
- onDeleteConnection,
-}: IntegrationProps) => {
- const ConnectionHeading = ({ integration }: { integration: TIntegration }) => {
- return (
- <IntegrationConnectionHeader
- markdown={`### ${integration.connections.length} project ${pluralize(
- integration.connections.length,
- 'connection'
- )}
-Repository connections for ${title?.toLowerCase()}
- `}
- />
- )
- }
-
- return (
- <>
- <ScaffoldContainer>
- <ScaffoldSection>
- <ScaffoldSectionDetail>
- {detail && <Markdown content={detail} />}
- <img
- className="border rounded-lg shadow w-48 mt-6 border-body"
- src={`${BASE_PATH}/img/integrations/covers/${title.toLowerCase()}-cover.png?v=3`}
- alt="cover"
- />
- </ScaffoldSectionDetail>
- <ScaffoldSectionContent>
- <Markdown content={`${description}`} />
- <div className="flex flex-col gap-12">
- {integrations.length > 0 &&
- integrations.map((integration, i) => {
- return (
- <div key={integration.id}>
- <IntegrationInstallation title={title} integration={integration} />
-
- {integration.connections.length > 0 ? (
- <>
- <ConnectionHeading integration={integration} />
-
- <ul className="flex flex-col">
- {integration.connections.map((connection) => (
- <IntegrationConnectionItem
- key={connection.id}
- connection={connection}
- type={title as IntegrationName}
- onDeleteConnection={onDeleteConnection}
- />
- ))}
- </ul>
- </>
- ) : (
- <ConnectionHeading integration={integration} />
- )}
- <EmptyIntegrationConnection onClick={() => onAddConnection(integration.id)}>
- Add new project connection
- </EmptyIntegrationConnection>
- </div>
- )
- })}
- </div>
- {note !== undefined && <Markdown content={note} className="text-scale-900" />}
- </ScaffoldSectionContent>
- </ScaffoldSection>
- </ScaffoldContainer>
- </>
- )
-}
-
-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-light">
- {`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 a0be0c4b15c..57be7929850 100644
--- a/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
+++ b/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
@@ -1,20 +1,45 @@
import { useCallback, useState } from 'react'
-
-import { useParams } from 'common'
-import { ScaffoldDivider } from 'components/layouts/Scaffold'
+import {
+ ScaffoldContainer,
+ ScaffoldDivider,
+ ScaffoldSectionContent,
+ ScaffoldSection,
+ ScaffoldSectionDetail,
+} 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 { IntegrationProjectConnection } from 'data/integrations/integrations.types'
+import { IntegrationName, IntegrationProjectConnection } from 'data/integrations/integrations.types'
import { getIntegrationConfigurationUrl } from 'lib/integration-utils'
-import Integration from './Integration'
+import { IntegrationConnectionItem } from './OrganizationIntegration'
import SidePanelGitHubRepoLinker from './SidePanelGitHubRepoLinker'
import SidePanelVercelProjectLinker from './SidePanelVercelProjectLinker'
+import { useSelectedOrganization } from 'hooks'
+import { useSidePanelsStateSnapshot } from 'state/side-panels'
+import { Markdown } from 'components/interfaces/Markdown'
+import { BASE_PATH } from 'lib/constants'
+import {
+ EmptyIntegrationConnection,
+ IntegrationConnectionHeader,
+ IntegrationInstallation,
+} from 'components/interfaces/Integrations/IntegrationPanels'
+import { pluralize } from 'lib/helpers'
+
+const IntegrationImageHandler = ({ title }: { title: 'vercel' | 'github' }) => {
+ return (
+ <img
+ className="border rounded-lg shadow w-48 mt-6 border-body"
+ src={`${BASE_PATH}/img/integrations/covers/${title}-cover.png`}
+ alt={`${title} cover`}
+ />
+ )
+}
const IntegrationSettings = () => {
- const { slug } = useParams()
- const { data } = useOrgIntegrationsQuery({ orgSlug: slug })
+ const org = useSelectedOrganization()
+ const { data } = useOrgIntegrationsQuery({ orgSlug: org?.slug })
+ const sidePanelsStateSnapshot = useSidePanelsStateSnapshot()
const vercelIntegrations = data
?.filter((integration) => integration.integration.name === 'Vercel')
@@ -30,6 +55,7 @@ const IntegrationSettings = () => {
return integration
})
+
const githubIntegrations = data?.filter(
(integration) => integration.integration.name === 'GitHub'
)
@@ -45,23 +71,21 @@ 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 onAddVercelConnection = useCallback(
+ (integrationId: string) => {
+ sidePanelsStateSnapshot.setVercelConnectionsIntegrationId(integrationId)
+ sidePanelsStateSnapshot.setVercelConnectionsOpen(true)
+ },
+ [sidePanelsStateSnapshot]
+ )
- const onCloseAddPanel = useCallback(() => {
- setAddPanelOpen(undefined)
- setAddPanelIntegrationId(undefined)
- }, [])
+ const onAddGitHubConnection = useCallback(
+ (integrationId: string) => {
+ sidePanelsStateSnapshot.setGithubConnectionsIntegrationId(integrationId)
+ sidePanelsStateSnapshot.setGithubConnectionsOpen(true)
+ },
+ [sidePanelsStateSnapshot]
+ )
const { mutateAsync: deleteVercelConnection } =
useIntegrationsVercelInstalledConnectionDeleteMutation()
@@ -71,10 +95,10 @@ const IntegrationSettings = () => {
await deleteVercelConnection({
id: connection.id,
organization_integration_id: connection.organization_integration_id,
- orgSlug: slug,
+ orgSlug: org?.slug,
})
},
- [deleteVercelConnection, slug]
+ [deleteVercelConnection, org?.slug]
)
const { mutateAsync: deleteGitHubConnection } =
@@ -85,71 +109,182 @@ const IntegrationSettings = () => {
await deleteGitHubConnection({
connectionId: connection.id,
integrationId: connection.organization_integration_id,
- orgSlug: slug,
+ orgSlug: org?.slug,
})
},
- [deleteGitHubConnection, slug]
+ [deleteGitHubConnection, org?.slug]
)
- return (
- <>
- <Integration
- title="Vercel"
- detail={`
-## Vercel Integration
-
-Connect your Vercel teams to your Supabase organization.
-`}
- description={`
+ /**
+ * 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 the right 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.
-`}
- note={
- vercelProjectCount > 0 && vercelIntegration !== undefined
- ? `
+`
+
+ 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
- )}).
+You can change the scope of the access for Supabase by configuring
+[here](${getIntegrationConfigurationUrl(vercelIntegration)}).
`
- : undefined
- }
- integrations={vercelIntegrations}
- onAddConnection={onAddVercelConnection}
- onDeleteConnection={onDeleteVercelConnection}
- />
- <ScaffoldDivider />
- <Integration
- title="GitHub"
- detail={`
-## GitHub Connections
-
-Connect any of your GitHub repositories to a project.
-`}
- description={`
+ : ''
+
+ 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)}>
+ Add new project connection
+ </EmptyIntegrationConnection>
+ </div>
+ )
+ })}
+ {VercelContentSectionBottom && (
+ <Markdown content={VercelContentSectionBottom} className="text-lighter" />
+ )}
+ </ScaffoldSectionContent>
+ </ScaffoldSection>
+ </ScaffoldContainer>
+ )
+
+ /**
+ * GitHub markdown content
+ */
+
+ const GitHubTitle = `GitHub Connections`
+
+ const GitHubDetailsSection = `
+Connect any of your GitHub repositories to a project.
+`
+
+ const GitHubContentSectionTop = `
+
### How will GitHub connections work?
You will be able to connect a GitHub repository to a Supabase project.
The GitHub app will watch for changes in your repository such as file changes, branch changes as well as pull request activity.
These connections will be part of a GitHub workflow that is currently in development.
-`}
- integrations={githubIntegrations}
- onAddConnection={onAddGitHubConnection}
- onDeleteConnection={onDeleteGitHubConnection}
- />
- <SidePanelVercelProjectLinker
- isOpen={addPanelOpen === 'VERCEL'}
- organizationIntegrationId={addPanelIntegrationId}
- onClose={onCloseAddPanel}
- />
- <SidePanelGitHubRepoLinker
- isOpen={addPanelOpen === 'GITHUB'}
- organizationIntegrationId={addPanelIntegrationId}
- onClose={onCloseAddPanel}
- />
+`
+
+ const GitHubSection = () => (
+ <ScaffoldContainer>
+ <ScaffoldSection>
+ <ScaffoldSectionDetail title={GitHubTitle}>
+ <Markdown content={GitHubDetailsSection} />
+ <IntegrationImageHandler title="github" />
+ </ScaffoldSectionDetail>
+ <ScaffoldSectionContent>
+ <Markdown content={GitHubContentSectionTop} />
+ {githubIntegrations &&
+ githubIntegrations.length > 0 &&
+ githubIntegrations.map((integration, i) => {
+ const ConnectionHeaderTitle = `${integration.connections.length} project ${pluralize(
+ integration.connections.length,
+ 'connection'
+ )} `
+
+ return (
+ <div key={integration.id}>
+ <IntegrationInstallation title={'GitHub'} integration={integration} />
+ {integration.connections.length > 0 ? (
+ <>
+ <IntegrationConnectionHeader
+ title={ConnectionHeaderTitle}
+ markdown={`Repository connections for GitHub`}
+ />
+ <ul className="flex flex-col">
+ {integration.connections.map((connection) => (
+ <IntegrationConnectionItem
+ key={connection.id}
+ connection={connection}
+ type={'GitHub' as IntegrationName}
+ onDeleteConnection={onDeleteGitHubConnection}
+ />
+ ))}
+ </ul>
+ </>
+ ) : (
+ <IntegrationConnectionHeader
+ markdown={`### ${integration.connections.length} project ${pluralize(
+ integration.connections.length,
+ 'connection'
+ )} Repository connections for GitHub`}
+ />
+ )}
+ <EmptyIntegrationConnection onClick={() => onAddGitHubConnection(integration.id)}>
+ Add new project connection
+ </EmptyIntegrationConnection>
+ </div>
+ )
+ })}
+ </ScaffoldSectionContent>
+ </ScaffoldSection>
+ </ScaffoldContainer>
+ )
+
+ return (
+ <>
+ <VercelSection />
+ <ScaffoldDivider />
+ <GitHubSection />
+ <SidePanelVercelProjectLinker />
+ <SidePanelGitHubRepoLinker />
</>
)
}
diff --git a/studio/components/interfaces/Organization/IntegrationSettings/OrganizationIntegration.tsx b/studio/components/interfaces/Organization/IntegrationSettings/OrganizationIntegration.tsx
new file mode 100644
index 00000000000..b26d83cb017
--- /dev/null
+++ b/studio/components/interfaces/Organization/IntegrationSettings/OrganizationIntegration.tsx
@@ -0,0 +1,178 @@
+import {
+ EmptyIntegrationConnection,
+ IntegrationConnection,
+ IntegrationConnectionHeader,
+ IntegrationInstallation,
+ IntegrationConnectionProps,
+} from 'components/interfaces/Integrations/IntegrationPanels'
+import { Markdown } from 'components/interfaces/Markdown'
+import {
+ ScaffoldContainer,
+ ScaffoldSection,
+ ScaffoldSectionContent,
+ ScaffoldSectionDetail,
+} from 'components/layouts/Scaffold'
+import ConfirmationModal from 'components/ui/ConfirmationModal'
+import {
+ IntegrationName,
+ IntegrationProjectConnection,
+ Integration as TIntegration,
+} from 'data/integrations/integrations.types'
+import { BASE_PATH } from 'lib/constants'
+import { pluralize } from 'lib/helpers'
+import { EMPTY_ARR } from 'lib/void'
+import React, { forwardRef, useCallback, useState } from 'react'
+import { Button, Dropdown, IconChevronDown, IconTrash, Modal } from 'ui'
+
+export interface IntegrationProps {
+ title: string
+ description?: string
+ note?: string
+ detail?: string
+ integrations?: TIntegration[]
+ onAddConnection: (integrationId: string) => void
+ onDeleteConnection: (connection: IntegrationProjectConnection) => void | Promise<void>
+}
+
+// const OrganizationIntegration = ({
+// title,
+// description,
+// note,
+// detail,
+// integrations = EMPTY_ARR,
+// onAddConnection,
+// onDeleteConnection,
+// }: IntegrationProps) => {
+// const ConnectionHeading = ({ integration }: { integration: TIntegration }) => {
+// return (
+// <IntegrationConnectionHeader
+// markdown={`### ${integration.connections.length} project ${pluralize(
+// integration.connections.length,
+// 'connection'
+// )}
+// Repository connections for ${title?.toLowerCase()}
+// `}
+// />
+// )
+// }
+
+// return (
+// <>
+// <ScaffoldContainer>
+// <ScaffoldSection>
+// <ScaffoldSectionDetail>
+// {detail && <Markdown content={detail} />}
+// <img
+// className="border rounded-lg shadow w-48 mt-6 border-body"
+// src={`${BASE_PATH}/img/integrations/covers/${title.toLowerCase()}-cover.png?v=3`}
+// alt="cover"
+// />
+// </ScaffoldSectionDetail>
+// <ScaffoldSectionContent>
+// <Markdown content={`${description}`} />
+// <div className="flex flex-col gap-12">
+// {integrations.length > 0 &&
+// integrations.map((integration, i) => {
+// return (
+// <div key={integration.id}>
+// <IntegrationInstallation title={title} integration={integration} />
+
+// {integration.connections.length > 0 ? (
+// <>
+// <ConnectionHeading integration={integration} />
+
+// <ul className="flex flex-col">
+// {integration.connections.map((connection) => (
+// <IntegrationConnectionItem
+// key={connection.id}
+// connection={connection}
+// type={title as IntegrationName}
+// onDeleteConnection={onDeleteConnection}
+// />
+// ))}
+// </ul>
+// </>
+// ) : (
+// <ConnectionHeading integration={integration} />
+// )}
+// <EmptyIntegrationConnection onClick={() => onAddConnection(integration.id)}>
+// Add new project connection
+// </EmptyIntegrationConnection>
+// </div>
+// )
+// })}
+// </div>
+// {note !== undefined && <Markdown content={note} className="text-scale-900" />}
+// </ScaffoldSectionContent>
+// </ScaffoldSection>
+// </ScaffoldContainer>
+// </>
+// )
+// }
+
+interface IntegrationConnectionItemProps extends IntegrationConnectionProps {
+ onDeleteConnection: (connection: IntegrationProjectConnection) => void | Promise<void>
+}
+
+const IntegrationConnectionItem = React.forwardRef<HTMLLIElement, IntegrationConnectionItemProps>(
+ ({ onDeleteConnection, ...props }, ref) => {
+ const [isOpen, setIsOpen] = useState(false)
+
+ const onConfirm = useCallback(async () => {
+ try {
+ await onDeleteConnection(props.connection)
+ } finally {
+ setIsOpen(false)
+ }
+ }, [props.connection, onDeleteConnection])
+
+ const onCancel = useCallback(() => {
+ setIsOpen(false)
+ }, [])
+
+ return (
+ <>
+ <IntegrationConnection
+ ref={ref}
+ 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>
+ }
+ {...props}
+ />
+ <ConfirmationModal
+ visible={isOpen}
+ danger={true}
+ header="Confirm to delete"
+ buttonLabel="Delete"
+ onSelectCancel={onCancel}
+ onSelectConfirm={onConfirm}
+ >
+ <Modal.Content>
+ <p className="py-4 text-sm text-light">
+ {`This action cannot be undone. Are you sure you want to delete this connection?`}
+ </p>
+ </Modal.Content>
+ </ConfirmationModal>
+ </>
+ )
+ }
+)
+
+IntegrationConnectionItem.displayName = 'IntegrationConnectionItem'
+
+export { IntegrationConnectionItem }
diff --git a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx
index 82a5dd7cb25..e91fd21c683 100644
--- a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx
+++ b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx
@@ -11,6 +11,7 @@ import { EMPTY_ARR } from 'lib/void'
import { SidePanel } from 'ui'
import { useIntegrationsGitHubInstalledConnectionDeleteMutation } from 'data/integrations/integrations-github-connection-delete-mutation'
import { IntegrationConnectionsCreateVariables } from 'data/integrations/types'
+import { useSidePanelsStateSnapshot } from 'state/side-panels'
const GITHUB_ICON = (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 96" className="w-6">
@@ -24,19 +25,14 @@ const GITHUB_ICON = (
)
export type SidePanelGitHubRepoLinkerProps = {
- isOpen?: boolean
- onClose?: () => void
- organizationIntegrationId?: string
projectRef?: string
}
-const SidePanelGitHubRepoLinker = ({
- isOpen = false,
- onClose,
- organizationIntegrationId,
- projectRef,
-}: SidePanelGitHubRepoLinkerProps) => {
+const SidePanelGitHubRepoLinker = ({ projectRef }: SidePanelGitHubRepoLinkerProps) => {
const selectedOrganization = useSelectedOrganization()
+ const sidePanelStateSnapshot = useSidePanelsStateSnapshot()
+
+ const organizationIntegrationId = sidePanelStateSnapshot.githubConnectionsIntegrationId
const { data: integrationData } = useOrgIntegrationsQuery({
orgSlug: selectedOrganization?.slug,
@@ -90,7 +86,7 @@ const SidePanelGitHubRepoLinker = ({
const { mutate: createConnections, isLoading: isCreatingConnection } =
useIntegrationGitHubConnectionsCreateMutation({
onSuccess() {
- onClose?.()
+ sidePanelStateSnapshot.setGithubConnectionsOpen(false)
},
})
@@ -115,9 +111,9 @@ const SidePanelGitHubRepoLinker = ({
<SidePanel
header={'Add GitHub repository'}
size="large"
- visible={isOpen}
+ visible={sidePanelStateSnapshot.githubConnectionsOpen}
hideFooter
- onCancel={() => onClose?.()}
+ onCancel={() => sidePanelStateSnapshot.setGithubConnectionsOpen(false)}
>
<div className="py-10 flex flex-col gap-6 bg-body h-full">
<SidePanel.Content>
diff --git a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx
index f2b092bf758..eb1077aab2a 100644
--- a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx
+++ b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx
@@ -13,6 +13,7 @@ import { useSelectedOrganization } from 'hooks'
import { BASE_PATH } from 'lib/constants'
import { EMPTY_ARR } from 'lib/void'
import { SidePanel } from 'ui'
+import { useSidePanelsStateSnapshot } from 'state/side-panels'
const VERCEL_ICON = (
<svg xmlns="http://www.w3.org/2000/svg" fill="white" viewBox="0 0 512 512" className="w-6">
@@ -20,18 +21,10 @@ const VERCEL_ICON = (
</svg>
)
-export type SidePanelVercelProjectLinkerProps = {
- isOpen?: boolean
- onClose?: () => void
- organizationIntegrationId?: string
-}
-
-const SidePanelVercelProjectLinker = ({
- isOpen = false,
- onClose,
- organizationIntegrationId,
-}: SidePanelVercelProjectLinkerProps) => {
+const SidePanelVercelProjectLinker = () => {
const selectedOrganization = useSelectedOrganization()
+ const sidePanelStateSnapshot = useSidePanelsStateSnapshot()
+ const organizationIntegrationId = sidePanelStateSnapshot.vercelConnectionsIntegrationId
const { data: integrationData } = useOrgIntegrationsQuery({
orgSlug: selectedOrganization?.slug,
@@ -94,7 +87,7 @@ const SidePanelVercelProjectLinker = ({
const { mutate: createConnections, isLoading: isCreatingConnection } =
useIntegrationVercelConnectionsCreateMutation({
onSuccess() {
- onClose?.()
+ sidePanelStateSnapshot.setVercelConnectionsOpen(false)
},
})
@@ -122,9 +115,9 @@ const SidePanelVercelProjectLinker = ({
<SidePanel
header={'Add GitHub repository'}
size="large"
- visible={isOpen}
+ visible={sidePanelStateSnapshot.vercelConnectionsOpen}
hideFooter
- onCancel={() => onClose?.()}
+ onCancel={() => sidePanelStateSnapshot.setVercelConnectionsOpen(false)}
>
<div className="py-10 flex flex-col gap-6 bg-body h-full">
<SidePanel.Content>
diff --git a/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx b/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx
new file mode 100644
index 00000000000..554040f0314
--- /dev/null
+++ b/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx
@@ -0,0 +1,422 @@
+import { useCallback, useState } from 'react'
+import {
+ ScaffoldContainer,
+ ScaffoldDivider,
+ ScaffoldSectionContent,
+ ScaffoldSection,
+ ScaffoldSectionDetail,
+} 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 { getIntegrationConfigurationUrl } from 'lib/integration-utils'
+import { IntegrationConnectionItem } from './../../Organization/IntegrationSettings/OrganizationIntegration'
+import SidePanelGitHubRepoLinker from './../../Organization/IntegrationSettings/SidePanelGitHubRepoLinker'
+import SidePanelVercelProjectLinker from './../../Organization/IntegrationSettings/SidePanelVercelProjectLinker'
+import { useSelectedOrganization } from 'hooks'
+import { useSidePanelsStateSnapshot } from 'state/side-panels'
+import { Markdown } from 'components/interfaces/Markdown'
+import { BASE_PATH } from 'lib/constants'
+import {
+ EmptyIntegrationConnection,
+ IntegrationConnectionHeader,
+ IntegrationInstallation,
+} from 'components/interfaces/Integrations/IntegrationPanels'
+import { pluralize } from 'lib/helpers'
+import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
+import {
+ Button,
+ FormControl_Shadcn_,
+ FormDescription_Shadcn_,
+ FormField_Shadcn_,
+ FormItem_Shadcn_,
+ FormLabel_Shadcn_,
+ Form_Shadcn_,
+ Input,
+ Switch,
+ cn,
+} from 'ui'
+import * as z from 'zod'
+import { useForm } from 'react-hook-form'
+import { zodResolver } from '@hookform/resolvers/zod'
+
+const IntegrationImageHandler = ({ title }: { title: 'vercel' | 'github' }) => {
+ return (
+ <img
+ className="border rounded-lg shadow w-48 mt-6 border-body"
+ src={`${BASE_PATH}/img/integrations/covers/${title}-cover.png`}
+ alt={`${title} cover`}
+ />
+ )
+}
+
+const IntegrationSettings = () => {
+ const org = useSelectedOrganization()
+ const { data } = useOrgIntegrationsQuery({ orgSlug: org?.slug })
+ const sidePanelsStateSnapshot = useSidePanelsStateSnapshot()
+
+ const projectContext = useProjectContext()
+
+ const vercelIntegrations = 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
+ })
+
+ 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)
+ sidePanelsStateSnapshot.setGithubConnectionsOpen(true)
+ },
+ [sidePanelsStateSnapshot]
+ )
+
+ const { mutateAsync: deleteVercelConnection } =
+ useIntegrationsVercelInstalledConnectionDeleteMutation()
+
+ const onDeleteVercelConnection = useCallback(
+ async (connection: IntegrationProjectConnection) => {
+ await deleteVercelConnection({
+ id: connection.id,
+ organization_integration_id: connection.organization_integration_id,
+ orgSlug: org?.slug,
+ })
+ },
+ [deleteVercelConnection, org?.slug]
+ )
+
+ const { mutateAsync: deleteGitHubConnection } =
+ useIntegrationsGitHubInstalledConnectionDeleteMutation()
+
+ const onDeleteGitHubConnection = useCallback(
+ async (connection: IntegrationProjectConnection) => {
+ await deleteGitHubConnection({
+ connectionId: connection.id,
+ integrationId: connection.organization_integration_id,
+ orgSlug: org?.slug,
+ })
+ },
+ [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 the right 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 VercelSection = () => (
+ <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 === projectContext.project?.ref)
+ )
+ .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) => (
+ <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-3">
+ <div className="border-b border-l border-r rounded-b-md px-8 py-4">
+ <FormThing />
+
+ {/* <label className="text-sm text-light">Production branch</label>
+ <Input /> */}
+ </div>
+ </div>
+ </div>
+ ))}
+ </ul>
+ </>
+ ) : (
+ <IntegrationConnectionHeader
+ markdown={`### ${integration.connections.length} project ${pluralize(
+ integration.connections.length,
+ 'connection'
+ )} Repository connections for Vercel`}
+ />
+ )}
+ <EmptyIntegrationConnection
+ onClick={() => onAddVercelConnection(integration.id)}
+ >
+ Add new project connection
+ </EmptyIntegrationConnection>
+ </div>
+ )
+ })}
+ {VercelContentSectionBottom && (
+ <Markdown content={VercelContentSectionBottom} className="text-lighter" />
+ )}
+ </ScaffoldSectionContent>
+ </ScaffoldSection>
+ </ScaffoldContainer>
+ )
+
+ const FormThing = () => {
+ const FormSchema = z.object({
+ marketing_emails: z.boolean().default(false).optional(),
+ security_emails: z.boolean(),
+ })
+
+ const form = useForm<z.infer<typeof FormSchema>>({
+ resolver: zodResolver(FormSchema),
+ defaultValues: {
+ security_emails: true,
+ },
+ })
+
+ function onSubmit(data: z.infer<typeof FormSchema>) {
+ // toast({
+ // title: 'You submitted the following values:',
+ // description: (
+ // <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
+ // <code className="text-white">{JSON.stringify(data, null, 2)}</code>
+ // </pre>
+ // ),
+ // })
+ }
+
+ return (
+ <Form_Shadcn_ {...form}>
+ <form onSubmit={form.handleSubmit(onSubmit)} className="w-full space-y-6">
+ <div>
+ <div className="flex flex-col gap-6">
+ <FormField_Shadcn_
+ control={form.control}
+ name="marketing_emails"
+ render={({ field }) => (
+ <FormItem_Shadcn_ className="flex flex-row items-center justify-between">
+ <div className="">
+ <FormLabel_Shadcn_ className="!text">
+ Auto sync environment variables for Production
+ </FormLabel_Shadcn_>
+ <FormDescription_Shadcn_ className="text-xs">
+ Deploy Edge Functions when merged into Production Beanch
+ </FormDescription_Shadcn_>
+ </div>
+ <FormControl_Shadcn_>
+ <Switch checked={field.value} onCheckedChange={field.onChange} />
+ </FormControl_Shadcn_>
+ </FormItem_Shadcn_>
+ )}
+ />
+ <FormField_Shadcn_
+ control={form.control}
+ name="security_emails"
+ render={({ field }) => (
+ <FormItem_Shadcn_ className="flex flex-row items-center justify-between">
+ <div className="">
+ <FormLabel_Shadcn_ className="!text">
+ Auto sync enviroment variables for Database Preview Branches
+ </FormLabel_Shadcn_>
+ <FormDescription_Shadcn_ className="text-xs">
+ Deploy Edge Functions when merged into Production Beanch
+ </FormDescription_Shadcn_>
+ </div>
+ <FormControl_Shadcn_>
+ <Switch checked={field.value} onCheckedChange={field.onChange} />
+ </FormControl_Shadcn_>
+ </FormItem_Shadcn_>
+ )}
+ />
+ <FormField_Shadcn_
+ control={form.control}
+ name="security_emails"
+ render={({ field }) => (
+ <FormItem_Shadcn_ className="flex flex-row items-center justify-between">
+ <div className="">
+ <FormLabel_Shadcn_ className="!text">
+ Auto manage Supabase Auth redirect URIs
+ </FormLabel_Shadcn_>
+ <FormDescription_Shadcn_ className="text-xs">
+ Deploy Edge Functions when merged into Production Beanch
+ </FormDescription_Shadcn_>
+ </div>
+ <FormControl_Shadcn_>
+ <Switch checked={field.value} onCheckedChange={field.onChange} />
+ </FormControl_Shadcn_>
+ </FormItem_Shadcn_>
+ )}
+ />
+ </div>
+ </div>
+ {/* <Button htmlType="submit">Submit</Button> */}
+ </form>
+ </Form_Shadcn_>
+ )
+ }
+
+ /**
+ * GitHub markdown content
+ */
+
+ const GitHubTitle = `GitHub Connections`
+
+ const GitHubDetailsSection = `
+Connect any of your GitHub repositories to a project.
+`
+
+ const GitHubContentSectionTop = `
+
+### How will GitHub connections work?
+
+You will be able to connect a GitHub repository to a Supabase project.
+The GitHub app will watch for changes in your repository such as file changes, branch changes as well as pull request activity.
+
+These connections will be part of a GitHub workflow that is currently in development.
+`
+
+ const GitHubSection = () => (
+ <ScaffoldContainer>
+ <ScaffoldSection>
+ <ScaffoldSectionDetail title={GitHubTitle}>
+ <Markdown content={GitHubDetailsSection} />
+ <IntegrationImageHandler title="github" />
+ </ScaffoldSectionDetail>
+ <ScaffoldSectionContent>
+ <Markdown content={GitHubContentSectionTop} />
+ {githubIntegrations &&
+ githubIntegrations.length > 0 &&
+ githubIntegrations.map((integration, i) => {
+ const ConnectionHeaderTitle = `${integration.connections.length} project ${pluralize(
+ integration.connections.length,
+ 'connection'
+ )} `
+
+ return (
+ <div key={integration.id}>
+ <IntegrationInstallation title={'GitHub'} integration={integration} />
+ {integration.connections.length > 0 ? (
+ <>
+ <IntegrationConnectionHeader
+ title={ConnectionHeaderTitle}
+ markdown={`Repository connections for GitHub`}
+ />
+ <ul className="flex flex-col">
+ {integration.connections.map((connection) => (
+ <IntegrationConnectionItem
+ key={connection.id}
+ connection={connection}
+ type={'GitHub' as IntegrationName}
+ onDeleteConnection={onDeleteGitHubConnection}
+ />
+ ))}
+ </ul>
+ </>
+ ) : (
+ <IntegrationConnectionHeader
+ markdown={`### ${integration.connections.length} project ${pluralize(
+ integration.connections.length,
+ 'connection'
+ )} Repository connections for GitHub`}
+ />
+ )}
+ <EmptyIntegrationConnection onClick={() => onAddGitHubConnection(integration.id)}>
+ Add new project connection
+ </EmptyIntegrationConnection>
+ </div>
+ )
+ })}
+ </ScaffoldSectionContent>
+ </ScaffoldSection>
+ </ScaffoldContainer>
+ )
+
+ return (
+ <>
+ <VercelSection />
+ <ScaffoldDivider />
+ <GitHubSection />
+ <SidePanelVercelProjectLinker />
+ <SidePanelGitHubRepoLinker />
+ </>
+ )
+}
+
+export default IntegrationSettings
diff --git a/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.ts b/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.ts
index bf9ebf7cfaf..b97ed0be959 100644
--- a/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.ts
+++ b/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.ts
@@ -28,6 +28,12 @@ export const generateSettingsMenu = (
url: isProjectBuilding ? buildingUrl : `/project/${ref}/settings/infrastructure`,
items: [],
},
+ {
+ name: 'Integrations',
+ key: 'Integrations',
+ url: `/project/${ref}/settings/integrations`,
+ items: [],
+ },
{
name: 'Add Ons',
key: 'addons',
diff --git a/studio/components/layouts/Scaffold.tsx b/studio/components/layouts/Scaffold.tsx
index bcf1cfd9bd3..0ed8f43a859 100644
--- a/studio/components/layouts/Scaffold.tsx
+++ b/studio/components/layouts/Scaffold.tsx
@@ -62,8 +62,13 @@ const ScaffoldColumn = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTM
const ScaffoldSectionDetail = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
->(({ className, ...props }, ref) => {
- return <div ref={ref} {...props} className={cn('col-span-4 xl:col-span-5', className)} />
+>(({ className, children, title, ...props }, ref) => {
+ return (
+ <div ref={ref} {...props} className={cn('col-span-4 xl:col-span-5 prose text-sm', className)}>
+ <h2>{title}</h2>
+ {children}
+ </div>
+ )
})
const ScaffoldSectionContent = React.forwardRef<
diff --git a/studio/pages/project/[ref]/settings/integrations.tsx b/studio/pages/project/[ref]/settings/integrations.tsx
new file mode 100644
index 00000000000..03a074c5f88
--- /dev/null
+++ b/studio/pages/project/[ref]/settings/integrations.tsx
@@ -0,0 +1,11 @@
+import IntegrationSettings from 'components/interfaces/Settings/Integrations/IntegrationsSettings'
+import { SettingsLayout } from 'components/layouts'
+import { NextPageWithLayout } from 'types'
+
+const OrgIntegrationSettings: NextPageWithLayout = () => {
+ return <IntegrationSettings />
+}
+
+OrgIntegrationSettings.getLayout = (page) => <SettingsLayout>{page}</SettingsLayout>
+
+export default OrgIntegrationSettings
diff --git a/studio/state/side-panels.ts b/studio/state/side-panels.ts
new file mode 100644
index 00000000000..65fdbc61f70
--- /dev/null
+++ b/studio/state/side-panels.ts
@@ -0,0 +1,34 @@
+import { proxy, snapshot, useSnapshot } from 'valtio'
+
+export const sidePanelsState = proxy({
+ /**
+ * Vercel connections
+ */
+ vercelConnectionsOpen: false as boolean,
+ setVercelConnectionsOpen: (bool: boolean) => {
+ sidePanelsState.vercelConnectionsOpen = bool
+ },
+ // ID to determine which vercel integration installation to use
+ vercelConnectionsIntegrationId: '' as string,
+ setVercelConnectionsIntegrationId: (id: string) => {
+ sidePanelsState.vercelConnectionsIntegrationId = id
+ },
+
+ /**
+ * GitHub connections
+ */
+ githubConnectionsOpen: false as boolean,
+ setGithubConnectionsOpen: (bool: boolean) => {
+ sidePanelsState.githubConnectionsOpen = bool
+ },
+ // ID to determine which github integration installation to use
+ githubConnectionsIntegrationId: '' as string,
+ setGithubConnectionsIntegrationId: (id: string) => {
+ sidePanelsState.githubConnectionsIntegrationId = id
+ },
+})
+
+export const getSidePanelsState = () => snapshot(sidePanelsState)
+
+export const useSidePanelsStateSnapshot = (options?: Parameters<typeof useSnapshot>[1]) =>
+ useSnapshot(sidePanelsState, options)