mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
Integrate updated GH PR endpoint (#18774)
* Integrate updated GH PR endpoint * Address comments
This commit is contained in:
1 parent
b89c4d285c
commit
01408f7e56
5 files changed
+21
-59
No files matched your search
@@ -70,6 +70,10 @@ const BranchManagement = () => {
|
||||
} = useBranchesQuery({ projectRef })
|
||||
const [[mainBranch], previewBranches] = partition(branches, (branch) => branch.is_default)
|
||||
const branchesWithPRs = previewBranches.filter((branch) => branch.pr_number !== undefined)
|
||||
const prNumbers =
|
||||
branches !== undefined
|
||||
? (branchesWithPRs.map((branch) => branch.pr_number).filter(Boolean) as number[])
|
||||
: undefined
|
||||
|
||||
const githubIntegration = integrations?.find(
|
||||
(integration) =>
|
||||
@@ -92,7 +96,7 @@ const BranchManagement = () => {
|
||||
organizationIntegrationId: githubIntegration?.id,
|
||||
repoOwner,
|
||||
repoName,
|
||||
target: mainBranch?.git_branch,
|
||||
prNumbers,
|
||||
})
|
||||
const pullRequests = allPullRequests ?? []
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ export const BranchRow = ({
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isMain ? (
|
||||
<div className="flex items-center gap-x-2">
|
||||
<Button asChild type="default" iconRight={<IconExternalLink />}>
|
||||
|
||||
Vendored
-39
@@ -4763,40 +4763,6 @@ export interface components {
|
||||
extensionId: string
|
||||
items: components['schemas']['ResourceBillingItem'][]
|
||||
}
|
||||
ResourceProvisioningBody: {
|
||||
/** @description A UNIX epoch timestamp value */
|
||||
timestamp: number
|
||||
/** @description A random unique string identifying the individual request */
|
||||
nonce: string
|
||||
/** @description The full request target URL */
|
||||
url: string
|
||||
/** @description Name of the extension */
|
||||
name: string
|
||||
/** @description Unique ID representing the extension */
|
||||
id: string
|
||||
/** @description Unique ID representing an organization */
|
||||
organization_id: string
|
||||
/** @description Display name for an organization */
|
||||
organization_name: string
|
||||
/** @description Obfuscated email that routes to all organization admins */
|
||||
organization_email: string
|
||||
/** @description Obfuscated email that routes to the provisioning user */
|
||||
user_email: string
|
||||
/** @description Unique ID representing an user */
|
||||
user_id: string
|
||||
/** @description The three-letter, primary Fly.io region where the target app intends to write from */
|
||||
primary_region: string
|
||||
/** @description An IPv6 address on the customer network assigned to this extension */
|
||||
ip_address: string
|
||||
/**
|
||||
* @description An array of Fly.io region codes where read replicas should be provisioned
|
||||
* @default []
|
||||
*/
|
||||
read_regions: string[]
|
||||
/** @description Database password (Optional, don't send to generate one) */
|
||||
db_pass?: string
|
||||
user_name: string
|
||||
}
|
||||
ResourceProvisioningConfigResponse: {
|
||||
/**
|
||||
* @description PSQL connection string
|
||||
@@ -12340,11 +12306,6 @@ export interface operations {
|
||||
}
|
||||
/** Creates a database */
|
||||
ExtensionsController_provisionResource: {
|
||||
requestBody: {
|
||||
content: {
|
||||
'application/json': components['schemas']['ResourceProvisioningBody']
|
||||
}
|
||||
}
|
||||
responses: {
|
||||
201: {
|
||||
content: {
|
||||
|
||||
@@ -8,27 +8,30 @@ export type GithubPullRequestsVariables = {
|
||||
organizationIntegrationId?: string
|
||||
repoOwner: string
|
||||
repoName: string
|
||||
target?: string
|
||||
prNumbers?: number[]
|
||||
}
|
||||
|
||||
export type GitHubPullRequest = components['schemas']['GetGithubPullRequest']
|
||||
|
||||
export async function getGitHubPullRequests(
|
||||
{ organizationIntegrationId, repoOwner, repoName, target }: GithubPullRequestsVariables,
|
||||
{ organizationIntegrationId, repoOwner, repoName, prNumbers }: GithubPullRequestsVariables,
|
||||
signal?: AbortSignal
|
||||
) {
|
||||
if (!organizationIntegrationId) throw new Error('Organization integration ID is required')
|
||||
if (!target) throw new Error('Target branch is required')
|
||||
if (!prNumbers) throw new Error('A list of PR numbers is required')
|
||||
|
||||
const { data, error } = await get(
|
||||
`/platform/integrations/github/pull-requests/{organization_integration_id}/{repo_owner}/{repo_name}/{target}`,
|
||||
`/platform/integrations/github/pull-requests/{organization_integration_id}/{repo_owner}/{repo_name}`,
|
||||
{
|
||||
params: {
|
||||
path: {
|
||||
organization_integration_id: organizationIntegrationId,
|
||||
repo_owner: repoOwner,
|
||||
repo_name: repoName,
|
||||
target,
|
||||
},
|
||||
query: {
|
||||
// @ts-ignore generated api types is incorrect here, to remove ignore statement once fixed
|
||||
pr_number: prNumbers,
|
||||
},
|
||||
},
|
||||
signal,
|
||||
@@ -43,23 +46,24 @@ export type GithubPullRequestsData = Awaited<ReturnType<typeof getGitHubPullRequ
|
||||
export type GithubPullRequestsError = ResponseError
|
||||
|
||||
export const useGithubPullRequestsQuery = <TData = GithubPullRequestsData>(
|
||||
{ organizationIntegrationId, repoOwner, repoName, target }: GithubPullRequestsVariables,
|
||||
{ organizationIntegrationId, repoOwner, repoName, prNumbers }: GithubPullRequestsVariables,
|
||||
{
|
||||
enabled = true,
|
||||
...options
|
||||
}: UseQueryOptions<GithubPullRequestsData, GithubPullRequestsError, TData> = {}
|
||||
) =>
|
||||
useQuery<GithubPullRequestsData, GithubPullRequestsError, TData>(
|
||||
integrationKeys.githubPullRequestsList(organizationIntegrationId, repoOwner, repoName, target),
|
||||
// [Joshen] Just fyi im not sure if we need to include prNumber in the RQ key here
|
||||
integrationKeys.githubPullRequestsList(organizationIntegrationId, repoOwner, repoName),
|
||||
({ signal }) =>
|
||||
getGitHubPullRequests({ organizationIntegrationId, repoOwner, repoName, target }, signal),
|
||||
getGitHubPullRequests({ organizationIntegrationId, repoOwner, repoName, prNumbers }, signal),
|
||||
{
|
||||
enabled:
|
||||
enabled &&
|
||||
typeof organizationIntegrationId !== 'undefined' &&
|
||||
typeof repoOwner !== 'undefined' &&
|
||||
typeof repoName !== 'undefined' &&
|
||||
typeof target !== 'undefined',
|
||||
typeof prNumbers !== 'undefined',
|
||||
...options,
|
||||
}
|
||||
)
|
||||
@@ -29,16 +29,8 @@ export const integrationKeys = {
|
||||
githubPullRequestsList: (
|
||||
organization_integration_id: string | undefined,
|
||||
repo_owner: string,
|
||||
repo_name: string,
|
||||
target: string | undefined
|
||||
) => [
|
||||
'organizations',
|
||||
organization_integration_id,
|
||||
'pull-requests',
|
||||
repo_owner,
|
||||
repo_name,
|
||||
target,
|
||||
],
|
||||
repo_name: string
|
||||
) => ['organizations', organization_integration_id, 'pull-requests', repo_owner, repo_name],
|
||||
githubConnectionsList: (organization_integration_id: string | undefined) =>
|
||||
['organizations', organization_integration_id, 'github-connections'] as const,
|
||||
}
|
||||
Reference in new issue
Block a user