Skip to content

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

feat: Allow for configuring branch limit per connection (#26394)

Kamil Ogórekd6ed076ef2d6
diff --git a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx
index ccd89048f73..f772b840880 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx
@@ -95,12 +95,14 @@ const GitHubIntegrationConnectionForm = ({ connection }: GitHubIntegrationConnec
supabaseChangesOnly: z
.boolean()
.default(connection.metadata?.supabaseConfig?.supabaseChangesOnly ?? false),
+ branchLimit: z.string().default(String(connection.metadata?.supabaseConfig?.branchLimit ?? 50)),
})
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
defaultValues: {
supabaseDirectory: connection?.metadata?.supabaseConfig?.supabaseDirectory,
supabaseChangesOnly: connection?.metadata?.supabaseConfig?.supabaseChangesOnly,
+ branchLimit: String(connection?.metadata?.supabaseConfig?.branchLimit),
},
})
@@ -111,6 +113,7 @@ const GitHubIntegrationConnectionForm = ({ connection }: GitHubIntegrationConnec
organizationId: org?.id,
workdir: data.supabaseDirectory,
supabaseChangesOnly: data.supabaseChangesOnly,
+ branchLimit: Number(data.branchLimit),
})
}
@@ -208,6 +211,58 @@ const GitHubIntegrationConnectionForm = ({ connection }: GitHubIntegrationConnec
<Form_Shadcn_ {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="flex flex-col gap-6">
+ <FormField_Shadcn_
+ control={form.control}
+ name="branchLimit"
+ render={({ field }) => (
+ <FormItem_Shadcn_ className="flex flex-col">
+ <FormLabel_Shadcn_ className="!text">Branch limit</FormLabel_Shadcn_>
+ <FormDescription_Shadcn_ className="text-xs text-foreground-lighter !mt-0 !mb-1">
+ Total number of branches that can be automatically created for this connection.
+ </FormDescription_Shadcn_>
+ <FormControl_Shadcn_ className="flex gap-3">
+ <div className="relative">
+ <Input_Shadcn_
+ {...field}
+ className="w-80"
+ onKeyPress={(event) => {
+ if (event.key === 'Escape') form.reset()
+ }}
+ type="number"
+ />
+ <RotateCcw
+ className={cn(
+ 'text-foreground-lighter transition hover:text cursor-pointer',
+ 'w-4 h-4 absolute right-3 top-3',
+ 'duration-150',
+
+ field.value !== String(connection.metadata?.supabaseConfig?.branchLimit)
+ ? 'opacity-100 transition'
+ : 'opacity-0'
+ )}
+ onClick={() => form.reset()}
+ />
+ <Button
+ loading={isUpdatingConnection}
+ className={cn(
+ 'duration-150 transition',
+ field.value !== String(connection.metadata?.supabaseConfig?.branchLimit)
+ ? 'opacity-100'
+ : 'opacity-0'
+ )}
+ htmlType="submit"
+ disabled={
+ field.value === String(connection.metadata?.supabaseConfig?.branchLimit)
+ }
+ >
+ Update
+ </Button>
+ </div>
+ </FormControl_Shadcn_>
+ </FormItem_Shadcn_>
+ )}
+ />
+
<FormField_Shadcn_
control={form.control}
name="supabaseDirectory"
diff --git a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
index be7f4e8ccbd..6fe2032fb93 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GithubSection.tsx
@@ -149,7 +149,8 @@ const GitHubSection = () => {
name: connection.repository.name,
supabaseConfig: {
supabaseDirectory: connection.workdir,
- supabaseChangesOnly: (connection as any).supabase_changes_only, //[Joshen] potentially API codegen issue
+ supabaseChangesOnly: connection.supabase_changes_only,
+ branchLimit: connection.branch_limit,
},
} as any,
}}
diff --git a/apps/studio/data/integrations/github-connection-update-mutation.ts b/apps/studio/data/integrations/github-connection-update-mutation.ts
index 737970d0ff4..a7158b1146a 100644
--- a/apps/studio/data/integrations/github-connection-update-mutation.ts
+++ b/apps/studio/data/integrations/github-connection-update-mutation.ts
@@ -10,16 +10,17 @@ type UpdateVariables = {
organizationId: number
workdir: string
supabaseChangesOnly: boolean
+ branchLimit: number
}
export async function updateConnection(
- { connectionId, workdir, supabaseChangesOnly }: UpdateVariables,
+ { connectionId, workdir, supabaseChangesOnly, branchLimit }: UpdateVariables,
signal?: AbortSignal
) {
const { data, error } = await patch('/platform/integrations/github/connections/{connection_id}', {
params: { path: { connection_id: String(connectionId) } },
signal,
- body: { workdir, supabase_changes_only: supabaseChangesOnly },
+ body: { workdir, supabase_changes_only: supabaseChangesOnly, branch_limit: branchLimit },
})
if (error) handleError(error)
diff --git a/apps/studio/data/integrations/integrations.types.ts b/apps/studio/data/integrations/integrations.types.ts
index 4027e04e80a..9ba950b4b3d 100644
--- a/apps/studio/data/integrations/integrations.types.ts
+++ b/apps/studio/data/integrations/integrations.types.ts
@@ -140,6 +140,7 @@ export type Imetadata = {
}
supabaseDirectory?: string
supabaseChangesOnly?: boolean
+ branchLimit?: number
}
link?: VercelGitLink
name: string