mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
* start new github integration * query/mutation updates * progress * branch management * update codegen * progress * progress * Refactor GitHub integration URLs * Refactor GitHubIntegrationAuthorize component * Updates * Do not remove GitHub connection when creating new one * Deleting a GH connection when branching is enabled for the project, will also disable branching for that project * Add link to configure connection from org integration settings page * Slight refactor * Support updating CWD path * Change cwd_path to workdir and disallow empty values * Allow for triggering branches on supabase directory changes only * Pass missing supabaseChangesOnly value * Small style fix * Add Authorization GitHub step * Small change * Fix supabase integrations form in project settings * Revert URLa nd client ID * Fix UI issues --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Kamil Ogórek <kamil.ogorek@gmail.com>
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
import { get } from 'data/fetchers'
|
|
import { integrationKeys } from './keys'
|
|
import { ResponseError } from 'types'
|
|
import { components } from 'data/api'
|
|
|
|
export type GitHubPullRequestsVariables = {
|
|
connectionId?: number
|
|
prNumbers?: number[]
|
|
}
|
|
|
|
// TODO(alaister): find the actual type
|
|
export type GitHubPullRequest = any
|
|
|
|
export async function getGitHubPullRequests(
|
|
{ connectionId, prNumbers = [] }: GitHubPullRequestsVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
if (!connectionId) throw new Error('connectionId is required')
|
|
|
|
const { data, error } = await get(`/platform/integrations/github/pull-requests/{connectionId}`, {
|
|
params: {
|
|
path: {
|
|
connectionId,
|
|
},
|
|
query: {
|
|
pr_number: prNumbers,
|
|
},
|
|
},
|
|
signal,
|
|
})
|
|
|
|
if (error) throw error
|
|
return data
|
|
}
|
|
|
|
export type GitHubPullRequestsData = Awaited<ReturnType<typeof getGitHubPullRequests>>
|
|
export type GitHubPullRequestsError = ResponseError
|
|
|
|
export const useGitHubPullRequestsQuery = <TData = GitHubPullRequestsData>(
|
|
{ connectionId, prNumbers }: GitHubPullRequestsVariables,
|
|
{
|
|
enabled = true,
|
|
...options
|
|
}: UseQueryOptions<GitHubPullRequestsData, GitHubPullRequestsError, TData> = {}
|
|
) =>
|
|
useQuery<GitHubPullRequestsData, GitHubPullRequestsError, TData>(
|
|
integrationKeys.githubPullRequestsList(connectionId, prNumbers),
|
|
({ signal }) => getGitHubPullRequests({ connectionId, prNumbers }, signal),
|
|
{
|
|
enabled: enabled && typeof connectionId !== 'undefined',
|
|
...options,
|
|
}
|
|
)
|