The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: estimate time needed to create data branch (#38426)
Han Qiao10a1deca66e2
diff --git a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsxindex 7bfc6942c37..b69109218a9 100644--- a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx+++ b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx@@ -1,6 +1,6 @@import { zodResolver } from '@hookform/resolvers/zod'import { useQueryClient } from '@tanstack/react-query'-import { DollarSign, GitMerge, Github, Loader2 } from 'lucide-react'+import { DatabaseZap, DollarSign, GitMerge, Github, Loader2 } from 'lucide-react'import Image from 'next/image'import Link from 'next/link'import { useRouter } from 'next/router'@@ -21,6 +21,7 @@ import { useBranchCreateMutation } from 'data/branches/branch-create-mutation'import { useBranchesQuery } from 'data/branches/branches-query'import { useCheckGithubBranchValidity } from 'data/integrations/github-branch-check-query'import { useGitHubConnectionsQuery } from 'data/integrations/github-connections-query'+import { useCloneBackupsQuery } from 'data/projects/clone-query'import { projectKeys } from 'data/projects/keys'import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'import { useSendEventMutation } from 'data/telemetry/send-event-mutation'@@ -45,6 +46,9 @@ import {Input_Shadcn_,Label_Shadcn_ as Label,Switch,+ Tooltip,+ TooltipContent,+ TooltipTrigger,cn,} from 'ui'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'@@ -85,6 +89,11 @@ export const CreateBranchModal = () => {useCheckGithubBranchValidity({onError: () => {},})+ const { data: cloneBackups, error: cloneBackupsError } = useCloneBackupsQuery({ projectRef })+ const targetVolumeSizeGb = cloneBackups?.target_volume_size_gb ?? 0+ const noPhysicalBackups = cloneBackupsError?.message.startsWith(+ 'Physical backups need to be enabled'+ )const { mutate: sendEvent } = useSendEventMutation()@@ -172,6 +181,7 @@ export const CreateBranchModal = () => {resolver: zodResolver(FormSchema),defaultValues: { branchName: '', gitBranchName: '', withData: false },})+ const withData = form.watch('withData')const canSubmit = !isCreating && !isCheckingconst isDisabled =@@ -344,9 +354,22 @@ export const CreateBranchModal = () => {layout="flex-row-reverse"description="Clone production data into this branch">- <FormControl_Shadcn_>- <Switch checked={field.value} onCheckedChange={field.onChange} />- </FormControl_Shadcn_>+ <Tooltip>+ <TooltipTrigger>+ <FormControl_Shadcn_>+ <Switch+ disabled={noPhysicalBackups}+ checked={field.value}+ onCheckedChange={field.onChange}+ />+ </FormControl_Shadcn_>+ </TooltipTrigger>+ {noPhysicalBackups && (+ <TooltipContent side="bottom">+ PITR is required for the project to clone data into the branch+ </TooltipContent>+ )}+ </Tooltip></FormItemLayout>)}/>@@ -362,6 +385,30 @@ export const CreateBranchModal = () => {promptProPlanUpgrade && 'opacity-25 pointer-events-none')}>+ {withData && (+ <div className="flex flex-row gap-4">+ <div>+ <figure className="w-10 h-10 rounded-md bg-info-200 border border-info-400 flex items-center justify-center">+ <DatabaseZap className="text-info" size={20} strokeWidth={2} />+ </figure>+ </div>+ <div className="flex flex-col gap-y-1">+ <p className="text-sm text-foreground">+ Data branch takes longer time to create+ </p>+ <p className="text-sm text-foreground-light">+ Since your target database volume size is{' '}+ <code className="text-xs font-mono">{targetVolumeSizeGb} GB</code>, creating a+ data branch is estimated to take around{' '}+ <code className="text-xs font-mono">+ {Math.round((720 / 21000) * targetVolumeSizeGb) + 3} minutes+ </code>+ .+ </p>+ </div>+ </div>+ )}+{githubConnection && (<div className="flex flex-row gap-4"><div>