Skip to content

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

Merge branch 'master' into feat/vercel-integration-v2

Alaister Younga8e24c7f539f
diff --cc packages/ui/src/components/Tabs/Tabs.tsx
index aba66a6dfea,67d389baecd..3466dc5d262
--- a/packages/ui/src/components/Tabs/Tabs.tsx
+++ b/packages/ui/src/components/Tabs/Tabs.tsx
@@@ -42,15 -37,12 +37,16 @@@ const Tabs: React.FC<TabsProps> & TabsS
addOnBefore,
addOnAfter,
listClassNames,
-- children,
++ children: _children,
}) => {
++ // toArray is used here to filter out invalid children
++ // another method would be to use React.Children.map
++ const children = React.Children.toArray(_children) as PanelPropsProps[]
++
const [activeTab, setActiveTab] = React.useState(
- defaultActiveId
- ? defaultActiveId
- : // if no defaultActiveId is set use the first panel
- children && children[0].props
- ? children[0].props.id
- : ''
+ defaultActiveId ??
+ // if no defaultActiveId is set use the first panel
+ children?.[0]?.props?.id
)
const router = useRouter()
@@@ -58,20 -50,25 +54,21 @@@
let __styles = styleHandler('tabs')
- // activeId state can be overriden externally with `active`
- // defaults to the first panelif we have one or url hash if not
- const active = activeId ? activeId : activeTab ? activeTab : hash
- if (children && !Array.isArray(children)) {
- children = [children]
- }
-
+ const tabIds = children.map((tab) => tab.props.id)
+
+ const { groupActiveId, setGroupActiveId } = useTabGroup(tabIds)
+
+ const active = activeId ?? groupActiveId ?? activeTab ?? hash
function onTabClick(id: string) {
- const newTabSelected = id !== active
setActiveTab(id)
- if (onClick) onClick(id)
- if (onChange && newTabSelected) onChange(id)
- }
+ setGroupActiveId?.(id)
- // for styling the tabs for underline style
- const underlined = type === 'underlined'
- // for styling the tabs for cards style
+ onClick?.(id)
+ if (id !== active) {
+ onChange?.(id)
+ }
+ }
const listClasses = [__styles[type].list]
if (scrollable) listClasses.push(__styles.scrollable)
diff --cc studio/components/interfaces/Integrations/IntegrationPanels.tsx
index fe875ec5a5c,00000000000..3103d61a147
mode 100644,000000..100644
--- a/studio/components/interfaces/Integrations/IntegrationPanels.tsx
+++ b/studio/components/interfaces/Integrations/IntegrationPanels.tsx
@@@ -1,260 -1,0 +1,258 @@@
- import { Markdown } from 'components/interfaces/Markdown'
- import { Integration, IntegrationProjectConnection } from 'data/integrations/integrations.types'
+import dayjs from 'dayjs'
- import { useStore } from 'hooks'
- import { BASE_PATH } from 'lib/constants'
+import Image from 'next/image'
-
+import React from 'react'
+
++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 { Badge, Button, IconArrowRight, IconGitHub, IconSquare, cn } from 'ui'
+
+const ICON_STROKE_WIDTH = 2
+const ICON_SIZE = 14
+
+export interface IntegrationInstallationProps extends React.RefAttributes<HTMLLIElement> {
+ title: string
+ integration: Integration
+}
+
+type HandleIconType = Integration['integration']['name'] | 'Supabase'
+
+const HandleIcon = ({ type }: { type: HandleIconType }) => {
+ switch (type) {
+ case 'GitHub':
+ return <IconGitHub strokeWidth={ICON_STROKE_WIDTH} size={ICON_SIZE} />
+ break
+ case 'Netlify':
+ return <IconSquare strokeWidth={ICON_STROKE_WIDTH} size={ICON_SIZE} />
+ break
+ case 'Vercel':
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="var(--colors-scale12)"
+ viewBox="0 0 512 512"
+ className="w-3.5"
+ >
+ <path fill-rule="evenodd" d="M256,48,496,464H16Z" />
+ </svg>
+ )
+
+ break
+ case 'Supabase':
+ return <img src={`${BASE_PATH}/img/supabase-logo.svg`} alt="Supabase" className="w-3.5"></img>
+ break
+
+ default:
+ return <></>
+ break
+ }
+}
+
+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"
+ />
+ </div>
+ )
+}
+
+const IntegrationInstallation = React.forwardRef<HTMLLIElement, IntegrationInstallationProps>(
+ ({ title, integration, ...props }, ref) => {
+ const IntegrationIconBlock = () => {
+ return (
+ <div className="bg-scale-100 w-8 h-8 rounded flex items-center justify-center">
+ <HandleIcon type={integration.integration.name} />
+ </div>
+ )
+ }
+
+ return (
+ <li
+ 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">
+ <div className="flex -space-x-1">
+ <IntegrationIconBlock />
+ <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 •{' '} */}
+ {integration.metadata?.account.name || integration.metadata?.gitHubConnectionOwner}
+ </span>
+
+ <Badge color="scale" className="capitalize">
+ {integration.metadata?.account.type}
+ </Badge>
+ </div>
+ <div className="flex gap-3 items-center">
+ <span className="text-scale-900 text-sm">
+ Created {dayjs(integration.inserted_at).fromNow()}
+ </span>
+ <span className="text-scale-900 text-sm">
+ Added by {integration?.added_by?.primary_email}
+ </span>
+ </div>
+ </div>
+ </div>
+
+ <Button type="default">Manage</Button>
+ </li>
+ )
+ }
+)
+
+export interface IntegrationConnectionProps extends React.HTMLAttributes<HTMLLIElement> {
+ connection: IntegrationProjectConnection
+ type: Integration['integration']['name']
+ actions?: React.ReactNode
+}
+
+const IntegrationConnection = React.forwardRef<HTMLLIElement, IntegrationConnectionProps>(
+ ({ className, connection, type, actions, ...props }, ref) => {
- const { app } = useStore()
-
- const { projects } = app
++ const { data: projects } = useProjectsQuery()
++ const project = projects?.find((project) => project.ref === connection.supabase_project_ref)
+
+ return (
+ <li
+ ref={ref}
+ key={connection.id}
+ {...props}
+ className={cn('ml-6 pl-8 pb-2 border-l', 'relative')}
+ >
+ <div className="absolute w-8 rounded-bl-full border-b border-l h-10 -left-px"></div>
+ <div className="bg border shadow-sm flex justify-between items-center px-8 py-4 rounded-lg">
+ <div className="flex flex-col gap-1">
+ <div className="flex gap-2 items-center">
+ <HandleIcon type={'Supabase'} />
- <span>{projects.byId(connection.supabase_project_ref)?.name}</span>
++ <span>{project?.name}</span>
+ <IconArrowRight size={14} className="text-scale-900" strokeWidth={1.5} />
+ {!connection?.metadata?.framework ? (
+ <HandleIcon type={type} />
+ ) : (
+ <img
+ src={`${BASE_PATH}/img/icons/frameworks/${connection.metadata.framework}.svg`}
+ width={21}
+ height={21}
+ alt={`icon`}
+ />
+ )}
+ <span>{connection.metadata?.name}</span>
+ </div>
+
+ <div className="flex gap-3 items-center">
+ <span className="text-scale-900 text-sm">
+ Connected {dayjs(connection?.inserted_at).fromNow()}
+ </span>
+ <span className="text-scale-900 text-sm">
+ Added by {connection?.added_by?.primary_email}
+ </span>
+ </div>
+ </div>
+
+ <div>{actions}</div>
+ </div>
+ </li>
+ )
+ }
+)
+
+const IntegrationConnectionOption = React.forwardRef<HTMLLIElement, IntegrationConnectionProps>(
+ ({ className, connection, type, ...props }, ref) => {
- const { app } = useStore()
++ const { data: projects } = useProjectsQuery()
++ const project = projects?.find((project) => project.ref === connection.supabase_project_ref)
+
- const { projects } = app
+ return (
+ <li
+ ref={ref}
+ key={connection.id}
+ {...props}
+ className={cn('bg border shadow-sm flex justify-between items-center px-8 py-4 rounded-lg')}
+ >
+ <div className="flex flex-col gap-1">
+ <div className="flex gap-2 items-center">
+ <HandleIcon type={'Supabase'} />
- <span>{projects.byId(connection.supabase_project_ref)?.name}</span>
++ <span>{project?.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.inserted_at).fromNow()}
+ </span>
+ </div>
+
+ <Button type="default">Connect</Button>
+ </li>
+ )
+ }
+)
+
+const EmptyIntegrationConnection = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => {
+ return (
+ <div
+ ref={ref}
+ {...props}
+ className={cn('ml-6 pl-8 pb-2 border-l', 'last:border-l-transparent', 'relative', className)}
+ >
+ <div className="absolute w-8 rounded-bl-full border-b border-l h-10 -left-px"></div>
+ <div
+ className={cn(
+ 'w-full',
+ 'border border-dashed',
+ '',
+ 'flex h-20 px-10 rounded-lg justify-center items-center'
+ )}
+ >
+ <Button type="default">Add new project connection</Button>
+ </div>
+ </div>
+ )
+})
+
+interface IntegrationConnectionHeader extends React.HTMLAttributes<HTMLDivElement> {
+ name?: string
+ markdown?: string
+}
+
+const IntegrationConnectionHeader = React.forwardRef<HTMLDivElement, IntegrationConnectionHeader>(
+ ({ className, name, markdown = '', ...props }, ref) => {
+ return (
+ <div {...props} ref={ref} className={cn('border-l ml-6 pl-8 pt-6 pb-3', className)}>
+ <Markdown content={markdown} className="" />
+ </div>
+ )
+ }
+)
+
+IntegrationInstallation.displayName = 'IntegrationInstallation'
+IntegrationConnection.displayName = 'IntegrationConnection'
+IntegrationConnectionHeader.displayName = 'IntegrationConnectionHeader'
+EmptyIntegrationConnection.displayName = 'EmptyIntegrationConnection'
+IntegrationConnectionOption.displayName = 'IntegrationConnectionOption'
+
+export {
+ EmptyIntegrationConnection,
+ IntegrationConnection,
+ IntegrationConnectionHeader,
+ IntegrationConnectionOption,
+ IntegrationInstallation,
+}
diff --cc studio/components/interfaces/Integrations/ProjectLinker.tsx
index 053f0a1ab2c,00000000000..900efeb8a6c
mode 100644,000000..100644
--- a/studio/components/interfaces/Integrations/ProjectLinker.tsx
+++ b/studio/components/interfaces/Integrations/ProjectLinker.tsx
@@@ -1,226 -1,0 +1,227 @@@
++import { useState } from 'react'
++
+import { ENV_VAR_RAW_KEYS } from 'components/interfaces/Integrations/Integrations-Vercel.constants'
+import { Markdown } from 'components/interfaces/Markdown'
+import { vercelIcon } from 'components/to-be-cleaned/ListIcons'
+import { useIntegrationConnectionsCreateMutation } from 'data/integrations/integration-connections-create-mutation'
- import { IntegrationProjectConnection } from 'data/integrations/integrations.types'
+import { VercelProjectsResponse } from 'data/integrations/integrations-vercel-projects-query'
- import { useStore } from 'hooks'
++import { IntegrationProjectConnection } from 'data/integrations/integrations.types'
++import { useSelectedOrganization } from 'hooks'
+import { BASE_PATH } from 'lib/constants'
- import { useState } from 'react'
+import { Button, Listbox, cn } from 'ui'
+
+interface Project {
+ id: string
+ name: string
+ ref: string
+}
+
+// to do: move this somewhere
+// const INTEGRATION_INTERNAL_ID = 1
+
+export interface ProjectLinkerProps {
+ organizationIntegrationId: string | undefined
+ foreignProjects: VercelProjectsResponse[]
+ supabaseProjects: Project[]
+ onCreateConnections?: () => void
+ installedConnections: IntegrationProjectConnection[] | undefined
+}
+
+const UNDEFINED_SELECT_VALUE = 'undefined'
+
+const ProjectLinker = ({
+ organizationIntegrationId,
+ foreignProjects,
+ supabaseProjects,
+ onCreateConnections: _onCreateConnections,
+ installedConnections = [],
+}: ProjectLinkerProps) => {
- const { ui } = useStore()
++ const selectedOrganization = useSelectedOrganization()
+
+ const [supabaseProjectRef, setSupabaseProjectRef] = useState(UNDEFINED_SELECT_VALUE)
+ const [vercelProjectId, setVercelProjectId] = useState(UNDEFINED_SELECT_VALUE)
+
+ const { mutate: createConnections, isLoading } = useIntegrationConnectionsCreateMutation({
+ onSuccess() {
+ _onCreateConnections?.()
+ },
+ })
+
+ function onCreateConnections() {
+ const projectDetails = foreignProjects.filter((x) => x.id === vercelProjectId)[0]
+
+ if (!organizationIntegrationId) {
+ console.error('No integration ID set')
+ return
+ }
+
+ createConnections({
+ organizationIntegrationId,
+ connection: {
+ foreign_project_id: vercelProjectId,
+ supabase_project_ref: supabaseProjectRef,
+ // integration_id: INTEGRATION_INTERNAL_ID,
+ metadata: {
+ ...projectDetails,
+ supabaseConfig: {
+ projectEnvVars: {
+ write: true,
+ },
+ },
+ },
+ },
- orgSlug: ui.selectedOrganization?.slug,
++ orgSlug: selectedOrganization?.slug,
+ })
+ }
+
+ const Panel = ({ children, className, ...props }: React.HTMLAttributes<HTMLDivElement>) => {
+ return (
+ <div
+ className={cn(
+ 'flex flex-col gap-6 px-5 mx-auto w-full justify-center items-center',
+ className
+ )}
+ {...props}
+ >
+ {children}
+ </div>
+ )
+ }
+
+ /**
+ * create a flat array of foreign project ids. ie, ["prj_MlkO6AiLG5ofS9ojKrkS3PhhlY3f", ..]
+ */
+ const flatInstalledConnectionsIds = installedConnections.map((x) => x.foreign_project_id)
+ /**
+ * check that vercel project is not already installed
+ */
+ const filteredForeignProjects: VercelProjectsResponse[] = foreignProjects.filter(
+ (foreignProject) => {
+ return !flatInstalledConnectionsIds.includes(foreignProject.id)
+ }
+ )
+
+ return (
+ <div className="flex flex-col gap-4">
+ <div className="relative border rounded-lg p-12 bg shadow-inner">
+ <div
+ className="absolute inset-0 bg-grid-black/5 [mask-image:linear-gradient(0deg,#fff,rgba(255,255,255,0.6))] dark:bg-grid-white/5 dark:[mask-image:linear-gradient(0deg,rgba(255,255,255,0.1),rgba(255,255,255,0.5))]"
+ style={{ backgroundPosition: '10px 10px' }}
+ ></div>
+ <div className="flex gap-0 w-full relative">
+ <Panel>
+ <div className="bg-white shadow border rounded p-1 w-12 h-12 flex justify-center items-center">
+ <img src={`${BASE_PATH}/img/supabase-logo.svg`} alt="Supabase" className="w-6" />
+ </div>
+ <Listbox
+ className="w-full"
+ value={supabaseProjectRef ?? UNDEFINED_SELECT_VALUE}
+ onChange={(e) => setSupabaseProjectRef(e)}
+ >
+ <Listbox.Option value={UNDEFINED_SELECT_VALUE} label="Choose a project" disabled>
+ Choose project
+ </Listbox.Option>
+ {supabaseProjects.map((project) => (
+ <Listbox.Option
+ key={project.id}
+ value={project.ref}
+ label={project.name}
+ addOnBefore={() => {
+ return (
+ <>
+ <div className="bg-white shadow border rounded p-1 w-6 h-6 flex justify-center items-center">
+ <img
+ src={`${BASE_PATH}/img/supabase-logo.svg`}
+ alt="Supabase"
+ className="w-4"
+ />
+ </div>
+ </>
+ )
+ }}
+ >
+ {project.name}
+ </Listbox.Option>
+ ))}
+ </Listbox>
+ </Panel>
+ <div className="border border-scale-1000 h-px w-16 border-dashed self-end mb-5"></div>
+ <Panel>
+ <div className="bg-black shadow rounded p-1 w-12 h-12 flex justify-center items-center">
+ {/* <img src="/img/icons/vercel.svg" style={{ height: 21 }} alt="integration icon" /> */}
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="var(--colors-scale12)"
+ viewBox="0 0 512 512"
+ className="w-6"
+ >
+ <path fill-rule="evenodd" d="M256,48,496,464H16Z" />
+ </svg>
+ </div>
+ <Listbox
+ className="w-full"
+ value={vercelProjectId ?? UNDEFINED_SELECT_VALUE}
+ onChange={(e) => setVercelProjectId(e)}
+ >
+ <Listbox.Option value={UNDEFINED_SELECT_VALUE} label="Choose a project" disabled>
+ Choose Vercel project
+ </Listbox.Option>
+ {filteredForeignProjects.map((project) => {
+ return (
+ <Listbox.Option
+ key={project.id}
+ value={project.id}
+ label={project.name}
+ addOnBefore={() => {
+ return (
+ <>
+ {!project?.framework ? (
+ vercelIcon
+ ) : (
+ <img
+ src={`${BASE_PATH}/img/icons/frameworks/${project.framework}.svg`}
+ width={21}
+ height={21}
+ alt={`icon`}
+ />
+ )}
+ </>
+ )
+ }}
+ >
+ {project.name}
+ </Listbox.Option>
+ )
+ })}
+ </Listbox>
+ </Panel>
+ </div>
+ </div>
+ <div className="flex w-full justify-end">
+ <Button
+ size="medium"
+ className="self-end"
+ onClick={onCreateConnections}
+ loading={isLoading}
+ disabled={isLoading}
+ >
+ Connect project
+ </Button>
+ </div>
+ <Markdown
+ content={`
+The following enviroment variables will be added:
+
+${ENV_VAR_RAW_KEYS.map((x, idx) => {
+ return `
+ \n
+ - \`${x}\` - ${(<span>This is the URL for the Project</span>)}
+`
+})}
+`}
+ />
+ </div>
+ )
+}
+
+export default ProjectLinker
diff --cc studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx
index 39b23288760,00000000000..84a8d2bdee5
mode 100644,000000..100644
--- a/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx
+++ b/studio/components/interfaces/Organization/IntegrationSettings/Integration.tsx
@@@ -1,171 -1,0 +1,173 @@@
+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.types'
+import { useIntegrationsVercelInstalledConnectionDeleteMutation } from 'data/integrations/integrations-vercel-installed-connection-delete-mutation'
- import { IntegrationProjectConnection } from 'data/integrations/integrations.types'
- import { useStore } from 'hooks'
++import {
++ 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, IconRefreshCcw, IconTrash } from 'ui'
+
+export interface IntegrationProps {
+ title: string
+ orgName?: string
+ description?: string
+ note?: string
+ detail?: string
+ integrations?: TIntegration[]
+}
+
+const Integration = ({
+ title,
+ orgName,
+ description,
+ note,
+ detail,
+ integrations = EMPTY_ARR,
+}: IntegrationProps) => {
+ const snapshot = useGithubConnectionConfigPanelSnapshot()
+
- const { ui } = useStore()
++ const selectedOrganization = useSelectedOrganization()
+
+ const { mutate: deleteMutate, isLoading: isDeleteLoading } =
+ useIntegrationsVercelInstalledConnectionDeleteMutation()
+
+ const ConnectionHeading = ({ integration }: { integration: TIntegration }) => {
+ return (
+ <IntegrationConnectionHeader
+ markdown={`### ${integration.connections.length} project ${pluralize(
+ integration.connections.length,
+ 'connection'
+ )}
+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: ui.selectedOrganization?.slug,
++ orgSlug: selectedOrganization?.slug,
+ }
+
+ deleteMutate(variables)
+ }
+
+ 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={i}>
+ <IntegrationInstallation title={title} key={i} integration={integration} />
+ {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={
+ <div>
+ <IconRefreshCcw size={14} />
+ </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>
+ }
+ />
+ )
+ )}
+ </ul>
+ </>
+ ) : (
+ <ConnectionHeading integration={integration} />
+ )}
+ <EmptyIntegrationConnection
+ onClick={() => {
+ snapshot.setOrganizationIntegrationId(integration.id)
+ snapshot.setOpen(true)
+ }}
+ >
+ Add new project connection
+ </EmptyIntegrationConnection>
+ </div>
+ )
+ })}
+ </div>
+ <Markdown content={`${note}`} className="text-scale-900" />
+ </ScaffoldSectionContent>
+ </ScaffoldSection>
+ </ScaffoldContainer>
+ </>
+ )
+}
+
+export default Integration
diff --cc studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
index 74d072b44a0,00000000000..4fc51f51cc6
mode 100644,000000..100644
--- a/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
+++ b/studio/components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx
@@@ -1,80 -1,0 +1,77 @@@
+import { ScaffoldDivider } from 'components/layouts/Scaffold'
+import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-org-only'
- import { useStore } from 'hooks'
- import { observer } from 'mobx-react-lite'
++import { useSelectedOrganization } from 'hooks'
+import Integration from './Integration'
+import SidePanelVercelProjectLinker from './SidePanelVercelProjectLinker'
+
+const IntegrationSettings = () => {
- const { ui } = useStore()
- const { data } = useOrgIntegrationsQuery({ orgSlug: ui.selectedOrganization?.slug })
-
- const org = ui.selectedOrganization
++ const org = useSelectedOrganization()
++ const { data } = useOrgIntegrationsQuery({ orgSlug: org?.slug })
+
+ const vercelIntegrations = data?.filter(
+ (integration) => integration.integration.name === 'Vercel'
+ ) // vercel
+ const githubIntegrations = data?.filter(
+ (integration) => integration.integration.name === 'GitHub'
+ ) // github
+
+ vercelIntegrations?.map((x) => {
+ let data: any = { ...x }
+
+ const avatarSrc = data.metadata.account.avatar
+ ? `https://vercel.com/api/www/avatar/${data.metadata.account.avatar}?s=48`
+ : `https://vercel.com/api/www/avatar?teamId=${data.metadata.account.team_id}&s=48`
+ data['metadata']['account']['avatar'] = avatarSrc
+
+ return data
+ })
+
+ return (
+ <>
+ <Integration
+ title="Vercel"
+ orgName={org?.name}
+ detail={`
+## Vercel Integration
+
+Connect your Vercel teams to your Supabase organization.
+`}
+ description={`
+### 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={`
+Your Vercel connection has access to 7 Vercel Projects.
+You can change the scope of the access for Supabase by configuring here.
+`}
+ integrations={vercelIntegrations}
+ />
+ <ScaffoldDivider />
+ <Integration
+ title="GitHub"
+ orgName={org?.name}
+ detail={`
+## GitHub Connections
+
+Conect any of your GitHub repositories to a project.
+`}
+ description={`
+### How do GitHub connections 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={`
+Your Vercel connection has access to 7 Vercel Projects.
+You can change the scope of the access for Supabase by configuring here.
+`}
+ integrations={githubIntegrations}
+ />
+ <SidePanelVercelProjectLinker />
+ </>
+ )
+}
+
- export default observer(IntegrationSettings)
++export default IntegrationSettings
diff --cc studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx
index 606857d6f5f,00000000000..cfebb6acff0
mode 100644,000000..100644
--- a/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx
+++ b/studio/components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx
@@@ -1,115 -1,0 +1,110 @@@
- 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'
+import { useProjectsQuery } from 'data/projects/projects-query'
- import { useStore } from 'hooks'
++import { useSelectedOrganization } from 'hooks'
+import { EMPTY_ARR } from 'lib/void'
- import { observer } from 'mobx-react-lite'
+import { useMemo } from 'react'
+import { useGithubConnectionConfigPanelSnapshot } from 'state/github-connection-config-panel'
+import { SidePanel } from 'ui'
+
+const SidePanelVercelProjectLinker = () => {
- const { ui } = useStore()
-
- const selectedOrg = ui.selectedOrganization
++ const selectedOrganization = useSelectedOrganization()
+
+ const { data: integrationData } = useOrgIntegrationsQuery({
- orgSlug: ui.selectedOrganization?.slug,
++ orgSlug: selectedOrganization?.slug,
+ })
+ const vercelIntegrations = integrationData?.filter(
+ (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
+
+ /**
+ * Supabase projects available
+ */
+ const { data: supabaseProjectsData } = useProjectsQuery({
+ enabled: organizationIntegrationId !== null,
+ })
+
+ const supabaseProjects = useMemo(
+ () =>
+ supabaseProjectsData
- ?.filter((project) => project.organization_id === selectedOrg?.id)
++ ?.filter((project) => project.organization_id === selectedOrganization?.id)
+ .map((project) => ({ id: project.id.toString(), name: project.name, ref: project.ref })) ??
+ EMPTY_ARR,
- [selectedOrg?.id, supabaseProjectsData]
++ [selectedOrganization?.id, supabaseProjectsData]
+ )
+
+ const { data: vercelProjectConnectionsData } = useVercelProjectConnectionsQuery(
+ {
+ organization_integration_id: organizationIntegrationId,
+ },
+ { enabled: organizationIntegrationId !== null }
+ )
+
+ const { data: vercelProjectsData } = useVercelProjectsQuery(
+ {
+ organization_integration_id: organizationIntegrationId,
+ },
+ { enabled: organizationIntegrationId !== null }
+ )
+
+ const vercelProjects = useMemo(() => vercelProjectsData ?? EMPTY_ARR, [vercelProjectsData])
+
+ return (
+ <SidePanel
+ header={'Add GitHub repository'}
+ size="large"
+ visible={open}
+ hideFooter
+ onCancel={() => snapshot.setOpen(false)}
+ >
+ <div className="py-10 flex flex-col gap-6 bg-body h-full">
+ <SidePanel.Content>
+ <Markdown
+ content={`
+### Choose repository to connect to
+
+Check the details below before proceeding
+ `}
+ />
+ </SidePanel.Content>
+ <SidePanel.Content className="flex flex-col gap-2">
+ <ProjectLinker
+ organizationIntegrationId={selectedIntegration?.id}
+ foreignProjects={vercelProjects}
+ supabaseProjects={supabaseProjects}
+ onCreateConnections={() => {
+ snapshot.setOpen(false)
+ }}
+ installedConnections={selectedIntegration?.connections}
+ />
+ </SidePanel.Content>
+ <SidePanel.Content>
+ <ul>
+ <li className="border px-10">
+ {/* <IntegrationConnectionOption connection={githubIntegrations[0]} /> */}
+ </li>
+ </ul>
+ </SidePanel.Content>
+ </div>
+ </SidePanel>
+ )
+}
+
- export default observer(SidePanelVercelProjectLinker)
++export default SidePanelVercelProjectLinker
diff --cc studio/components/interfaces/Organization/index.ts
index 4ff115e7c94,2c02467f0f9..1c6271c6d6f
--- a/studio/components/interfaces/Organization/index.ts
+++ b/studio/components/interfaces/Organization/index.ts
@@@ -1,15 -1,8 +1,17 @@@
--import GeneralSettings from './GeneralSettings/GeneralSettings'
--import TeamSettings from './TeamSettings/TeamSettings'
import BillingSettings from './BillingSettings/BillingSettings'
- import InvoicesSettings from './InvoicesSettings/InvoicesSettings'
++import GeneralSettings from './GeneralSettings/GeneralSettings'
+import IntegrationSettings from './IntegrationSettings/IntegrationSettings'
+ import InvoicesSettings from './InvoicesSettings/InvoicesSettings'
import NewOrgForm from './NewOrg/NewOrgForm'
+ import OAuthApps from './OAuthApps/OAuthApps'
++import TeamSettings from './TeamSettings/TeamSettings'
-export { GeneralSettings, TeamSettings, BillingSettings, InvoicesSettings, NewOrgForm, OAuthApps }
+export {
- GeneralSettings,
- TeamSettings,
+ BillingSettings,
++ GeneralSettings,
++ IntegrationSettings,
+ InvoicesSettings,
+ NewOrgForm,
- IntegrationSettings,
++ OAuthApps,
++ TeamSettings,
+}
diff --cc studio/components/layouts/OrganizationLayout.tsx
index 35d35debe4f,c4479bcf785..7b66373e84c
--- a/studio/components/layouts/OrganizationLayout.tsx
+++ b/studio/components/layouts/OrganizationLayout.tsx
@@@ -1,48 -1,15 +1,49 @@@
-import { useSelectedOrganization } from 'hooks'
+import { useParams } from 'common'
- import { useStore } from 'hooks'
- import { observer } from 'mobx-react-lite'
++import { useFlag, useSelectedOrganization } from 'hooks'
+import { useRouter } from 'next/router'
import { PropsWithChildren } from 'react'
-import AccountLayout from './AccountLayout/AccountLayout'
+import { Tabs } from 'ui'
+import { AccountLayout } from './'
+import { ScaffoldContainer, ScaffoldDivider, ScaffoldHeader, ScaffoldTitle } from './Scaffold'
const OrganizationLayout = ({ children }: PropsWithChildren<{}>) => {
- const { ui } = useStore()
+ const selectedOrganization = useSelectedOrganization()
+ const router = useRouter()
+ const { slug } = useParams()
+ const id = router.asPath.split('/').at(-1)
++ const showOAuthApps = useFlag('oauthApps')
return (
<AccountLayout
- title={ui.selectedOrganization?.name ?? 'Supabase'}
+ title={selectedOrganization?.name ?? 'Supabase'}
breadcrumbs={[{ key: `org-settings`, label: 'Settings' }]}
>
+ <ScaffoldHeader>
+ <ScaffoldContainer>
- <ScaffoldTitle>{ui.selectedOrganization?.name ?? 'Organization'} settings</ScaffoldTitle>
++ <ScaffoldTitle>{selectedOrganization?.name ?? 'Organization'} settings</ScaffoldTitle>
+ </ScaffoldContainer>
+ <ScaffoldContainer>
+ <nav>
+ <Tabs
+ listClassNames="border-none"
+ size="small"
+ type="underlined"
+ activeId={id}
+ onChange={(id: any) => {
+ router.push(`/org/${slug}/${id}`)
+ }}
+ >
+ <Tabs.Panel id="general" label="General" className="!my-0" />
+ <Tabs.Panel id="team" label="Team" className="!my-0" />
+ <Tabs.Panel id="integrations" label="Integrations" className="!my-0" />
+ <Tabs.Panel id="billing" label="Billing" className="!my-0" />
+ <Tabs.Panel id="invoices" label="Invoices" className="!my-0" />
++ {showOAuthApps && <Tabs.Panel id="apps" label="OAuth Apps" className="!my-0" />}
+ </Tabs>
+ </nav>
+ </ScaffoldContainer>
+ </ScaffoldHeader>
+ <ScaffoldDivider />
{children}
</AccountLayout>
)
diff --cc studio/lib/helpers.ts
index c2bba182580,b5d09d62ab9..767599d3cfa
--- a/studio/lib/helpers.ts
+++ b/studio/lib/helpers.ts
@@@ -247,9 -247,12 +247,19 @@@ export const detectOS = () =>
}
}
+/**
+ * Pluralize a word based on a count
+ */
+export function pluralize(count: number, singular: string, plural?: string) {
+ return count === 1 ? singular : plural || singular + 's'
+}
++
+ export const isValidHttpUrl = (value: string) => {
+ let url: URL
+ try {
+ url = new URL(value)
+ } catch (_) {
+ return false
+ }
+ return url.protocol === 'http:' || url.protocol === 'https:'
+ }
diff --cc studio/pages/integrations/vercel/[slug]/deploy-button/new-project.tsx
index 035508f2f6f,00000000000..299040165fe
mode 100644,000000..100644
--- a/studio/pages/integrations/vercel/[slug]/deploy-button/new-project.tsx
+++ b/studio/pages/integrations/vercel/[slug]/deploy-button/new-project.tsx
@@@ -1,379 -1,0 +1,380 @@@
+import { debounce } from 'lodash'
+import { useRouter } from 'next/router'
+import { ChangeEvent, useRef, useState } from 'react'
+
+import { useParams } from 'common'
+import { Markdown } from 'components/interfaces/Markdown'
+import IntegrationWindowLayout from 'components/layouts/IntegrationWindowLayout'
+import { ScaffoldContainer, ScaffoldDivider } from 'components/layouts/Scaffold'
+import PasswordStrengthBar from 'components/ui/PasswordStrengthBar'
+import { useProjectApiQuery } from 'data/config/project-api-query'
+import { useIntegrationConnectionsCreateMutation } from 'data/integrations/integration-connections-create-mutation'
+import { useIntegrationsQuery } from 'data/integrations/integrations-query'
+import { useVercelProjectsQuery } from 'data/integrations/integrations-vercel-projects-query'
+import { Integration } from 'data/integrations/integrations.types'
+import { useOrganizationsQuery } from 'data/organizations/organizations-query'
+import { useProjectCreateMutation } from 'data/projects/project-create-mutation'
+import generator from 'generate-password'
- import { useStore } from 'hooks'
++import { useSelectedOrganization, useStore } from 'hooks'
+import { AWS_REGIONS, DEFAULT_MINIMUM_PASSWORD_STRENGTH, PROVIDERS } from 'lib/constants'
+import { passwordStrength } from 'lib/helpers'
+import { getInitialMigrationSQLFromGitHubRepo } from 'lib/integration-utils'
+import { NextPageWithLayout, ProjectBase } from 'types'
+import { Alert, Button, Checkbox, IconBook, IconLifeBuoy, Input, Listbox, LoadingLine } from 'ui'
+
+const VercelIntegration: NextPageWithLayout = () => {
+ const [loading, setLoading] = useState<boolean>(false)
+
+ return (
+ <>
+ <main className="overflow-auto flex flex-col h-full">
+ <LoadingLine loading={loading} />
+
+ <>
+ <ScaffoldContainer className="max-w-md flex flex-col gap-6 grow py-8">
+ <h1 className="text-xl text-scale-1200">New project</h1>
+ <>
+ <Markdown content={`Choose the Supabase Organization you wish to install to`} />
+ <CreateProject loading={loading} setLoading={(e: boolean) => setLoading(e)} />
+ </>
+ </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>
+ </>
+
+ <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>
+ </>
+ )
+}
+
+VercelIntegration.getLayout = (page) => <IntegrationWindowLayout>{page}</IntegrationWindowLayout>
+
+const CreateProject = ({
+ loading,
+ setLoading,
+}: {
+ loading: boolean
+ setLoading: (e: boolean) => void
+}) => {
+ const router = useRouter()
+ const { ui } = useStore()
++ const selectedOrganization = useSelectedOrganization()
+ const [projectName, setProjectName] = useState('')
+ const [dbPass, setDbPass] = useState('')
+ const [passwordStrengthMessage, setPasswordStrengthMessage] = useState('')
+ const [passwordStrengthScore, setPasswordStrengthScore] = useState(-1)
+ const [shouldRunMigrations, setShouldRunMigrations] = useState(true)
+ const [dbRegion, setDbRegion] = useState(PROVIDERS.AWS.default_region)
+ // const [loading, setLoading] = useState(false)
+ const delayedCheckPasswordStrength = useRef(
+ debounce((value: string) => checkPasswordStrength(value), 300)
+ ).current
+
+ const {
+ slug,
+ configurationId,
+ next,
+ currentProjectId: foreignProjectId,
+ externalId,
+ } = useParams()
+
+ const { mutateAsync: createConnections, isLoading: isLoadingCreateConnections } =
+ useIntegrationConnectionsCreateMutation({})
+
+ const { data: organizationData, isLoading: isLoadingOrganizationsQuery } = useOrganizationsQuery()
+
+ const organization = organizationData?.find((x) => x.slug === slug)
+
+ /**
+ * array of integrations installed
+ */
+ const { data: integrationData, isLoading: integrationDataLoading } = useIntegrationsQuery()
+
+ /**
+ * the vercel integration installed for organization chosen
+ */
+ const organizationIntegration: Integration | undefined = integrationData?.find(
+ (x) => x.organization.slug === slug
+ )
+
+ /**
+ * Vercel projects available for this integration
+ */
+ const { data: vercelProjects } = useVercelProjectsQuery(
+ {
+ organization_integration_id: organizationIntegration?.id,
+ },
+ { enabled: organizationIntegration !== undefined }
+ )
+
+ const canSubmit =
+ projectName != '' &&
+ passwordStrengthScore >= DEFAULT_MINIMUM_PASSWORD_STRENGTH &&
+ dbRegion != undefined
+
+ function onProjectNameChange(e: ChangeEvent<HTMLInputElement>) {
+ e.target.value = e.target.value.replace(/\./g, '')
+ setProjectName(e.target.value)
+ }
+
+ function onDbPassChange(e: ChangeEvent<HTMLInputElement>) {
+ const value = e.target.value
+ setDbPass(value)
+ if (value == '') {
+ setPasswordStrengthScore(-1)
+ setPasswordStrengthMessage('')
+ } else delayedCheckPasswordStrength(value)
+ }
+
+ async function checkPasswordStrength(value: string) {
+ const { message, strength } = await passwordStrength(value)
+ setPasswordStrengthScore(strength)
+ setPasswordStrengthMessage(message)
+ }
+
+ function generateStrongPassword() {
+ const password = generator.generate({
+ length: 16,
+ numbers: true,
+ uppercase: true,
+ })
+
+ setDbPass(password)
+ delayedCheckPasswordStrength(password)
+ }
+
+ const { mutateAsync: createProject } = useProjectCreateMutation()
+
+ const [newProjectRef, setNewProjectRef] = useState<string | undefined>(undefined)
+ async function onCreateProject() {
+ if (!organizationIntegration) {
+ console.error('No organization installation details found')
+ }
+
+ if (!organizationIntegration?.id) {
+ console.error('No organization installation ID found')
+ return
+ }
+
+ if (!foreignProjectId) {
+ console.error('No foreignProjectId ID set')
+ return
+ }
+
+ if (!configurationId) {
+ console.error('No configurationId ID set')
+ return
+ }
+
+ setLoading(true)
+
+ try {
+ if (!organization) {
+ throw new Error('No organization set')
+ }
+
+ let dbSql: string | undefined
+ if (shouldRunMigrations) {
+ const id = ui.setNotification({
+ category: 'info',
+ message: `Fetching initial migrations from GitHub repo`,
+ })
+
+ dbSql = (await getInitialMigrationSQLFromGitHubRepo(externalId)) ?? undefined
+
+ ui.setNotification({
+ id,
+ category: 'success',
+ message: `Done fetching initial migrations`,
+ })
+ }
+
+ let project: ProjectBase
+
+ try {
+ project = await createProject({
+ organizationId: organization.id,
+ name: projectName,
+ dbPass,
+ dbRegion,
+ dbSql,
+ configurationId,
+ })
+
+ setNewProjectRef(project.ref)
+ } catch (error: any) {
+ setLoading(false)
+ ui.setNotification({
+ category: 'error',
+ message: `Failed to create project: ${error.message}`,
+ })
+ return
+ }
+ } catch (error) {
+ console.error('Error', error)
+ setLoading(false)
+ }
+ }
+ const isInstallingRef = useRef(false)
+
+ // Wait for the new project to be created before creating the connection
+ useProjectApiQuery(
+ { projectRef: newProjectRef },
+ {
+ enabled: newProjectRef !== undefined,
+ // refetch until the project is created
+ refetchInterval: (data) => {
+ return (data?.autoApiService.service_api_keys.length ?? 0) > 0 ? false : 1000
+ },
+ async onSuccess(data) {
+ const isReady = data.autoApiService.service_api_keys.length > 0
+
+ if (
+ !isReady ||
+ !organizationIntegration ||
+ !foreignProjectId ||
+ !newProjectRef ||
+ isInstallingRef.current
+ ) {
+ return
+ }
+ isInstallingRef.current = true
+
+ const projectDetails = vercelProjects?.find((x) => x.id === foreignProjectId)
+
+ // Wrap the createConnections function call in a try-catch block
+ try {
+ await createConnections({
+ organizationIntegrationId: organizationIntegration?.id,
+ connection: {
+ foreign_project_id: foreignProjectId,
+ supabase_project_ref: newProjectRef,
+ metadata: {
+ ...projectDetails,
+ supabaseConfig: {
+ projectEnvVars: {
+ write: true,
+ },
+ },
+ },
+ },
- orgSlug: ui.selectedOrganization?.slug,
++ orgSlug: selectedOrganization?.slug,
+ })
+ } catch (error) {
+ console.error('An error occurred during createConnections:', error)
+ return
+ }
+
+ setLoading(false)
+
+ if (next) {
+ window.location.href = next
+ }
+ },
+ }
+ )
+
+ return (
+ <div className="">
+ <p className="mb-2">Project details for integration</p>
+ <div className="py-2">
+ <Input
+ autoFocus
+ id="projectName"
+ label="Project name"
+ type="text"
+ placeholder=""
+ descriptionText=""
+ value={projectName}
+ onChange={onProjectNameChange}
+ />
+ </div>
+ <div className="py-2">
+ <Input
+ id="dbPass"
+ label="Database Password"
+ type="password"
+ placeholder="Type in a strong password"
+ value={dbPass}
+ copy={dbPass.length > 0}
+ onChange={onDbPassChange}
+ descriptionText={
+ <PasswordStrengthBar
+ passwordStrengthScore={passwordStrengthScore}
+ password={dbPass}
+ passwordStrengthMessage={passwordStrengthMessage}
+ generateStrongPassword={generateStrongPassword}
+ />
+ }
+ />
+ </div>
+ <div className="py-2">
+ <div className="mt-1">
+ <Listbox
+ label="Region"
+ type="select"
+ value={dbRegion}
+ onChange={(region) => setDbRegion(region)}
+ descriptionText="Select a region close to your users for the best performance."
+ >
+ {Object.keys(AWS_REGIONS).map((option: string, i) => {
+ const label = Object.values(AWS_REGIONS)[i]
+ return (
+ <Listbox.Option
+ key={option}
+ label={label}
+ value={label}
+ addOnBefore={({ active, selected }: any) => (
+ <img
+ alt="region icon"
+ className="w-5 rounded-sm"
+ src={`${router.basePath}/img/regions/${Object.keys(AWS_REGIONS)[i]}.svg`}
+ />
+ )}
+ >
+ <span className="text-scale-1200">{label}</span>
+ </Listbox.Option>
+ )
+ })}
+ </Listbox>
+ </div>
+ </div>
+ <div className="py-2 pb-4">
+ <Checkbox
+ name="shouldRunMigrations"
+ label="Run migrations & seed.sql"
+ description="If your repository has migrations under supabase/migrations, they will be run automatically."
+ checked={shouldRunMigrations}
+ onChange={(e) => setShouldRunMigrations(e.target.checked)}
+ />
+ </div>
+ <div className="flex flex-row w-full justify-end">
+ <Button
+ size="medium"
+ className="self-end"
+ disabled={loading}
+ loading={loading}
+ onClick={onCreateProject}
+ >
+ Create Project
+ </Button>
+ </div>
+ </div>
+ )
+}
+
+export default VercelIntegration
diff --cc studio/pages/org/[slug]/apps.tsx
index 00000000000,000ea4d1ec1..c53ee052c42
mode 000000,100644..100644
--- a/studio/pages/org/[slug]/apps.tsx
+++ b/studio/pages/org/[slug]/apps.tsx
@@@ -1,0 -1,57 +1,26 @@@
-import { observer } from 'mobx-react-lite'
-import { useRouter } from 'next/router'
-import { Tabs } from 'ui'
-
-import { useParams } from 'common/hooks'
+ import { OAuthApps } from 'components/interfaces/Organization'
+ import { OrganizationLayout } from 'components/layouts'
+ import Loading from 'components/ui/Loading'
+ import { usePermissionsQuery } from 'data/permissions/permissions-query'
+ import { useSelectedOrganization } from 'hooks'
+ import { NextPageWithLayout } from 'types'
+
+ const OrgOAuthApps: NextPageWithLayout = () => {
- const { slug } = useParams()
- const router = useRouter()
+ const selectedOrganization = useSelectedOrganization()
- const { isLoading: isLoadingPermissions } = usePermissionsQuery()
++ // const { isLoading: isLoadingPermissions } = usePermissionsQuery()
++ const { data: permissions } = usePermissionsQuery()
+
+ return (
+ <>
- {selectedOrganization === undefined && isLoadingPermissions ? (
++ {selectedOrganization === undefined && (permissions ?? []).length === 0 ? (
+ <Loading />
+ ) : (
- <div className="p-4 pt-0">
- <div className="space-y-3">
- <section className="mt-4">
- <h1 className="text-3xl">{selectedOrganization?.name ?? 'Organization'} settings</h1>
- </section>
- <nav>
- <Tabs
- size="small"
- type="underlined"
- activeId="apps"
- onChange={(id: any) => {
- if (id !== 'apps') router.push(`/org/${slug}/${id}`)
- }}
- >
- <Tabs.Panel id="general" label="General" />
- <Tabs.Panel id="team" label="Team" />
- <Tabs.Panel id="billing" label="Billing" />
- <Tabs.Panel id="invoices" label="Invoices" />
- <Tabs.Panel id="apps" label="OAuth Apps" />
- </Tabs>
- </nav>
- </div>
-
- <div className="mb-8">
- <OAuthApps />
- </div>
- </div>
++ <OAuthApps />
+ )}
+ </>
+ )
+ }
+
+ OrgOAuthApps.getLayout = (page) => <OrganizationLayout>{page}</OrganizationLayout>
-export default observer(OrgOAuthApps)
++
++export default OrgOAuthApps
diff --cc studio/pages/org/[slug]/billing.tsx
index 83248fec7a6,d32cfa72bc1..17b7d313641
--- a/studio/pages/org/[slug]/billing.tsx
+++ b/studio/pages/org/[slug]/billing.tsx
@@@ -1,20 -1,53 +1,20 @@@
- import { observer } from 'mobx-react-lite'
-import { useRouter } from 'next/router'
--
- import { NextPageWithLayout } from 'types'
- import { useStore } from 'hooks'
- import Loading from 'components/ui/Loading'
- import { OrganizationLayout } from 'components/layouts'
-import { useParams } from 'common/hooks'
import { BillingSettings } from 'components/interfaces/Organization'
+ import { OrganizationLayout } from 'components/layouts'
+ import Loading from 'components/ui/Loading'
+ import { usePermissionsQuery } from 'data/permissions/permissions-query'
-import { useFlag, useSelectedOrganization } from 'hooks'
++import { useSelectedOrganization } from 'hooks'
+ import { NextPageWithLayout } from 'types'
-import { Tabs } from 'ui'
const OrgBillingSettings: NextPageWithLayout = () => {
- const { ui } = useStore()
+ const { data: permissions } = usePermissionsQuery()
+ const selectedOrganization = useSelectedOrganization()
- const { slug } = useParams()
- const router = useRouter()
- const showOAuthApps = useFlag('oauthApps')
return (
<>
- {ui.selectedOrganization === undefined && (ui?.permissions ?? []).length === 0 ? (
+ {selectedOrganization === undefined && (permissions ?? []).length === 0 ? (
<Loading />
) : (
- <div className="p-4 pt-0">
- <div className="space-y-3">
- <section className="mt-4">
- <h1 className="text-3xl">{selectedOrganization?.name ?? 'Organization'} settings</h1>
- </section>
- <nav>
- <Tabs
- size="small"
- type="underlined"
- activeId="billing"
- onChange={(id: any) => {
- if (id !== 'billing') router.push(`/org/${slug}/${id}`)
- }}
- >
- <Tabs.Panel id="general" label="General" />
- <Tabs.Panel id="team" label="Team" />
- <Tabs.Panel id="billing" label="Billing" />
- <Tabs.Panel id="invoices" label="Invoices" />
- {showOAuthApps && <Tabs.Panel id="apps" label="OAuth Apps" />}
- </Tabs>
- </nav>
- </div>
-
- <div className="mb-8">
- <BillingSettings />
- </div>
- </div>
+ <BillingSettings />
)}
</>
)
diff --cc studio/pages/org/[slug]/general.tsx
index a62ed0e7c4b,6ac6f02f674..a2144d6383f
--- a/studio/pages/org/[slug]/general.tsx
+++ b/studio/pages/org/[slug]/general.tsx
@@@ -1,20 -1,53 +1,20 @@@
- import { observer } from 'mobx-react-lite'
-import { useRouter } from 'next/router'
--
- import { NextPageWithLayout } from 'types'
- import { useStore } from 'hooks'
- import Loading from 'components/ui/Loading'
- import { OrganizationLayout } from 'components/layouts'
-import { useParams } from 'common/hooks'
import { GeneralSettings } from 'components/interfaces/Organization'
+ import { OrganizationLayout } from 'components/layouts'
+ import Loading from 'components/ui/Loading'
+ import { usePermissionsQuery } from 'data/permissions/permissions-query'
-import { useFlag, useSelectedOrganization } from 'hooks'
++import { useSelectedOrganization } from 'hooks'
+ import { NextPageWithLayout } from 'types'
-import { Tabs } from 'ui'
const OrgGeneralSettings: NextPageWithLayout = () => {
- const { ui } = useStore()
+ const { data: permissions } = usePermissionsQuery()
+ const selectedOrganization = useSelectedOrganization()
- const { slug } = useParams()
- const router = useRouter()
- const showOAuthApps = useFlag('oauthApps')
return (
<>
- {ui.selectedOrganization === undefined && (ui?.permissions ?? []).length === 0 ? (
+ {selectedOrganization === undefined && (permissions ?? []).length === 0 ? (
<Loading />
) : (
- <div className="p-4 pt-0">
- <div className="space-y-3">
- <section className="mt-4">
- <h1 className="text-3xl">{selectedOrganization?.name ?? 'Organization'} settings</h1>
- </section>
- <nav>
- <Tabs
- size="small"
- type="underlined"
- activeId="general"
- onChange={(id: any) => {
- if (id !== 'general') router.push(`/org/${slug}/${id}`)
- }}
- >
- <Tabs.Panel id="general" label="General" />
- <Tabs.Panel id="team" label="Team" />
- <Tabs.Panel id="billing" label="Billing" />
- <Tabs.Panel id="invoices" label="Invoices" />
- {showOAuthApps && <Tabs.Panel id="apps" label="OAuth Apps" />}
- </Tabs>
- </nav>
- </div>
-
- <div className="mb-8">
- <GeneralSettings />
- </div>
- </div>
+ <GeneralSettings />
)}
</>
)
diff --cc studio/pages/org/[slug]/invoices.tsx
index f1c7127198a,4219e34c41d..bb21316adbd
--- a/studio/pages/org/[slug]/invoices.tsx
+++ b/studio/pages/org/[slug]/invoices.tsx
@@@ -1,25 -1,58 +1,25 @@@
--import { observer } from 'mobx-react-lite'
-import { useRouter } from 'next/router'
-import { Tabs } from 'ui'
--
- import { NextPageWithLayout } from 'types'
- import { useStore } from 'hooks'
- import Loading from 'components/ui/Loading'
- import { OrganizationLayout } from 'components/layouts'
-import { useParams } from 'common/hooks'
import { InvoicesSettings } from 'components/interfaces/Organization'
+ import { OrganizationLayout } from 'components/layouts'
+ import Loading from 'components/ui/Loading'
+ import { usePermissionsQuery } from 'data/permissions/permissions-query'
-import { useFlag, useSelectedOrganization } from 'hooks'
++import { useSelectedOrganization } from 'hooks'
+ import { NextPageWithLayout } from 'types'
const OrgInvoices: NextPageWithLayout = () => {
- const { ui } = useStore()
+ const { data: permissions } = usePermissionsQuery()
+ const selectedOrganization = useSelectedOrganization()
- const { slug } = useParams()
- const router = useRouter()
- const showOAuthApps = useFlag('oauthApps')
return (
<>
- {ui.selectedOrganization === undefined && (ui?.permissions ?? []).length === 0 ? (
+ {selectedOrganization === undefined && (permissions ?? []).length === 0 ? (
<Loading />
) : (
- <div className="p-4 pt-0">
- <div className="space-y-3">
- <section className="mt-4">
- <h1 className="text-3xl">{selectedOrganization?.name ?? 'Organization'} settings</h1>
- </section>
- <nav>
- <Tabs
- size="small"
- type="underlined"
- activeId="invoices"
- onChange={(id: any) => {
- if (id !== 'invoices') router.push(`/org/${slug}/${id}`)
- }}
- >
- <Tabs.Panel id="general" label="General" />
- <Tabs.Panel id="team" label="Team" />
- <Tabs.Panel id="billing" label="Billing" />
- <Tabs.Panel id="invoices" label="Invoices" />
- {showOAuthApps && <Tabs.Panel id="apps" label="OAuth Apps" />}
- </Tabs>
- </nav>
- </div>
-
- <div className="mb-8">
- <InvoicesSettings />
- </div>
- </div>
+ <InvoicesSettings />
)}
</>
)
}
OrgInvoices.getLayout = (page) => <OrganizationLayout>{page}</OrganizationLayout>
-export default observer(OrgInvoices)
+
- export default observer(OrgInvoices)
++export default OrgInvoices
diff --cc studio/pages/org/[slug]/team.tsx
index 7f96623cd61,8d024a5652f..579249d3001
--- a/studio/pages/org/[slug]/team.tsx
+++ b/studio/pages/org/[slug]/team.tsx
@@@ -1,52 -1,53 +1,20 @@@
--import { useRouter } from 'next/router'
- import { observer } from 'mobx-react-lite'
- import { Tabs } from 'ui'
--
- import { NextPageWithLayout } from 'types'
- import { useStore } from 'hooks'
--import { useParams } from 'common/hooks'
- import Loading from 'components/ui/Loading'
- import { OrganizationLayout } from 'components/layouts'
import { TeamSettings } from 'components/interfaces/Organization'
+ import { OrganizationLayout } from 'components/layouts'
+ import Loading from 'components/ui/Loading'
+ import { usePermissionsQuery } from 'data/permissions/permissions-query'
-import { useFlag, useSelectedOrganization } from 'hooks'
++import { useSelectedOrganization } from 'hooks'
+ import { NextPageWithLayout } from 'types'
-import { Tabs } from 'ui'
const OrgTeamSettings: NextPageWithLayout = () => {
- const { ui } = useStore()
- const { slug } = useParams()
- const router = useRouter()
+ const { data: permissions } = usePermissionsQuery()
+ const selectedOrganization = useSelectedOrganization()
- const { slug } = useParams()
- const router = useRouter()
- const showOAuthApps = useFlag('oauthApps')
return (
<>
- {ui.selectedOrganization === undefined && (ui?.permissions ?? []).length === 0 ? (
+ {selectedOrganization === undefined && (permissions ?? []).length === 0 ? (
<Loading />
) : (
-- <div className="p-4 pt-0">
-- <div className="space-y-3">
-- <section className="mt-4">
- <h1 className="text-3xl">
- {ui.selectedOrganization?.name ?? 'Organization'} settings
- </h1>
- <h1 className="text-3xl">{selectedOrganization?.name ?? 'Organization'} settings</h1>
-- </section>
-- <nav>
-- <Tabs
-- size="small"
-- type="underlined"
-- activeId="team"
-- onChange={(id: any) => {
-- if (id !== 'team') router.push(`/org/${slug}/${id}`)
-- }}
-- >
-- <Tabs.Panel id="general" label="General" />
-- <Tabs.Panel id="team" label="Team" />
-- <Tabs.Panel id="billing" label="Billing" />
-- <Tabs.Panel id="invoices" label="Invoices" />
- {showOAuthApps && <Tabs.Panel id="apps" label="OAuth Apps" />}
-- </Tabs>
-- </nav>
-- </div>
--
-- <div className="mb-8">
-- <TeamSettings />
-- </div>
-- </div>
++ <TeamSettings />
)}
</>
)