diff --git a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx index 34c82f89e86..2026093d02b 100644 --- a/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx +++ b/apps/studio/components/interfaces/BranchManagement/CreateBranchModal.tsx @@ -136,10 +136,10 @@ export const CreateBranchModal = ({ visible, onClose }: CreateBranchModalProps) return } - if (val.gitBranchName && val.gitBranchName.length > 0 && githubConnection?.id) { + if (val.gitBranchName && val.gitBranchName.length > 0 && githubConnection?.repository.id) { try { await checkGithubBranchValidity({ - connectionId: githubConnection.id, + repositoryId: githubConnection.repository.id, branchName: val.gitBranchName, }) // valid – no issues added diff --git a/apps/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx b/apps/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx index aa9c4f93337..54cabb1f86a 100644 --- a/apps/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx +++ b/apps/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx @@ -72,8 +72,6 @@ const SidePanelGitHubRepoLinker = ({ projectRef }: SidePanelGitHubRepoLinkerProp enabled: visible && Boolean(gitHubAuthorization), }) - console.log('githubReposData', githubReposData) - const { data: connections } = useGitHubConnectionsQuery( { organizationId: selectedOrganization?.id, @@ -157,10 +155,10 @@ const SidePanelGitHubRepoLinker = ({ projectRef }: SidePanelGitHubRepoLinkerProp return } - if (existingConnection?.id && val.branchName && val.branchName.length > 0) { + if (selectedRepo?.id && val.branchName && val.branchName.length > 0) { try { await checkGithubBranchValidity({ - connectionId: Number(existingConnection.id), + repositoryId: Number(selectedRepo.id), branchName: val.branchName, }) } catch (error) { @@ -283,6 +281,9 @@ const SidePanelGitHubRepoLinker = ({ projectRef }: SidePanelGitHubRepoLinkerProp installation_id: selectedRepo.installation_id!, project_ref: projectRef, repository_id: Number(selectedRepo.id), + workdir: data.supabaseDirectory, + supabaseChangesOnly: data.supabaseChangesOnly, + branchLimit: Number(data.branchLimit), }, }) } else { @@ -301,6 +302,9 @@ const SidePanelGitHubRepoLinker = ({ projectRef }: SidePanelGitHubRepoLinkerProp installation_id: selectedRepo.installation_id!, project_ref: projectRef, repository_id: Number(selectedRepo.id), + workdir: data.supabaseDirectory, + supabaseChangesOnly: data.supabaseChangesOnly, + branchLimit: Number(data.branchLimit), }, }) } @@ -501,7 +505,7 @@ const SidePanelGitHubRepoLinker = ({ projectRef }: SidePanelGitHubRepoLinkerProp
@@ -532,7 +536,7 @@ const SidePanelGitHubRepoLinker = ({ projectRef }: SidePanelGitHubRepoLinkerProp {...field} placeholder="supabase" autoComplete="off" - disabled={!existingConnection || !autoBranchingEnabled} + disabled={!autoBranchingEnabled} /> @@ -554,7 +558,7 @@ const SidePanelGitHubRepoLinker = ({ projectRef }: SidePanelGitHubRepoLinkerProp {...field} type="number" autoComplete="off" - disabled={!existingConnection || !autoBranchingEnabled} + disabled={!autoBranchingEnabled} /> @@ -575,7 +579,7 @@ const SidePanelGitHubRepoLinker = ({ projectRef }: SidePanelGitHubRepoLinkerProp field.onChange(val)} - disabled={!existingConnection || !autoBranchingEnabled} + disabled={!autoBranchingEnabled} /> diff --git a/apps/studio/data/integrations/github-branch-check-query.ts b/apps/studio/data/integrations/github-branch-check-query.ts index 6f7d8bffa78..e6046666972 100644 --- a/apps/studio/data/integrations/github-branch-check-query.ts +++ b/apps/studio/data/integrations/github-branch-check-query.ts @@ -5,20 +5,20 @@ import { get, handleError } from 'data/fetchers' import type { ResponseError } from 'types' export type GithubBranchVariables = { - connectionId: number + repositoryId: number branchName: string } export async function checkGithubBranchValidity( - { connectionId, branchName }: GithubBranchVariables, + { repositoryId, branchName }: GithubBranchVariables, signal?: AbortSignal ) { const { data, error } = await get( - '/platform/integrations/github/branches/{connectionId}/{branchName}', + '/platform/integrations/github/repositories/{repositoryId}/branches/{branchName}', { params: { path: { - connectionId, + repositoryId, branchName, }, }, diff --git a/packages/api-types/types/platform.d.ts b/packages/api-types/types/platform.d.ts index 208765a7f5e..8c7437b1260 100644 --- a/packages/api-types/types/platform.d.ts +++ b/packages/api-types/types/platform.d.ts @@ -622,6 +622,44 @@ export interface paths { patch?: never trace?: never } + '/platform/integrations/github/repositories/{repositoryId}/branches': { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + /** List GitHub repository branches */ + get: operations['GitHubRepositoriesController_listRepositoryBranches'] + put?: never + post?: never + delete?: never + options?: never + head?: never + patch?: never + trace?: never + } + '/platform/integrations/github/repositories/{repositoryId}/branches/{branchName}': { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + /** + * Get GitHub repository branch + * @deprecated + * @description This is a temporary endpoint before dashboard switches to combo box + */ + get: operations['GitHubRepositoriesController_getRepository'] + put?: never + post?: never + delete?: never + options?: never + head?: never + patch?: never + trace?: never + } '/platform/integrations/vercel': { parameters: { query?: never @@ -2106,8 +2144,7 @@ export interface paths { /** Gets project's logs */ get: operations['LogsController_getApiPaths'] put?: never - /** Post project's logs */ - post: operations['LogsController_postApiPaths'] + post?: never delete?: never options?: never head?: never @@ -4422,10 +4459,22 @@ export interface components { CreateGitHubAuthorizationBody: { code: string } - CreateGitHubConnectionsBody: { + CreateGitHubConnectionBody: { + branch_limit?: number installation_id: number project_ref: string repository_id: number + supabase_changes_only?: boolean + workdir?: string + } + CreateGitHubConnectionResponse: { + branch_limit: number + id: number + inserted_at: string + installation_id: number + supabase_changes_only: boolean + updated_at: string + workdir: string } CreateInvitationBody: { email: string @@ -5617,6 +5666,9 @@ export interface components { sender_id: number user_id: number } + GitHubBranchResponse: { + name: string + } GoTrueConfigResponse: { API_MAX_REQUEST_DURATION: number | null DB_MAX_POOL_SIZE: number | null @@ -5958,6 +6010,14 @@ export interface components { workdir: string }[] } + ListGitHubRepositoriesResponse: { + repositories: { + default_branch: string + id: number + installation_id: number + name: string + }[] + } ListNotificationExceptionsResponse: { exceptions: { /** Format: uuid */ @@ -5991,6 +6051,11 @@ export interface components { oauth_app_id: string }[] } + ListRepositoryBranchesResponse: { + branches: { + name: string + }[] + } LoadBalancerDetailResponse: { databases: { identifier: string @@ -6705,9 +6770,6 @@ export interface components { name: string schema: string } - PostProjectLogsBody: { - sql: string - } PreviewProjectTransferResponse: { errors: { key: string @@ -9637,7 +9699,9 @@ export interface operations { headers: { [name: string]: unknown } - content?: never + content: { + 'application/json': components['schemas']['GitHubBranchResponse'][] + } } /** @description Failed to list GitHub connection branches */ 500: { @@ -9664,7 +9728,9 @@ export interface operations { headers: { [name: string]: unknown } - content?: never + content: { + 'application/json': components['schemas']['GitHubBranchResponse'] + } } /** @description Failed to get GitHub connection branch */ 500: { @@ -9712,7 +9778,7 @@ export interface operations { } requestBody: { content: { - 'application/json': components['schemas']['CreateGitHubConnectionsBody'] + 'application/json': components['schemas']['CreateGitHubConnectionBody'] } } responses: { @@ -9720,7 +9786,9 @@ export interface operations { headers: { [name: string]: unknown } - content?: never + content: { + 'application/json': components['schemas']['CreateGitHubConnectionResponse'] + } } /** @description Failed to create project connections */ 500: { @@ -9800,7 +9868,9 @@ export interface operations { headers: { [name: string]: unknown } - content?: never + content: { + 'application/json': components['schemas']['ListGitHubRepositoriesResponse'] + } } /** @description Failed to get GitHub repositories for user */ 500: { @@ -9811,6 +9881,63 @@ export interface operations { } } } + GitHubRepositoriesController_listRepositoryBranches: { + parameters: { + query?: never + header?: never + path: { + repositoryId: number + } + cookie?: never + } + requestBody?: never + responses: { + 200: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['ListRepositoryBranchesResponse'] + } + } + /** @description Failed to list GitHub repository branches */ + 500: { + headers: { + [name: string]: unknown + } + content?: never + } + } + } + GitHubRepositoriesController_getRepository: { + parameters: { + query?: never + header?: never + path: { + branchName: string + repositoryId: number + } + cookie?: never + } + requestBody?: never + responses: { + 200: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['GitHubBranchResponse'] + } + } + /** @description Failed to get GitHub repository branch */ + 500: { + headers: { + [name: string]: unknown + } + content?: never + } + } + } VercelIntegrationController_createVercelIntegration: { parameters: { query?: never @@ -14482,50 +14609,6 @@ export interface operations { } } } - LogsController_postApiPaths: { - parameters: { - query?: { - iso_timestamp_end?: string - iso_timestamp_start?: string - project?: string - sql?: string - } - header?: never - path: { - /** @description Project ref */ - ref: string - } - cookie?: never - } - requestBody: { - content: { - 'application/json': components['schemas']['PostProjectLogsBody'] - } - } - responses: { - 201: { - headers: { - [name: string]: unknown - } - content: { - 'application/json': components['schemas']['AnalyticsResponse'] - } - } - 403: { - headers: { - [name: string]: unknown - } - content?: never - } - /** @description Failed to POST project's logs */ - 500: { - headers: { - [name: string]: unknown - } - content?: never - } - } - } UsageApiController_getApiCounts: { parameters: { query?: {