The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Branch refinements (#37192)
Saxon Fletcher625af107bdba
diff --git a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsxindex 7f3074d1269..93c82251740 100644--- a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx+++ b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx@@ -44,6 +44,8 @@ import {cn,} from 'ui'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'+import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'+import { PermissionAction } from '@supabase/shared-types/out/constants'export const CreateBranchModal = () => {const { ref } = useParams()@@ -95,6 +97,8 @@ export const CreateBranchModal = () => {},})+ const canCreateBranch = useCheckPermissions(PermissionAction.CREATE, 'preview_branches')+const githubConnection = connections?.find((connection) => connection.project.ref === projectRef)// Fetch production/default branch to inspect git_branch linkage@@ -149,6 +153,14 @@ export const CreateBranchModal = () => {})const canSubmit = !isCreating && !isChecking+ const isDisabled =+ !isSuccessConnections ||+ isCreating ||+ !canSubmit ||+ isChecking ||+ (!gitlessBranching && !githubConnection) ||+ promptProPlanUpgrade ||+ !canCreateBranchconst onSubmit = (data: z.infer<typeof FormSchema>) => {if (!projectRef) return console.error('Project ref is required')@@ -198,6 +210,7 @@ export const CreateBranchModal = () => {<DialogSectionSeparator /></>)}+<DialogSectionpadding="medium"className={cn('space-y-4', promptProPlanUpgrade && 'opacity-25 pointer-events-none')}@@ -348,9 +361,7 @@ export const CreateBranchModal = () => {</figure></div><div className="flex flex-col gap-y-1">- <p className="text-sm text-foreground">- Preview branches are billed $0.01344 per hour- </p>+ <p className="text-sm text-foreground">Branches are billed $0.01344 per hour</p><p className="text-sm text-foreground-light">This cost will continue for as long as the branch has not been removed.</p>@@ -370,14 +381,7 @@ export const CreateBranchModal = () => {</Button><ButtonTooltipform={formId}- disabled={- !isSuccessConnections ||- isCreating ||- !canSubmit ||- isChecking ||- (!gitlessBranching && !githubConnection) ||- promptProPlanUpgrade- }+ disabled={isDisabled}loading={isCreating}type="primary"htmlType="submit"diff --git a/apps/studio/components/interfaces/BranchManagement/DatabaseDiffPanel.tsx b/apps/studio/components/interfaces/BranchManagement/DatabaseDiffPanel.tsxindex a9aa6d73da2..4748365eeaa 100644--- a/apps/studio/components/interfaces/BranchManagement/DatabaseDiffPanel.tsx+++ b/apps/studio/components/interfaces/BranchManagement/DatabaseDiffPanel.tsx@@ -46,7 +46,7 @@ const DatabaseDiffPanel = ({return (<Card>- <CardHeader className="flex flex-row items-center justify-between space-y-0">+ <CardHeader className="flex flex-row items-center justify-between space-y-0 py-3"><CardTitle><Linkhref={`/project/${currentBranchRef}/database/schema`}diff --git a/apps/studio/components/interfaces/BranchManagement/EmptyStates.tsx b/apps/studio/components/interfaces/BranchManagement/EmptyStates.tsxindex ed5c505cdd6..ec543b4150c 100644--- a/apps/studio/components/interfaces/BranchManagement/EmptyStates.tsx+++ b/apps/studio/components/interfaces/BranchManagement/EmptyStates.tsx@@ -63,8 +63,8 @@ export const PreviewBranchesEmptyState = ({<div className="flex items-center flex-col justify-center w-full py-10"><p>Create your first preview branch</p><p className="text-foreground-light mb-4">- Preview branches are used to experiment with changes to your database schema in a safe,- non-destructive environment.+ Preview branches are short-lived environments that let you safely experiment with changes to+ your database schema without affecting your main database.</p><div className="flex items-center space-x-2"><DocsButton href="https://supabase.com/docs/guides/platform/branching" />diff --git a/apps/studio/components/interfaces/BranchManagement/Overview.tsx b/apps/studio/components/interfaces/BranchManagement/Overview.tsxindex c4c2be7670c..b348808d864 100644--- a/apps/studio/components/interfaces/BranchManagement/Overview.tsx+++ b/apps/studio/components/interfaces/BranchManagement/Overview.tsx@@ -35,6 +35,7 @@ import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'import { BranchLoader, BranchManagementSection, BranchRow, BranchRowLoader } from './BranchPanels'import { EditBranchModal } from './EditBranchModal'import { PreviewBranchesEmptyState } from './EmptyStates'+import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal'interface OverviewProps {isLoading: boolean@@ -99,7 +100,8 @@ export const Overview = ({<div className="flex items-center flex-col justify-center w-full py-10"><p>No persistent branches</p><p className="text-foreground-light">- Persistent branches are long-lived and not automatically deleted.+ Persistent branches are long-lived, cannot be reset, and are ideal for staging+ environments.</p></div>)}@@ -337,19 +339,20 @@ const PreviewBranchActions = ({</DropdownMenuContent></DropdownMenu>- <ConfirmationModal- variant="destructive"+ <TextConfirmModal+ variant="warning"visible={showConfirmResetModal}- confirmLabel="Reset branch"- title="Confirm branch reset"- loading={isResetting}onCancel={() => setShowConfirmResetModal(false)}onConfirm={onConfirmReset}- >- <p className="text-sm text-foreground-light">- Are you sure you want to reset the "{branch.name}" branch? All data will be deleted.- </p>- </ConfirmationModal>+ loading={isResetting}+ title="Reset branch"+ confirmLabel="Reset branch"+ confirmPlaceholder="Type in name of branch"+ confirmString={branch?.name ?? ''}+ alert={{+ title: `Are you sure you want to reset the "${branch.name}" branch? All data will be deleted.`,+ }}+ /><ConfirmationModalvariant="default"diff --git a/apps/studio/components/interfaces/Home/ServiceStatus.tsx b/apps/studio/components/interfaces/Home/ServiceStatus.tsxindex 024b47a8f69..bcba3a9bc90 100644--- a/apps/studio/components/interfaces/Home/ServiceStatus.tsx+++ b/apps/studio/components/interfaces/Home/ServiceStatus.tsx@@ -239,7 +239,7 @@ export const ServiceStatus = () => {currentBranch?.status === 'MIGRATIONS_FAILED'? 'UNHEALTHY': 'COMING_UP') as ProjectServiceStatus,- logsUrl: '/logs/edge-functions-logs',+ logsUrl: '/branches',},]: []),diff --git a/apps/studio/components/layouts/AppLayout/BranchDropdown.tsx b/apps/studio/components/layouts/AppLayout/BranchDropdown.tsxindex 21266c321a1..08d4b8eb2a7 100644--- a/apps/studio/components/layouts/AppLayout/BranchDropdown.tsx+++ b/apps/studio/components/layouts/AppLayout/BranchDropdown.tsx@@ -133,8 +133,10 @@ export const BranchDropdown = () => {{isBranchingEnabled ? (selectedBranch?.is_default ? (<Badge variant="warning">Production</Badge>+ ) : selectedBranch?.persistent ? (+ <Badge variant="brand">Persistent</Badge>) : (- <Badge variant="brand">Preview Branch</Badge>+ <Badge variant="brand">Preview</Badge>)) : (<Badge variant="warning">Production</Badge>diff --git a/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPITRNotice.tsx b/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPITRNotice.tsxindex 289bf7b33c4..32d66d380a5 100644--- a/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPITRNotice.tsx+++ b/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPITRNotice.tsx@@ -24,11 +24,12 @@ export const BranchingPITRNotice = () => {<Clock className="text-warning-700" size={20} strokeWidth={2} /></figure></div>- <div className="flex grow items-center justify-between">+ <div className="flex grow items-center justify-between gap-4"><div className="flex flex-col gap-y-1"><p className="text-sm text-foreground">Consider enabling Point in Time Recovery (PITR)</p><p className="text-sm text-foreground-light">- This ensures you can recover data if you make a bad migration (e.g. delete a column).+ This ensures you can recover production data if you merge a bad migration (e.g. delete a+ column).</p></div>{!canUpdateSubscription ? (diff --git a/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx b/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsxindex 1ac41c011b8..5b0c209fac7 100644--- a/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx+++ b/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx@@ -9,7 +9,7 @@ import ShimmeringLoader from 'components/ui/ShimmeringLoader'import { ProjectInfo, useProjectsQuery } from 'data/projects/projects-query'import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'-import { useSelectedProject } from 'hooks/misc/useSelectedProject'+import { useProjectByRef, useSelectedProject } from 'hooks/misc/useSelectedProject'import { IS_PLATFORM } from 'lib/constants'import type { Organization } from 'types'import {@@ -27,6 +27,7 @@ import {ScrollArea,cn,} from 'ui'+import { useBranchesQuery } from 'data/branches/branches-query'// [Fran] the idea is to let users change projects without losing the current page,// but at the same time we need to redirect correctly between urls that might be@@ -119,7 +120,9 @@ export const ProjectDropdown = () => {className="flex items-center gap-2 flex-shrink-0 text-sm"><Box size={14} strokeWidth={1.5} className="text-foreground-lighter" />- <span className="text-foreground max-w-32 lg:max-w-none truncate">{project?.name}</span>+ <span className="text-foreground max-w-32 lg:max-w-none truncate">+ {selectedProject?.name}+ </span></Link><Popover_Shadcn_ open={open} onOpenChange={setOpen} modal={false}><PopoverTrigger_Shadcn_ asChild>diff --git a/apps/studio/pages/project/[ref]/index.tsx b/apps/studio/pages/project/[ref]/index.tsxindex eb3a86ed847..9f555e26cc9 100644--- a/apps/studio/pages/project/[ref]/index.tsx+++ b/apps/studio/pages/project/[ref]/index.tsx@@ -18,7 +18,7 @@ import { useEdgeFunctionsQuery } from 'data/edge-functions/edge-functions-query'import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'import { useTablesQuery } from 'data/tables/tables-query'import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'-import { useIsOrioleDb, useSelectedProject } from 'hooks/misc/useSelectedProject'+import { useIsOrioleDb, useProjectByRef, useSelectedProject } from 'hooks/misc/useSelectedProject'import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'import { useAppStateSnapshot } from 'state/app-state'import type { NextPageWithLayout } from 'types'@@ -34,10 +34,12 @@ import {TooltipTrigger,} from 'ui'import ShimmeringLoader from 'ui-patterns/ShimmeringLoader'+import { useBranchesQuery } from 'data/branches/branches-query'const Home: NextPageWithLayout = () => {const organization = useSelectedOrganization()const project = useSelectedProject()+ const parentProject = useProjectByRef(project?.parent_project_ref)const isOrioleDb = useIsOrioleDb()const snap = useAppStateSnapshot()const { ref, enableBranching } = useParams()@@ -54,11 +56,6 @@ const Home: NextPageWithLayout = () => {// eslint-disable-next-line react-hooks/exhaustive-deps}, [enableBranching])- const projectName =- project?.ref !== 'default' && project?.name !== undefined- ? project?.name- : 'Welcome to your project'-const { data: tablesData, isLoading: isLoadingTables } = useTablesQuery({projectRef: project?.ref,connectionString: project?.connectionString,@@ -71,6 +68,21 @@ const Home: NextPageWithLayout = () => {projectRef: project?.ref,})+ const { data: branches } = useBranchesQuery({+ projectRef: project?.parent_project_ref ?? project?.ref,+ })++ const mainBranch = branches?.find((branch) => branch.is_default)+ const currentBranch = branches?.find((branch) => branch.project_ref === project?.ref)+ const isMainBranch = currentBranch?.name === mainBranch?.name+ let projectName = 'Welcome to your project'++ if (currentBranch && !isMainBranch) {+ projectName = currentBranch?.name+ } else if (project?.name) {+ projectName = project?.name+ }+const tablesCount = Math.max(0, tablesData?.length ?? 0)const functionsCount = Math.max(0, functionsData?.length ?? 0)// [Joshen] JFYI minus 1 as the replicas endpoint returns the primary DB minimally@@ -81,31 +93,43 @@ const Home: NextPageWithLayout = () => {<div className={cn('py-16 px-8', !isPaused && 'border-b border-muted ')}><div className="mx-auto max-w-7xl flex flex-col gap-y-4"><div className="flex flex-col md:flex-row md:items-center gap-6 justify-between w-full">- <div className="flex flex-col md:flex-row md:items-center gap-3 w-full">- <h1 className="text-3xl">{projectName}</h1>- {isOrioleDb && (- <Tooltip>- <TooltipTrigger asChild>- <Badge variant="warning">OrioleDB</Badge>- </TooltipTrigger>- <TooltipContent side="bottom" align="start" className="max-w-80 text-center">- This project is using Postgres with OrioleDB which is currently in preview and- not suitable for production workloads. View our{' '}- <InlineLink href="https://supabase.com/docs/guides/database/orioledb">- documentation- </InlineLink>{' '}- for all limitations.- </TooltipContent>- </Tooltip>- )}- <ComputeBadgeWrapper- project={{- ref: project?.ref,- organization_slug: organization?.slug,- cloud_provider: project?.cloud_provider,- infra_compute_size: project?.infra_compute_size,- }}- />+ <div className="flex flex-col md:flex-row md:items-end gap-3 w-full">+ <div>+ {!isMainBranch && (+ <Link+ href={`/project/${parentProject?.ref}`}+ className="text-sm text-foreground-light"+ >+ {parentProject?.name}+ </Link>+ )}+ <h1 className="text-3xl">{projectName}</h1>+ </div>+ <div className="flex items-center gap-x-2 mb-1">+ {isOrioleDb && (+ <Tooltip>+ <TooltipTrigger asChild>+ <Badge variant="warning">OrioleDB</Badge>+ </TooltipTrigger>+ <TooltipContent side="bottom" align="start" className="max-w-80 text-center">+ This project is using Postgres with OrioleDB which is currently in preview and+ not suitable for production workloads. View our{' '}+ <InlineLink href="https://supabase.com/docs/guides/database/orioledb">+ documentation+ </InlineLink>{' '}+ for all limitations.+ </TooltipContent>+ </Tooltip>+ )}+ <ComputeBadgeWrapper+ project={{+ ref: project?.ref,+ organization_slug: organization?.slug,+ cloud_provider: project?.cloud_provider,+ infra_compute_size: project?.infra_compute_size,+ }}+ />+ </div></div><div className="flex items-center">{project?.status === PROJECT_STATUS.ACTIVE_HEALTHY && (diff --git a/apps/studio/pages/project/[ref]/merge.tsx b/apps/studio/pages/project/[ref]/merge.tsxindex 10195304cde..de80a26e713 100644--- a/apps/studio/pages/project/[ref]/merge.tsx+++ b/apps/studio/pages/project/[ref]/merge.tsx@@ -340,7 +340,7 @@ const MergePage: NextPageWithLayout = () => {? 'No changes to merge': isWorkflowRunning? 'Workflow is currently running'- : 'Branch is out of date',+ : 'Unable to merge at this time',},}}type="primary"