The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Updated enable branching modal to use IntegrationPanels. Also updated some a11y and shadcn things
Jonathan Summers-Muir5186e5dda37c
diff --git a/packages/ui/src/components/Modal/Modal.tsx b/packages/ui/src/components/Modal/Modal.tsxindex fa42ee94ea0..2dde90265c7 100644--- a/packages/ui/src/components/Modal/Modal.tsx+++ b/packages/ui/src/components/Modal/Modal.tsx@@ -2,6 +2,7 @@ import React, { useEffect } from 'react'// @ts-ignoreimport ModalStyles from './Modal.module.css'import { Button, IconX, Space } from './../../../index'+import { cn } from '@ui/lib/utils'import { AnimationTailwindClasses } from '../../types'import * as Dialog from '@radix-ui/react-dialog'@@ -188,9 +189,9 @@ const Modal = ({)}-function Content({ children }: { children: React.ReactNode }) {+function Content({ children, className }: { children: React.ReactNode; className?: string }) {const __styles = styleHandler('modal')- return <div className={__styles.content}>{children}</div>+ return <div className={cn(__styles.content, className)}>{children}</div>}export function Separator() {diff --git a/studio/components/interfaces/Integrations/IntegrationPanels.tsx b/studio/components/interfaces/Integrations/IntegrationPanels.tsxindex 202d712da00..26028c0a79f 100644--- a/studio/components/interfaces/Integrations/IntegrationPanels.tsx+++ b/studio/components/interfaces/Integrations/IntegrationPanels.tsx@@ -8,6 +8,8 @@ import { useProjectsQuery } from 'data/projects/projects-query'import { BASE_PATH } from 'lib/constants'import { Badge, Button, IconArrowRight, IconExternalLink, IconGitHub, IconSquare, cn } from 'ui'import { getIntegrationConfigurationUrl } from 'lib/integration-utils'+import Link from 'next/link'+import { BooleanFormatter } from 'components/grid/components/formatter'const ICON_STROKE_WIDTH = 2const ICON_SIZE = 14@@ -91,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-scale-1200 font-medium">+ <span className="text font-medium">{integration.metadata?.account.name ||(integration.metadata !== undefined &&'gitHubConnectionOwner' in integration.metadata &&@@ -103,25 +105,26 @@ const IntegrationInstallation = React.forwardRef<HTMLLIElement, IntegrationInsta</Badge></div><div className="flex flex-col gap-0">- <span className="text-scale-900 text-sm">+ <span className="text-lighter text-xs">Created {dayjs(integration.inserted_at).fromNow()}</span>- <span className="text-scale-900 text-sm">+ <span className="text-lighter text-xs">Added by {integration?.added_by?.primary_email}</span></div></div></div>- <Button type="default" asChild iconRight={<IconExternalLink />}>- <a- href={getIntegrationConfigurationUrl(integration)}- target="_blank"- rel="noopener noreferrer"- >- Manage- </a>- </Button>+ <Link+ href={getIntegrationConfigurationUrl(integration)}+ target="_blank"+ rel="noopener noreferrer"+ passHref+ >+ <Button type="default" asChild iconRight={<IconExternalLink />}>+ <a>Manage</a>+ </Button>+ </Link></li>)}@@ -131,10 +134,15 @@ export interface IntegrationConnectionProps extends React.HTMLAttributes<HTMLLIEconnection: IntegrationProjectConnectiontype: Integration['integration']['name']actions?: React.ReactNode+ showNode?: boolean+ orientation?: 'horizontal' | 'vertical'}const IntegrationConnection = React.forwardRef<HTMLLIElement, IntegrationConnectionProps>(- ({ className, connection, type, actions, ...props }, ref) => {+ (+ { className, connection, type, actions, showNode = true, orientation = 'horizontal', ...props },+ ref+ ) => {const { data: projects } = useProjectsQuery()const project = projects?.find((project) => project.ref === connection.supabase_project_ref)@@ -143,14 +151,27 @@ const IntegrationConnection = React.forwardRef<HTMLLIElement, IntegrationConnectref={ref}key={connection.id}{...props}- className={cn('ml-6 pl-8 pb-2 border-l border-scale-600 dark:border-scale-400', 'relative')}+ className={cn(+ showNode && 'pl-8 ml-6 border-l border-scale-600 dark:border-scale-400',+ 'pb-2',+ 'relative'+ )}>- <div className="absolute w-8 rounded-bl-full border-b border-l border-scale-600 dark:border-scale-400 h-10 -left-px"></div>- <div className="bg-surface-100 border shadow-sm flex justify-between items-center px-8 py-4 rounded-lg">- <div className="flex flex-col gap-1">+ {showNode && (+ <div className="absolute w-8 rounded-bl-full border-b border-l border-scale-600 dark:border-scale-400 h-10 -left-px"></div>+ )}+ <div+ className={cn(+ orientation === 'horizontal'+ ? 'flex items-center justify-between'+ : 'flex flex-col gap-3',+ 'bg-surface-100 border shadow-sm px-8 py-4 rounded-lg'+ )}+ >+ <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} />{!connection?.metadata?.framework ? (<div className="bg-black text-white w-4 h-4 rounded flex items-center justify-center">@@ -164,14 +185,14 @@ const IntegrationConnection = React.forwardRef<HTMLLIElement, IntegrationConnectalt={`icon`}/>)}- <span>{connection.metadata?.name}</span>+ <span className="text-sm">{connection.metadata?.name}</span></div><div className="flex flex-col gap-0">- <span className="text-scale-900 text-sm">+ <span className="text-scale-900 text-xs">Connected {dayjs(connection?.inserted_at).fromNow()}</span>- <span className="text-scale-900 text-sm">+ <span className="text-scale-900 text-xs">Added by {connection?.added_by?.primary_email}</span></div>@@ -207,7 +228,7 @@ const IntegrationConnectionOption = React.forwardRef<HTMLLIElement, IntegrationC<span>{connection.metadata.name}</span></div>- <span className="text-scale-900 text-sm">+ <span className="text-lighter text-xs">Connected {dayjs(connection.inserted_at).fromNow()}</span></div>@@ -220,15 +241,23 @@ const IntegrationConnectionOption = React.forwardRef<HTMLLIElement, IntegrationCconst EmptyIntegrationConnection = React.forwardRef<HTMLDivElement,- React.HTMLAttributes<HTMLDivElement>->(({ className, ...props }, ref) => {+ React.HTMLAttributes<HTMLDivElement> & { showNode?: boolean }+>(({ className, showNode = true, ...props }, ref) => {return (<divref={ref}{...props}- className={cn('ml-6 pl-8 pb-2 border-l', 'last:border-l-transparent', 'relative', className)}+ className={cn(+ showNode && 'ml-6 pl-8 border-l',+ 'pb-2 ',+ 'last:border-l-transparent',+ 'relative',+ className+ )}>- <div className="absolute w-8 rounded-bl-full border-b border-l border-scale-600 dark:border-scale-400 h-10 -left-px"></div>+ {showNode && (+ <div className="absolute w-8 rounded-bl-full border-b border-l border-scale-600 dark:border-scale-400 h-10 -left-px"></div>+ )}<divclassName={cn('w-full',diff --git a/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingButton.tsx b/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingButton.tsxindex 3bbda7a6bb8..3e3d77e05b2 100644--- a/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingButton.tsx+++ b/studio/components/layouts/AppLayout/EnableBranchingButton/EnableBranchingButton.tsx@@ -78,24 +78,26 @@ const EnableBranchingButton = () => {>Enable branching</Button>- <Modal hideFooter visible={open} onCancel={() => setOpen(false)}>- <Modal.Content>- <div className="flex items-center space-x-4 py-4">- <IconGitBranch strokeWidth={2} size={20} />- <div>- <p className="text">Enable database branching</p>- <p className="text-sm text-light">Management environments in Supabase</p>- </div>+ <Modal+ hideFooter+ visible={open}+ onCancel={() => setOpen(false)}+ className="!bg"+ size="medium"+ >+ <Modal.Content className="p-7 flex items-center space-x-4">+ <IconGitBranch strokeWidth={2} size={20} />+ <div>+ <p className="text">Enable database branching</p>+ <p className="text-sm text-light">Management environments in Supabase</p></div></Modal.Content>{isLoadingIntegrations && (<><Modal.Separator />- <Modal.Content>- <div className="py-6">- <GenericSkeletonLoader />- </div>+ <Modal.Content className="px-7 py-6">+ <GenericSkeletonLoader /></Modal.Content><Modal.Separator /></>@@ -104,10 +106,8 @@ const EnableBranchingButton = () => {{isErrorIntegrations && (<><Modal.Separator />- <Modal.Content>- <div className="py-6">- <AlertError error={integrationsError} subject="Failed to retrieve integrations" />- </div>+ <Modal.Content className="px-7 py-6">+ <AlertError error={integrationsError} subject="Failed to retrieve integrations" /></Modal.Content><Modal.Separator /></>@@ -129,37 +129,36 @@ const EnableBranchingButton = () => {)}{/* [Joshen TODO] Feels like this copy writing needs some relooking before we ship, make sure they are factual too */}- <Modal.Content>- <div className="py-6 space-y-3">- <p className="text-sm text-light">Please keep in mind the following:</p>- <div className="flex space-x-4">- <div>- <div className="w-10 h-10 border rounded-md bg-amber-200 border-amber-700 flex items-center justify-center">- <IconFileText className="text-amber-900" size={20} strokeWidth={2} />- </div>- </div>- <div>- <p className="text-sm text">- You will not be able to use the dashboard to make changes to the database- </p>- <p className="text-sm text-light">- Schema changes for database preview branches must be done via Git. We are- nonetheless working on allowing the dashboard to make schema changes for preview- branches.- </p>- </div>+ <Modal.Content className="px-7 py-6 flex flex-col gap-3">+ <p className="text-sm text-light">Please keep in mind the following:</p>+ <div className="flex flex-row gap-4">+ <div>+ <figure className="w-10 h-10 rounded-md bg-warning-200 border border-warning-300 flex items-center justify-center">+ <IconFileText className="text-amber-900" size={20} strokeWidth={2} />+ </figure>+ </div>+ <div>+ <p className="text-sm text">+ You will not be able to use the dashboard to make changes to the database+ </p>+ <p className="text-sm text-light">+ Schema changes for database preview branches must be done via Git. We are+ nonetheless working on allowing the dashboard to make schema changes for preview+ branches.+ </p></div></div></Modal.Content><Modal.Separator />- <Modal.Content>+ <Modal.Content className="px-7"><div className="flex items-center space-x-2 py-2 pb-4">- <Button block disabled={isCreating} type="default">+ <Button size="medium" block disabled={isCreating} type="default">Cancel</Button><Button+ size="medium"blockdisabled={selectedBranch === undefined || isCreating}loading={isCreating}diff --git a/studio/components/layouts/AppLayout/EnableBranchingButton/GithubRepositorySelection.tsx b/studio/components/layouts/AppLayout/EnableBranchingButton/GithubRepositorySelection.tsxindex 4a56d10098b..6915ce33b89 100644--- a/studio/components/layouts/AppLayout/EnableBranchingButton/GithubRepositorySelection.tsx+++ b/studio/components/layouts/AppLayout/EnableBranchingButton/GithubRepositorySelection.tsx@@ -17,10 +17,15 @@ import {PopoverContent_Shadcn_,PopoverTrigger_Shadcn_,Popover_Shadcn_,+ cn,} from 'ui'import { useParams } from 'common'-import { EmptyIntegrationConnection } from 'components/interfaces/Integrations/IntegrationPanels'+import {+ EmptyIntegrationConnection,+ IntegrationConnection,+ IntegrationConnectionOption,+} from 'components/interfaces/Integrations/IntegrationPanels'import AlertError from 'components/ui/AlertError'import ShimmeringLoader from 'components/ui/ShimmeringLoader'import { useGithubBranchesQuery } from 'data/integrations/integrations-github-branches-query'@@ -63,9 +68,11 @@ const GithubRepositorySelection = ({})return (- <div className={clsx('border-t border-b', !integration ? 'border-amber-300 bg-amber-100' : '')}>- <Modal.Content>- <div className="space-y-1 py-6">+ <div+ className={clsx('border-t border-b', !integration ? 'border-warning-300 bg-warning-200' : '')}+ >+ <Modal.Content className="px-7">+ <div className="py-6"><div className="flex items-center space-x-2"><p>Git Connection</p><Badge color="amber">Required</Badge>@@ -85,26 +92,28 @@ const GithubRepositorySelection = ({</Link>)}{integration && !githubProjectIntegration && (- <EmptyIntegrationConnection onClick={() => onSelectConnectRepo()} />+ <EmptyIntegrationConnection showNode={false} onClick={() => onSelectConnectRepo()} />)}{integration && githubProjectIntegration && (<>- <div className="border bg-surface-200 rounded-md flex items-center justify-between py-4 px-4">- <div className="flex items-center space-x-4">- <div className="w-10 h-10 rounded-md flex items-center justify-center bg-scale-100">- <IconGitHub strokeWidth={2} />- </div>- <div>- <p className="text-sm text-light">@{repoOwner}</p>- <p className="text-sm">{repoName}</p>- </div>- </div>- <Button type="default" onClick={() => onSelectConnectRepo()}>- Configure- </Button>- </div>- <div className="!mt-4">- <p className="text-sm text-light mb-2">Select your production branch:</p>+ <ul className="mb-3">+ <IntegrationConnection+ type={'GitHub'}+ connection={githubProjectIntegration}+ showNode={false}+ actions={+ <Button type="default" onClick={() => onSelectConnectRepo()}>+ Configure connection+ </Button>+ }+ orientation="vertical"+ />+ </ul>++ <div>+ <label className="block text-sm text-light mb-2" htmlFor="branch-selector">+ Select your production branch:+ </label>{isLoadingBranches && <ShimmeringLoader />}{isErrorBranches && (<AlertError@@ -114,22 +123,23 @@ const GithubRepositorySelection = ({)}{isSuccessBranches && (<Popover_Shadcn_ open={open} onOpenChange={setOpen} modal={false}>- <PopoverTrigger_Shadcn_ asChild>+ <PopoverTrigger_Shadcn_ asChild name="branch-selector"><Buttonblocktype="default"size="medium"ref={comboBoxRef}- className="justify-start"+ className={cn(+ 'justify-start w-64',+ selectedBranch === undefined ? 'text-light' : 'text'+ )}iconRight={<span className="grow flex justify-end"><IconChevronDown className={''} /></span>}>- <p className={selectedBranch === undefined ? 'text-light' : 'text'}>- {selectedBranch || 'Select a branch'}- </p>+ {selectedBranch || 'Select a branch'}</Button></PopoverTrigger_Shadcn_><PopoverContent_Shadcn_diff --git a/studio/components/ui/AlertError.tsx b/studio/components/ui/AlertError.tsxindex 7b6af8e4c98..dfd6b976a9a 100644--- a/studio/components/ui/AlertError.tsx+++ b/studio/components/ui/AlertError.tsx@@ -1,6 +1,13 @@import Link from 'next/link'import { ResponseError } from 'types'-import { Alert, Button } from 'ui'+import {+ Alert,+ AlertDescription_Shadcn_,+ AlertTitle_Shadcn_,+ Alert_Shadcn_,+ Button,+ IconAlertCircle,+} from 'ui'export interface AlertErrorProps {ref?: string@@ -20,26 +27,21 @@ const AlertError = ({ ref, subject, error, className }: AlertErrorProps) => {if (error) href += `&message=Error:%20${error.message}`return (- <Alert- withIcon- className={className}- variant="warning"- title={subject}- actions={[- <Link key="contact-support" href={href}>- <a>- <Button type="default" className="ml-4">- Contact support- </Button>- </a>- </Link>,- ]}- >- {error && <p className="mb-1">Error: {error.message}</p>}- <p>+ <Alert_Shadcn_ className={className} variant="warning" title={subject}>+ <IconAlertCircle className="h-4 w-4" />+ <AlertTitle_Shadcn_>{subject}</AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_ className="flex flex-col gap-3">+ {error?.message && <p>Error: {error?.message}</p>}Try refreshing your browser, but if the issue persists, please reach out to us via support.- </p>- </Alert>+ <div>+ <Link key="contact-support" href={href} passHref>+ <Button type="warning" asChild>+ <a>Contact support</a>+ </Button>+ </Link>+ </div>+ </AlertDescription_Shadcn_>+ </Alert_Shadcn_>)}