Skip to content

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

Add support for github pull requests

Joshen Lim59108c68617f
diff --git a/studio/components/interfaces/BranchManagement/BranchManagement.tsx b/studio/components/interfaces/BranchManagement/BranchManagement.tsx
index e7c892dd3d6..3936a1f7917 100644
--- a/studio/components/interfaces/BranchManagement/BranchManagement.tsx
+++ b/studio/components/interfaces/BranchManagement/BranchManagement.tsx
@@ -1,4 +1,4 @@
-import { partition } from 'lodash'
+import { isError, partition } from 'lodash'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useState } from 'react'
@@ -43,7 +43,7 @@ const BranchManagement = () => {
const isBranchingAllowed = true
const isBranch = projectDetails?.parent_project_ref !== undefined
- const hasBranchEnabled = projectDetails?.has_branch_enabled
+ const hasBranchEnabled = projectDetails?.is_branch_enabled
const projectRef =
projectDetails !== undefined ? (isBranch ? projectDetails.parent_project_ref : ref) : undefined
@@ -52,9 +52,13 @@ const BranchManagement = () => {
const [showDisableBranching, setShowDisableBranching] = useState(false)
const [selectedBranchToDelete, setSelectedBranchToDelete] = useState<Branch>()
- const { data: integrations, isLoading: isLoadingIntegrations } = useOrgIntegrationsQuery({
- orgSlug: selectedOrg?.slug,
- })
+ const {
+ data: integrations,
+ error: integrationsError,
+ isLoading: isLoadingIntegrations,
+ isError: isErrorIntegrations,
+ isSuccess: isSuccessIntegrations,
+ } = useOrgIntegrationsQuery({ orgSlug: selectedOrg?.slug })
const githubIntegration = integrations?.find(
(integration) =>
integration.integration.name === 'GitHub' &&
@@ -64,7 +68,7 @@ const BranchManagement = () => {
(connection) => connection.supabase_project_ref === ref
)
- const { data: branches, error, isLoading, isError, isSuccess } = useBranchesQuery({ projectRef })
+ const { data: branches } = useBranchesQuery({ projectRef })
const [[mainBranch], previewBranches] = partition(branches, (branch) => branch.is_default)
const { mutate: deleteBranch, isLoading: isDeleting } = useBranchDeleteMutation({
@@ -93,11 +97,11 @@ const BranchManagement = () => {
},
})
- const generatePullRequestURL = (branch?: string) => {
+ const generateCreatePullRequestURL = (branch?: string) => {
if (githubConnection === undefined) return 'https://github.com'
return branch !== undefined
- ? `https://github.com/${githubConnection.metadata.name}/compare/${mainBranch.git_branch}...${branch}`
+ ? `https://github.com/${githubConnection.metadata.name}/compare/${mainBranch?.git_branch}...${branch}`
: `https://github.com/${githubConnection.metadata.name}/compare`
}
@@ -162,9 +166,14 @@ const BranchManagement = () => {
<Button onClick={() => setShowCreateBranch(true)}>Create preview branch</Button>
</div>
<div className="">
- {isLoading && <GenericSkeletonLoader />}
- {isError && <AlertError error={error} subject="Failed to retrieve branches" />}
- {isSuccess && mainBranch !== undefined && (
+ {isLoadingIntegrations && <GenericSkeletonLoader />}
+ {isErrorIntegrations && (
+ <AlertError
+ error={integrationsError}
+ subject="Failed to retrieve GitHub integration connection"
+ />
+ )}
+ {isSuccessIntegrations && (
<>
<MainBranchPanel
repo={githubConnection?.metadata.name}
@@ -173,11 +182,10 @@ const BranchManagement = () => {
/>
<PullRequests
previewBranches={previewBranches}
- generatePullRequestURL={generatePullRequestURL}
+ generateCreatePullRequestURL={generateCreatePullRequestURL}
/>
<PreviewBranches
- previewBranches={previewBranches}
- generatePullRequestURL={generatePullRequestURL}
+ generateCreatePullRequestURL={generateCreatePullRequestURL}
onSelectCreateBranch={() => setShowCreateBranch(true)}
onSelectDeleteBranch={setSelectedBranchToDelete}
/>
diff --git a/studio/components/interfaces/BranchManagement/BranchPanels.tsx b/studio/components/interfaces/BranchManagement/BranchPanels.tsx
index 074d6f02a91..13124713f6a 100644
--- a/studio/components/interfaces/BranchManagement/BranchPanels.tsx
+++ b/studio/components/interfaces/BranchManagement/BranchPanels.tsx
@@ -22,15 +22,17 @@ import {
} from 'ui'
import { Markdown } from 'components/interfaces/Markdown'
+import ShimmeringLoader from 'components/ui/ShimmeringLoader'
import { Branch } from 'data/branches/branches-query'
+import { GitHubPullRequest } from 'data/integrations/integrations-github-pull-requests-query'
interface BranchPanelProps {
repo?: string
- branch: Branch
+ branch?: Branch
onSelectUpdate?: () => void
onSelectDelete?: () => void
onSelectDisableBranching?: () => void
- generatePullRequestURL?: (branch?: string) => string
+ generateCreatePullRequestURL?: (branch?: string) => string
}
const MainBranchPanel = ({
@@ -41,7 +43,7 @@ const MainBranchPanel = ({
}: BranchPanelProps) => {
const { ref } = useParams()
const [open, setOpen] = useState(false)
- const isActive = ref === branch.project_ref
+ const isActive = ref === branch?.project_ref
return (
<div className="border rounded-lg">
@@ -66,41 +68,52 @@ const MainBranchPanel = ({
</div>
</div>
<div className="bg-surface-100 border-t shadow-sm flex justify-between items-center pl-8 pr-6 py-3 rounded-b-lg text-sm">
- <div className="flex items-center space-x-4">
- <div className="w-8 h-8 bg-amber-300 rounded-md flex items-center justify-center">
- <IconShield size={18} strokeWidth={2} className="text-amber-900" />
- </div>
- <p>{branch.name}</p>
- <Badge color="amber">Production</Badge>
- {isActive && <Badge color="green">Selected</Badge>}
- </div>
- <div className="flex items-center space-x-4">
- <DropdownMenu_Shadcn_ open={open} onOpenChange={() => setOpen(!open)} modal={false}>
- <DropdownMenuTrigger_Shadcn_>
- <Button asChild type="text" className="px-1" icon={<IconMoreVertical size={14} />}>
- <span></span>
- </Button>
- </DropdownMenuTrigger_Shadcn_>
- <DropdownMenuContent_Shadcn_ side="bottom" align="end">
- <Link passHref href={`/project/${ref}/settings/general`}>
- <DropdownMenuItem_Shadcn_
- asChild
- className="flex gap-2"
- onSelect={() => onSelectUpdate()}
- >
- <a>Change production branch</a>
- </DropdownMenuItem_Shadcn_>
- </Link>
- <Dropdown.Separator />
- <DropdownMenuItem_Shadcn_
- className="flex gap-2"
- onSelect={() => onSelectDisableBranching()}
- >
- Disable branching
- </DropdownMenuItem_Shadcn_>
- </DropdownMenuContent_Shadcn_>
- </DropdownMenu_Shadcn_>
- </div>
+ {branch === undefined ? (
+ <ShimmeringLoader className="w-full" />
+ ) : (
+ <>
+ <div className="flex items-center space-x-4">
+ <div className="w-8 h-8 bg-amber-300 rounded-md flex items-center justify-center">
+ <IconShield size={18} strokeWidth={2} className="text-amber-900" />
+ </div>
+ <p>{branch?.name}</p>
+ <Badge color="amber">Production</Badge>
+ {isActive && <Badge color="green">Selected</Badge>}
+ </div>
+ <div className="flex items-center space-x-4">
+ <DropdownMenu_Shadcn_ open={open} onOpenChange={() => setOpen(!open)} modal={false}>
+ <DropdownMenuTrigger_Shadcn_>
+ <Button
+ asChild
+ type="text"
+ className="px-1"
+ icon={<IconMoreVertical size={14} />}
+ >
+ <span></span>
+ </Button>
+ </DropdownMenuTrigger_Shadcn_>
+ <DropdownMenuContent_Shadcn_ side="bottom" align="end">
+ <Link passHref href={`/project/${ref}/settings/general`}>
+ <DropdownMenuItem_Shadcn_
+ asChild
+ className="flex gap-2"
+ onSelect={() => onSelectUpdate()}
+ >
+ <a>Change production branch</a>
+ </DropdownMenuItem_Shadcn_>
+ </Link>
+ <Dropdown.Separator />
+ <DropdownMenuItem_Shadcn_
+ className="flex gap-2"
+ onSelect={() => onSelectDisableBranching()}
+ >
+ Disable branching
+ </DropdownMenuItem_Shadcn_>
+ </DropdownMenuContent_Shadcn_>
+ </DropdownMenu_Shadcn_>
+ </div>
+ </>
+ )}
</div>
</div>
)
@@ -124,33 +137,33 @@ const BranchContainer = ({ className, children }: PropsWithChildren<{ className?
const BranchPanel = ({
branch,
- generatePullRequestURL,
+ generateCreatePullRequestURL,
onSelectDelete = noop,
}: BranchPanelProps) => {
const { ref } = useParams()
const [open, setOpen] = useState(false)
- const isActive = ref === branch.project_ref
- const daysFromNow = dayjs().diff(dayjs(branch.created_at), 'day')
- const formattedTimeFromNow = dayjs(branch.created_at).fromNow()
- const formattedCreatedAt = dayjs(branch.created_at).format('DD MMM YYYY, HH:mm:ss (ZZ)')
+ const isActive = ref === branch?.project_ref
+ const daysFromNow = dayjs().diff(dayjs(branch?.created_at), 'day')
+ const formattedTimeFromNow = dayjs(branch?.created_at).fromNow()
+ const formattedCreatedAt = dayjs(branch?.created_at).format('DD MMM YYYY, HH:mm:ss (ZZ)')
- const pullRequestURL = generatePullRequestURL?.(branch.name) ?? 'https://github.com'
+ const pullRequestURL = generateCreatePullRequestURL?.(branch?.name) ?? 'https://github.com'
return (
<BranchContainer className="bg-surface-100">
<div className="flex items-center space-x-4">
- <IconGitBranch className="text-brand-900" size={16} strokeWidth={2} />
- <p>{branch.name}</p>
+ <IconGitBranch size={16} strokeWidth={2} />
+ <p>{branch?.name}</p>
{isActive && <Badge color="green">Selected</Badge>}
- <p className="text-scale-1000">
+ <p className="text-light">
{daysFromNow > 1 ? `Created on ${formattedCreatedAt}` : `Created ${formattedTimeFromNow}`}
</p>
</div>
<div className="flex items-center space-x-4">
<Link passHref href={pullRequestURL}>
<a target="_blank" rel="noreferrer">
- <Button>Create pull request</Button>
+ <Button icon={<IconExternalLink />}>Create pull request</Button>
</a>
</Link>
<DropdownMenu_Shadcn_ open={open} onOpenChange={() => setOpen(!open)} modal={false}>
@@ -193,5 +206,55 @@ const BranchHeader = forwardRef<HTMLDivElement, BranchHeader>(
}
)
+const PullRequestPanel = ({ pr }: { pr: GitHubPullRequest }) => {
+ const [open, setOpen] = useState(false)
+ const daysFromNow = dayjs().diff(dayjs(pr.created_at), 'day')
+ const formattedTimeFromNow = dayjs(pr.created_at).fromNow()
+ const formattedCreatedAt = dayjs(pr.created_at).format('DD MMM YYYY, HH:mm:ss (ZZ)')
+
+ return (
+ <BranchContainer className="bg-surface-100">
+ <div className="w-full">
+ <div className="flex items-center justify-between">
+ <div>
+ <div className="flex items-center space-x-4">
+ <IconGitBranch className="text-brand-900" size={16} strokeWidth={2} />
+ <p>{pr.branch}</p>
+ <p className="text-light">
+ {daysFromNow > 1
+ ? `Created on ${formattedCreatedAt}`
+ : `Created ${formattedTimeFromNow}`}
+ </p>
+ </div>
+ <p className="text-scale-1000 ml-8 mt-0.5">{pr.title}</p>
+ </div>
+ <div className="flex items-center space-x-4">
+ <Link passHref href={pr.url}>
+ <a target="_blank" rel="noreferrer">
+ <Button type="default" icon={<IconExternalLink />}>
+ View pull request
+ </Button>
+ </a>
+ </Link>
+ <DropdownMenu_Shadcn_ open={open} onOpenChange={() => setOpen(!open)} modal={false}>
+ <DropdownMenuTrigger_Shadcn_>
+ <Button asChild type="text" className="px-1" icon={<IconMoreVertical size={14} />}>
+ <span></span>
+ </Button>
+ </DropdownMenuTrigger_Shadcn_>
+ <DropdownMenuContent_Shadcn_ side="bottom" align="end">
+ <DropdownMenuItem_Shadcn_ className="flex gap-2" onSelect={() => {}}>
+ <IconTrash size={14} />
+ Delete branch
+ </DropdownMenuItem_Shadcn_>
+ </DropdownMenuContent_Shadcn_>
+ </DropdownMenu_Shadcn_>
+ </div>
+ </div>
+ </div>
+ </BranchContainer>
+ )
+}
+
BranchHeader.displayName = 'BranchHeader'
-export { BranchContainer, BranchHeader, BranchPanel, MainBranchPanel }
+export { BranchContainer, BranchHeader, BranchPanel, MainBranchPanel, PullRequestPanel }
diff --git a/studio/components/interfaces/BranchManagement/PreviewBranches.tsx b/studio/components/interfaces/BranchManagement/PreviewBranches.tsx
index 5c83d0a5fa2..872c52aedaa 100644
--- a/studio/components/interfaces/BranchManagement/PreviewBranches.tsx
+++ b/studio/components/interfaces/BranchManagement/PreviewBranches.tsx
@@ -1,63 +1,125 @@
import { Button, IconExternalLink, IconGitBranch } from 'ui'
-import { Branch } from 'data/branches/branches-query'
+import { Branch, useBranchesQuery } from 'data/branches/branches-query'
import { BranchContainer, BranchHeader, BranchPanel } from './BranchPanels'
+import { useParams } from 'common'
+import { useGithubPullRequestsQuery } from 'data/integrations/integrations-github-pull-requests-query'
+import { partition } from 'lodash'
+import { useSelectedOrganization } from 'hooks'
+import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-org-only'
+import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
+import AlertError from 'components/ui/AlertError'
interface PreviewBranchesProps {
- previewBranches: Branch[]
- generatePullRequestURL: (branch?: string) => string
+ generateCreatePullRequestURL: (branch?: string) => string
onSelectCreateBranch: () => void
onSelectDeleteBranch: (branch: Branch) => void
}
const PreviewBranches = ({
- previewBranches,
- generatePullRequestURL,
+ generateCreatePullRequestURL,
onSelectCreateBranch,
onSelectDeleteBranch,
}: PreviewBranchesProps) => {
+ const { ref } = useParams()
+ const selectedOrg = useSelectedOrganization()
+
+ const { data: integrations } = useOrgIntegrationsQuery({
+ orgSlug: selectedOrg?.slug,
+ })
+ const githubIntegration = integrations?.find(
+ (integration) =>
+ integration.integration.name === 'GitHub' &&
+ integration.organization.slug === selectedOrg?.slug
+ )
+ const githubConnection = githubIntegration?.connections.find(
+ (connection) => connection.supabase_project_ref === ref
+ )
+ const [repoOwner, repoName] = githubConnection?.metadata.name.split('/') || []
+
+ const {
+ data: branches,
+ error: branchesError,
+ isLoading: isLoadingBranches,
+ isError: isErrorBranches,
+ isSuccess: isSuccessBranches,
+ } = useBranchesQuery({ projectRef: ref })
+ const [[mainBranch], previewBranches] = partition(branches, (branch) => branch.is_default)
+
+ const { data: allPullRequests } = useGithubPullRequestsQuery({
+ organizationIntegrationId: githubIntegration?.id,
+ repoOwner,
+ repoName,
+ target: mainBranch?.git_branch,
+ })
+
+ const previewBranchesNotInPR = previewBranches.filter(
+ (branch) => !allPullRequests?.find((pr) => pr.branch === branch.git_branch)
+ )
+
return (
<>
<BranchHeader markdown={previewBranches.length > 0 ? `#### Preview branches` : undefined} />
- {previewBranches.length === 0 ? (
+
+ {isLoadingBranches && (
<BranchContainer>
- <div className="flex items-center flex-col justify-center w-full py-8">
- <p>No database preview branches</p>
- <p className="text-scale-1000">Database preview branches will be shown here</p>
- <div className="w-[500px] border rounded-md mt-4">
- <div className="px-5 py-3 bg-surface-100 flex items-center justify-between">
- <div className="flex items-center space-x-4">
- <IconGitBranch strokeWidth={2} className="text-scale-1100" />
- <div>
- <p>Create a preview branch</p>
- <p className="text-scale-1000">Start developing in preview</p>
+ <div className="w-full">
+ <GenericSkeletonLoader />
+ </div>
+ </BranchContainer>
+ )}
+
+ {isErrorBranches && (
+ <BranchContainer>
+ <div className="w-full">
+ <AlertError error={branchesError} subject="Failed to retrieve GitHub branches" />
+ </div>
+ </BranchContainer>
+ )}
+
+ {isSuccessBranches && (
+ <>
+ {previewBranches.length === 0 ? (
+ <BranchContainer>
+ <div className="flex items-center flex-col justify-center w-full py-8">
+ <p>No database preview branches</p>
+ <p className="text-scale-1000">Database preview branches will be shown here</p>
+ <div className="w-[500px] border rounded-md mt-4">
+ <div className="px-5 py-3 bg-surface-100 flex items-center justify-between">
+ <div className="flex items-center space-x-4">
+ <IconGitBranch strokeWidth={2} className="text-scale-1100" />
+ <div>
+ <p>Create a preview branch</p>
+ <p className="text-scale-1000">Start developing in preview</p>
+ </div>
+ </div>
+ <Button type="default" onClick={() => onSelectCreateBranch()}>
+ Create preview branch
+ </Button>
+ </div>
+ <div className="px-5 py-3 border-t flex items-center justify-between">
+ <div>
+ <p>Not sure what to do?</p>
+ <p className="text-scale-1000">Browse our documentation</p>
+ </div>
+ <Button type="default" iconRight={<IconExternalLink />}>
+ Docs
+ </Button>
</div>
</div>
- <Button type="default" onClick={() => onSelectCreateBranch()}>
- Create preview branch
- </Button>
- </div>
- <div className="px-5 py-3 border-t flex items-center justify-between">
- <div>
- <p>Not sure what to do?</p>
- <p className="text-scale-1000">Browse our documentation</p>
- </div>
- <Button type="default" iconRight={<IconExternalLink />}>
- Docs
- </Button>
</div>
- </div>
- </div>
- </BranchContainer>
- ) : (
- previewBranches.map((branch) => (
- <BranchPanel
- key={branch.id}
- branch={branch}
- generatePullRequestURL={generatePullRequestURL}
- onSelectDelete={() => onSelectDeleteBranch(branch)}
- />
- ))
+ </BranchContainer>
+ ) : (
+ previewBranchesNotInPR.map((branch) => (
+ <BranchPanel
+ key={branch.id}
+ branch={branch}
+ generateCreatePullRequestURL={generateCreatePullRequestURL}
+ onSelectDelete={() => onSelectDeleteBranch(branch)}
+ />
+ ))
+ )}
+ </>
)}
</>
)
diff --git a/studio/components/interfaces/BranchManagement/PullRequests.tsx b/studio/components/interfaces/BranchManagement/PullRequests.tsx
index fbcd4c6e84c..6c9ca01ce76 100644
--- a/studio/components/interfaces/BranchManagement/PullRequests.tsx
+++ b/studio/components/interfaces/BranchManagement/PullRequests.tsx
@@ -1,64 +1,126 @@
import Link from 'next/link'
import { Button, IconExternalLink, IconGitBranch } from 'ui'
-import { Branch } from 'data/branches/branches-query'
-import { BranchContainer, BranchHeader } from './BranchPanels'
+import { useParams } from 'common'
+import { Branch, useBranchesQuery } from 'data/branches/branches-query'
+import { useGithubPullRequestsQuery } from 'data/integrations/integrations-github-pull-requests-query'
+import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-org-only'
+import { useSelectedOrganization } from 'hooks'
+import { BranchContainer, BranchHeader, PullRequestPanel } from './BranchPanels'
+import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
+import AlertError from 'components/ui/AlertError'
interface PullRequestsProps {
previewBranches: Branch[]
- generatePullRequestURL: (branch?: string) => string
+ generateCreatePullRequestURL: (branch?: string) => string
}
-const PullRequests = ({ previewBranches, generatePullRequestURL }: PullRequestsProps) => {
- const pullRequests = []
- const pullRequestUrl = generatePullRequestURL()
+const PullRequests = ({ previewBranches, generateCreatePullRequestURL }: PullRequestsProps) => {
+ const { ref } = useParams()
+ const selectedOrg = useSelectedOrganization()
+ const pullRequestUrl = generateCreatePullRequestURL()
+
+ const { data: integrations, isLoading: isLoadingIntegrations } = useOrgIntegrationsQuery({
+ orgSlug: selectedOrg?.slug,
+ })
+ const githubIntegration = integrations?.find(
+ (integration) =>
+ integration.integration.name === 'GitHub' &&
+ integration.organization.slug === selectedOrg?.slug
+ )
+
+ const githubConnection = githubIntegration?.connections?.find(
+ (connection) => connection.supabase_project_ref === ref
+ )
+ const [repoOwner, repoName] = githubConnection?.metadata.name.split('/') || []
+
+ const { data: branches, isLoading: isLoadingBranches } = useBranchesQuery({ projectRef: ref })
+ const mainBranch = branches?.find((branch) => branch.is_default)
+
+ const {
+ data: allPullRequests,
+ error: pullRequestsError,
+ isLoading: isLoadingPullRequests,
+ isError: isErrorPullRequests,
+ isSuccess: isSuccessPullRequests,
+ } = useGithubPullRequestsQuery({
+ organizationIntegrationId: githubIntegration?.id,
+ repoOwner,
+ repoName,
+ target: mainBranch?.git_branch,
+ })
+ const pullRequests = allPullRequests?.filter((pr) =>
+ branches?.some((branch) => branch.name === pr.branch)
+ )
+
+ const showEmptyState = previewBranches.length === 0 || (pullRequests || []).length === 0
return (
<>
<BranchHeader
- markdown={
- pullRequests.length > 0 && previewBranches.length > 0
- ? `#### Open pull requests`
- : undefined
- }
+ markdown={!showEmptyState ? `#### Preview branches in pull requests` : undefined}
/>
- {previewBranches.length === 0 || pullRequests.length === 0 ? (
+
+ {(isLoadingBranches || isLoadingPullRequests || isLoadingIntegrations) && (
<BranchContainer>
- <div className="flex items-center flex-col justify-center w-full py-8">
- <p>No pull requests made yet for this repository</p>
- <p className="text-scale-1000">
- Only pull requests with the ./migration directory changes will show here.
- </p>
- {previewBranches.length > 0 && (
- <div className="w-96 border rounded-md mt-4">
- <div className="px-5 py-3 bg-surface-100 flex items-center justify-between">
- <div className="flex items-center space-x-4">
- <IconGitBranch strokeWidth={2} className="text-scale-1100" />
- <p>Create a pull request</p>
- </div>
- <Link passHref href={pullRequestUrl}>
- <a target="_blank" rel="noreferrer">
+ <div className="w-full">
+ <GenericSkeletonLoader />
+ </div>
+ </BranchContainer>
+ )}
+
+ {isErrorPullRequests && (
+ <BranchContainer>
+ <div className="w-full">
+ <AlertError
+ error={pullRequestsError}
+ subject="Failed to retrieve GitHub pull requests"
+ />
+ </div>
+ </BranchContainer>
+ )}
+
+ {isSuccessPullRequests && (
+ <>
+ {showEmptyState ? (
+ <BranchContainer>
+ <div className="flex items-center flex-col justify-center w-full py-8">
+ <p>No pull requests made yet for this repository</p>
+ <p className="text-scale-1000">
+ Only pull requests with the ./migration directory changes will show here.
+ </p>
+ {previewBranches.length > 0 && (
+ <div className="w-96 border rounded-md mt-4">
+ <div className="px-5 py-3 bg-surface-100 flex items-center justify-between">
+ <div className="flex items-center space-x-4">
+ <IconGitBranch strokeWidth={2} className="text-scale-1100" />
+ <p>Create a pull request</p>
+ </div>
+ <Link passHref href={pullRequestUrl}>
+ <a target="_blank" rel="noreferrer">
+ <Button type="default" iconRight={<IconExternalLink />}>
+ Github
+ </Button>
+ </a>
+ </Link>
+ </div>
+ <div className="px-5 py-3 border-t flex items-center justify-between">
+ <div>
+ <p>Not sure what to do?</p>
+ <p className="text-scale-1000">Browse our documentation</p>
+ </div>
<Button type="default" iconRight={<IconExternalLink />}>
- Github
+ Docs
</Button>
- </a>
- </Link>
- </div>
- <div className="px-5 py-3 border-t flex items-center justify-between">
- <div>
- <p>Not sure what to do?</p>
- <p className="text-scale-1000">Browse our documentation</p>
+ </div>
</div>
- <Button type="default" iconRight={<IconExternalLink />}>
- Docs
- </Button>
- </div>
+ )}
</div>
- )}
- </div>
- </BranchContainer>
- ) : (
- <BranchContainer>State 3</BranchContainer>
+ </BranchContainer>
+ ) : (
+ pullRequests?.map((pr) => <PullRequestPanel key={pr.id} pr={pr} />)
+ )}
+ </>
)}
</>
)
diff --git a/studio/components/layouts/AppLayout/AppHeader.tsx b/studio/components/layouts/AppLayout/AppHeader.tsx
index b0c582465fb..dfa8b1950f1 100644
--- a/studio/components/layouts/AppLayout/AppHeader.tsx
+++ b/studio/components/layouts/AppLayout/AppHeader.tsx
@@ -22,7 +22,7 @@ const AppHeader = () => {
const isBranchingAllowed = project?.cloud_provider === 'FLY'
const isBranchingEnabled =
- project?.has_branch_enabled === true || project?.parent_project_ref !== undefined
+ project?.is_branch_enabled === true || project?.parent_project_ref !== undefined
return (
<div className="flex items-center justify-between px-4 py-1 bg-scale-200 border-b">
diff --git a/studio/data/api.d.ts b/studio/data/api.d.ts
index 1fce7b8a7a6..1c8540975f8 100644
--- a/studio/data/api.d.ts
+++ b/studio/data/api.d.ts
@@ -42,6 +42,13 @@ export interface paths {
/** Get infrastructure status */
get: operations["StatusController_getStatus"];
};
+ "/platform/projects-resource-warnings": {
+ /**
+ * Gets resource warnings for all projects accessible by the user
+ * @description Only returns the minimal project info
+ */
+ get: operations["ProjectsResourceWarningsController_getProjectsResourceWarnings"];
+ };
"/platform/auth/{ref}/config": {
/** Gets GoTrue config */
get: operations["GoTrueConfigController_getGoTrueConfig"];
@@ -99,7 +106,7 @@ export interface paths {
get: operations["HooksController_getHookLogs"];
};
"/platform/database/{ref}/hook-enable": {
- /** Enables hooks on the project */
+ /** Enables Database Webhooks on the project */
post: operations["HooksController_enableHooks"];
};
"/platform/database/{ref}/owner-reassign": {
@@ -738,6 +745,10 @@ export interface paths {
/** Gets github branches for a given repo */
get: operations["GitHubBranchController_getBranches"];
};
+ "/platform/integrations/github/pull-requests/{organization_integration_id}/{repo_owner}/{repo_name}/{target}": {
+ /** Gets github pull requests for a given repo */
+ get: operations["GitHubPullRequestController_getPullRequests"];
+ };
"/system/auth/{ref}/templates/{template}": {
/** Gets GoTrue template */
get: operations["AuthTemplateController_getTemplate"];
@@ -899,7 +910,7 @@ export interface paths {
get: operations["HooksController_getHookLogs"];
};
"/v0/database/{ref}/hook-enable": {
- /** Enables hooks on the project */
+ /** Enables Database Webhooks on the project */
post: operations["HooksController_enableHooks"];
};
"/v0/organizations": {
@@ -1371,10 +1382,6 @@ export interface paths {
/** Updates project's postgrest config */
patch: operations["PostgrestConfigController_updatePostgRESTConfig"];
};
- "/v1/projects/{ref}/database/query": {
- /** Run sql query */
- post: operations["QueryController_runQuery"];
- };
"/v1/projects/{ref}/secrets": {
/**
* List all secrets
@@ -1457,6 +1464,28 @@ export interface paths {
/** Updates a project's auth config */
patch: operations["V1AuthConfigController_updateV1AuthConfig"];
};
+ "/v1/projects/{ref}/config/auth/sso/providers": {
+ /** Lists all SSO providers */
+ get: operations["ProvidersController_listAllProviders"];
+ /** Creates a new SSO provider */
+ post: operations["ProvidersController_createProviderForProject"];
+ };
+ "/v1/projects/{ref}/config/auth/sso/providers/{provider_id}": {
+ /** Gets a SSO provider by its UUID */
+ get: operations["ProvidersController_getProviderById"];
+ /** Updates a SSO provider by its UUID */
+ put: operations["ProvidersController_updateProviderById"];
+ /** Removes a SSO provider by its UUID */
+ delete: operations["ProvidersController_removeProviderById"];
+ };
+ "/v1/projects/{ref}/database/query": {
+ /** Run sql query */
+ post: operations["V1QueryController_v1RunQuery"];
+ };
+ "/v1/projects/{ref}/database/webhooks/enable": {
+ /** Enables Database Webhooks on the project */
+ post: operations["V1DatabaseWebhooksController_v1EnableDatabaseWebhooks"];
+ };
"/v1/projects/{ref}/functions": {
/**
* List all functions
@@ -1493,20 +1522,6 @@ export interface paths {
*/
get: operations["FunctionSlugController_getFunctionBody"];
};
- "/v1/projects/{ref}/config/auth/sso/providers": {
- /** Lists all SSO providers */
- get: operations["ProvidersController_listAllProviders"];
- /** Creates a new SSO provider */
- post: operations["ProvidersController_createProviderForProject"];
- };
- "/v1/projects/{ref}/config/auth/sso/providers/{provider_id}": {
- /** Gets a SSO provider by its UUID */
- get: operations["ProvidersController_getProviderById"];
- /** Updates a SSO provider by its UUID */
- put: operations["ProvidersController_updateProviderById"];
- /** Removes a SSO provider by its UUID */
- delete: operations["ProvidersController_removeProviderById"];
- };
"/v1/organizations": {
/**
* List all organizations
@@ -1612,6 +1627,14 @@ export interface components {
password: string;
redirectTo?: string;
};
+ ProjectResourceWarningsResponse: {
+ project: string;
+ is_readonly_mode_enabled: boolean;
+ is_disk_io_budget_below_threshold: boolean;
+ is_disk_space_usage_beyond_threshold: boolean;
+ is_cpu_load_beyond_threshold: boolean;
+ is_memory_and_swap_usage_beyond_threshold: boolean;
+ };
GetGoTrueConfigResponse: {
SITE_URL: string;
DISABLE_SIGNUP: boolean;
@@ -2227,7 +2250,7 @@ export interface components {
unlimited: boolean;
capped: boolean;
/** @enum {string} */
- metric: "EGRESS" | "DATABASE_EGRESS" | "DATABASE_SIZE" | "STORAGE_EGRESS" | "STORAGE_SIZE" | "MONTHLY_ACTIVE_USERS" | "MONTHLY_ACTIVE_SSO_USERS" | "FUNCTION_INVOCATIONS" | "FUNCTION_COUNT" | "STORAGE_IMAGES_TRANSFORMED" | "REALTIME_MESSAGE_COUNT" | "REALTIME_PEAK_CONNECTIONS" | "COMPUTE_HOURS_XS" | "COMPUTE_HOURS_SM" | "COMPUTE_HOURS_MD" | "COMPUTE_HOURS_L" | "COMPUTE_HOURS_XL" | "COMPUTE_HOURS_2XL" | "COMPUTE_HOURS_4XL" | "COMPUTE_HOURS_8XL" | "COMPUTE_HOURS_12XL" | "COMPUTE_HOURS_16XL";
+ metric: "EGRESS" | "DATABASE_EGRESS" | "DATABASE_SIZE" | "STORAGE_EGRESS" | "STORAGE_SIZE" | "MONTHLY_ACTIVE_USERS" | "MONTHLY_ACTIVE_SSO_USERS" | "FUNCTION_INVOCATIONS" | "FUNCTION_COUNT" | "STORAGE_IMAGES_TRANSFORMED" | "REALTIME_MESSAGE_COUNT" | "REALTIME_PEAK_CONNECTIONS" | "COMPUTE_HOURS_BRANCH" | "COMPUTE_HOURS_XS" | "COMPUTE_HOURS_SM" | "COMPUTE_HOURS_MD" | "COMPUTE_HOURS_L" | "COMPUTE_HOURS_XL" | "COMPUTE_HOURS_2XL" | "COMPUTE_HOURS_4XL" | "COMPUTE_HOURS_8XL" | "COMPUTE_HOURS_12XL" | "COMPUTE_HOURS_16XL";
/** @enum {string} */
pricing_strategy: "UNIT" | "PACKAGE" | "NONE";
pricing_free_units?: number;
@@ -2473,7 +2496,7 @@ export interface components {
};
BillingUsageBasedPrice: {
/** @enum {string} */
- metric: "EGRESS" | "DATABASE_EGRESS" | "DATABASE_SIZE" | "STORAGE_EGRESS" | "STORAGE_SIZE" | "MONTHLY_ACTIVE_USERS" | "MONTHLY_ACTIVE_SSO_USERS" | "FUNCTION_INVOCATIONS" | "FUNCTION_COUNT" | "STORAGE_IMAGES_TRANSFORMED" | "REALTIME_MESSAGE_COUNT" | "REALTIME_PEAK_CONNECTIONS" | "COMPUTE_HOURS_XS" | "COMPUTE_HOURS_SM" | "COMPUTE_HOURS_MD" | "COMPUTE_HOURS_L" | "COMPUTE_HOURS_XL" | "COMPUTE_HOURS_2XL" | "COMPUTE_HOURS_4XL" | "COMPUTE_HOURS_8XL" | "COMPUTE_HOURS_12XL" | "COMPUTE_HOURS_16XL";
+ metric: "EGRESS" | "DATABASE_EGRESS" | "DATABASE_SIZE" | "STORAGE_EGRESS" | "STORAGE_SIZE" | "MONTHLY_ACTIVE_USERS" | "MONTHLY_ACTIVE_SSO_USERS" | "FUNCTION_INVOCATIONS" | "FUNCTION_COUNT" | "STORAGE_IMAGES_TRANSFORMED" | "REALTIME_MESSAGE_COUNT" | "REALTIME_PEAK_CONNECTIONS" | "COMPUTE_HOURS_BRANCH" | "COMPUTE_HOURS_XS" | "COMPUTE_HOURS_SM" | "COMPUTE_HOURS_MD" | "COMPUTE_HOURS_L" | "COMPUTE_HOURS_XL" | "COMPUTE_HOURS_2XL" | "COMPUTE_HOURS_4XL" | "COMPUTE_HOURS_8XL" | "COMPUTE_HOURS_12XL" | "COMPUTE_HOURS_16XL";
/** @enum {string} */
pricingStrategy: "UNIT" | "PACKAGE" | "NONE";
pricingOptions: components["schemas"]["BillingPricingOptionsUnit"] | components["schemas"]["BillingPricingOptionsPackage"] | components["schemas"]["BillingPricingOptionsNone"];
@@ -2968,7 +2991,7 @@ export interface components {
status: string;
subscription_id: string;
is_readonly_mode_enabled?: boolean;
- is_branch_enabled?: boolean;
+ is_branch_enabled: boolean;
preview_branch_refs: (string)[];
};
AmiSearchOptions: {
@@ -3009,7 +3032,7 @@ export interface components {
status: string;
subscription_id: string;
is_readonly_mode_enabled?: boolean;
- is_branch_enabled?: boolean;
+ is_branch_enabled: boolean;
preview_branch_refs: (string)[];
endpoint: string;
anon_key: string;
@@ -3096,16 +3119,6 @@ export interface components {
postgrest: string;
"supabase-postgres": string;
};
- BranchResponse: {
- id: string;
- name: string;
- project_ref: string;
- parent_project_ref: string;
- is_default: boolean;
- git_branch: string;
- created_at: string;
- updated_at: string;
- };
ProjectDetailResponse: {
cloud_provider: string;
db_host: string;
@@ -3126,9 +3139,8 @@ export interface components {
volumeSizeGb?: number;
maxDatabasePreprovisionGb?: number;
lastDatabaseResizeAt?: string;
- preview_branches: (components["schemas"]["BranchResponse"])[];
+ is_branch_enabled: boolean;
parent_project_ref?: string;
- has_branch_enabled?: boolean;
};
ProjectRefResponse: {
id: number;
@@ -3855,6 +3867,14 @@ export interface components {
GetGithubBranch: {
name: string;
};
+ GetGithubPullRequest: {
+ id: number;
+ url: string;
+ title: string;
+ branch: string;
+ created_at: string;
+ created_by?: string;
+ };
FunctionResponse: {
id: string;
slug: string;
@@ -3945,6 +3965,16 @@ export interface components {
branch_name?: string;
git_branch?: string;
};
+ BranchResponse: {
+ id: string;
+ name: string;
+ project_ref: string;
+ parent_project_ref: string;
+ is_default: boolean;
+ git_branch: string;
+ created_at: string;
+ updated_at: string;
+ };
DatabaseResponse: {
/** @description Database host */
host: string;
@@ -4078,20 +4108,6 @@ export interface components {
smtp_sender_name?: string;
rate_limit_email_sent?: number;
};
- FunctionSlugResponse: {
- id: string;
- slug: string;
- name: string;
- /** @enum {string} */
- status: "ACTIVE" | "REMOVED" | "THROTTLED";
- version: number;
- created_at: number;
- updated_at: number;
- verify_jwt?: boolean;
- import_map?: boolean;
- entrypoint_path?: string;
- import_map_path?: string;
- };
AttributeValue: {
default?: Record<string, never> | number | string | boolean;
name?: string;
@@ -4170,6 +4186,20 @@ export interface components {
created_at?: string;
updated_at?: string;
};
+ FunctionSlugResponse: {
+ id: string;
+ slug: string;
+ name: string;
+ /** @enum {string} */
+ status: "ACTIVE" | "REMOVED" | "THROTTLED";
+ version: number;
+ created_at: number;
+ updated_at: number;
+ verify_jwt?: boolean;
+ import_map?: boolean;
+ entrypoint_path?: string;
+ import_map_path?: string;
+ };
OAuthAppResponse: {
id: string;
name: string;
@@ -4395,6 +4425,19 @@ export interface operations {
500: never;
};
};
+ /**
+ * Gets resource warnings for all projects accessible by the user
+ * @description Only returns the minimal project info
+ */
+ ProjectsResourceWarningsController_getProjectsResourceWarnings: {
+ responses: {
+ 200: {
+ content: {
+ "application/json": (components["schemas"]["ProjectResourceWarningsResponse"])[];
+ };
+ };
+ };
+ };
/** Gets GoTrue config */
GoTrueConfigController_getGoTrueConfig: {
parameters: {
@@ -4733,25 +4776,18 @@ export interface operations {
500: never;
};
};
- /** Enables hooks on the project */
+ /** Enables Database Webhooks on the project */
HooksController_enableHooks: {
parameters: {
- header: {
- "x-connection-encrypted": string;
- };
path: {
/** @description Project ref */
ref: string;
};
};
responses: {
- 201: {
- content: {
- "application/json": Record<string, never>;
- };
- };
+ 201: never;
403: never;
- /** @description Failed to enable hooks on the project */
+ /** @description Failed to enable Database Webhooks on the project */
500: never;
};
};
@@ -5048,7 +5084,7 @@ export interface operations {
OrgDailyStatsController_getDailyStats: {
parameters: {
query: {
- metric: "EGRESS" | "DATABASE_EGRESS" | "DATABASE_SIZE" | "STORAGE_EGRESS" | "STORAGE_SIZE" | "MONTHLY_ACTIVE_USERS" | "MONTHLY_ACTIVE_SSO_USERS" | "FUNCTION_INVOCATIONS" | "FUNCTION_COUNT" | "STORAGE_IMAGES_TRANSFORMED" | "REALTIME_MESSAGE_COUNT" | "REALTIME_PEAK_CONNECTIONS" | "COMPUTE_HOURS_XS" | "COMPUTE_HOURS_SM" | "COMPUTE_HOURS_MD" | "COMPUTE_HOURS_L" | "COMPUTE_HOURS_XL" | "COMPUTE_HOURS_2XL" | "COMPUTE_HOURS_4XL" | "COMPUTE_HOURS_8XL" | "COMPUTE_HOURS_12XL" | "COMPUTE_HOURS_16XL";
+ metric: "EGRESS" | "DATABASE_EGRESS" | "DATABASE_SIZE" | "STORAGE_EGRESS" | "STORAGE_SIZE" | "MONTHLY_ACTIVE_USERS" | "MONTHLY_ACTIVE_SSO_USERS" | "FUNCTION_INVOCATIONS" | "FUNCTION_COUNT" | "STORAGE_IMAGES_TRANSFORMED" | "REALTIME_MESSAGE_COUNT" | "REALTIME_PEAK_CONNECTIONS" | "COMPUTE_HOURS_BRANCH" | "COMPUTE_HOURS_XS" | "COMPUTE_HOURS_SM" | "COMPUTE_HOURS_MD" | "COMPUTE_HOURS_L" | "COMPUTE_HOURS_XL" | "COMPUTE_HOURS_2XL" | "COMPUTE_HOURS_4XL" | "COMPUTE_HOURS_8XL" | "COMPUTE_HOURS_12XL" | "COMPUTE_HOURS_16XL";
interval: string;
endDate: string;
startDate: string;
@@ -6027,6 +6063,9 @@ export interface operations {
/** Run sql query */
QueryController_runQuery: {
parameters: {
+ header: {
+ "x-connection-encrypted": string;
+ };
path: {
/** @description Project ref */
ref: string;
@@ -8535,6 +8574,26 @@ export interface operations {
500: never;
};
};
+ /** Gets github pull requests for a given repo */
+ GitHubPullRequestController_getPullRequests: {
+ parameters: {
+ path: {
+ organization_integration_id: string;
+ repo_owner: string;
+ repo_name: string;
+ target: string;
+ };
+ };
+ responses: {
+ 200: {
+ content: {
+ "application/json": (components["schemas"]["GetGithubPullRequest"])[];
+ };
+ };
+ /** @description Failed to get github pull requests for a given repo */
+ 500: never;
+ };
+ };
/** Gets GoTrue template */
AuthTemplateController_getTemplate: {
parameters: {
@@ -9755,129 +9814,116 @@ export interface operations {
500: never;
};
};
- /**
- * Retrieve a function
- * @description Retrieves a function with the specified slug and project.
- */
- FunctionSlugController_getFunction: {
+ /** Lists all SSO providers */
+ ProvidersController_listAllProviders: {
parameters: {
path: {
/** @description Project ref */
ref: string;
- /** @description Function slug */
- function_slug: string;
};
};
responses: {
200: {
content: {
- "application/json": components["schemas"]["FunctionSlugResponse"];
+ "application/json": components["schemas"]["ListProvidersResponse"];
};
};
403: never;
- /** @description Failed to retrieve function with given slug */
- 500: never;
+ /** @description SAML 2.0 support is not enabled for this project */
+ 404: never;
};
};
- /**
- * Delete a function
- * @description Deletes a function with the specified slug from the specified project.
- */
- FunctionSlugController_deleteFunction: {
+ /** Creates a new SSO provider */
+ ProvidersController_createProviderForProject: {
parameters: {
path: {
/** @description Project ref */
ref: string;
- /** @description Function slug */
- function_slug: string;
+ };
+ };
+ requestBody: {
+ content: {
+ "application/json": components["schemas"]["CreateProviderBody"];
};
};
responses: {
- 200: never;
+ 201: {
+ content: {
+ "application/json": components["schemas"]["CreateProviderResponse"];
+ };
+ };
403: never;
- /** @description Failed to delete function with given slug */
- 500: never;
+ /** @description SAML 2.0 support is not enabled for this project */
+ 404: never;
};
};
- /**
- * Update a function
- * @description Updates a function with the specified slug and project.
- */
- FunctionSlugController_updateFunction: {
+ /** Gets a SSO provider by its UUID */
+ ProvidersController_getProviderById: {
parameters: {
- query?: {
- slug?: string;
- name?: string;
- verify_jwt?: boolean;
- import_map?: boolean;
- entrypoint_path?: string;
- import_map_path?: string;
- };
path: {
/** @description Project ref */
ref: string;
- /** @description Function slug */
- function_slug: string;
- };
- };
- requestBody: {
- content: {
- "application/json": components["schemas"]["UpdateFunctionBody"];
- "application/vnd.denoland.eszip": components["schemas"]["UpdateFunctionBody"];
+ provider_id: string;
};
};
responses: {
200: {
content: {
- "application/json": components["schemas"]["FunctionResponse"];
+ "application/json": components["schemas"]["GetProviderResponse"];
};
};
403: never;
- /** @description Failed to update function with given slug */
- 500: never;
+ /** @description Either SAML 2.0 was not enabled for this project, or the provider does not exist */
+ 404: never;
};
};
- /**
- * Retrieve a function body
- * @description Retrieves a function body for the specified slug and project.
- */
- FunctionSlugController_getFunctionBody: {
+ /** Updates a SSO provider by its UUID */
+ ProvidersController_updateProviderById: {
parameters: {
path: {
/** @description Project ref */
ref: string;
- /** @description Function slug */
- function_slug: string;
+ provider_id: string;
+ };
+ };
+ requestBody: {
+ content: {
+ "application/json": components["schemas"]["UpdateProviderBody"];
};
};
responses: {
- 200: never;
+ 200: {
+ content: {
+ "application/json": components["schemas"]["UpdateProviderResponse"];
+ };
+ };
403: never;
- /** @description Failed to retrieve function body with given slug */
- 500: never;
+ /** @description Either SAML 2.0 was not enabled for this project, or the provider does not exist */
+ 404: never;
};
};
- /** Lists all SSO providers */
- ProvidersController_listAllProviders: {
+ /** Removes a SSO provider by its UUID */
+ ProvidersController_removeProviderById: {
parameters: {
path: {
/** @description Project ref */
ref: string;
+ provider_id: string;
};
};
responses: {
200: {
content: {
- "application/json": components["schemas"]["ListProvidersResponse"];
+ "application/json": components["schemas"]["DeleteProviderResponse"];
};
};
403: never;
- /** @description SAML 2.0 support is not enabled for this project */
+ /** @description Either SAML 2.0 was not enabled for this project, or the provider does not exist */
404: never;
};
};
- /** Creates a new SSO provider */
- ProvidersController_createProviderForProject: {
+ /** Run sql query */
+ V1QueryController_v1RunQuery: {
parameters: {
path: {
/** @description Project ref */
@@ -9886,83 +9932,135 @@ export interface operations {
};
requestBody: {
content: {
- "application/json": components["schemas"]["CreateProviderBody"];
+ "application/json": components["schemas"]["RunQueryBody"];
};
};
responses: {
201: {
content: {
- "application/json": components["schemas"]["CreateProviderResponse"];
+ "application/json": Record<string, never>;
};
};
403: never;
- /** @description SAML 2.0 support is not enabled for this project */
- 404: never;
+ /** @description Failed to run sql query */
+ 500: never;
};
};
- /** Gets a SSO provider by its UUID */
- ProvidersController_getProviderById: {
+ /** Enables Database Webhooks on the project */
+ V1DatabaseWebhooksController_v1EnableDatabaseWebhooks: {
parameters: {
path: {
/** @description Project ref */
ref: string;
- provider_id: string;
+ };
+ };
+ responses: {
+ 201: never;
+ 403: never;
+ /** @description Failed to enable Database Webhooks on the project */
+ 500: never;
+ };
+ };
+ /**
+ * Retrieve a function
+ * @description Retrieves a function with the specified slug and project.
+ */
+ FunctionSlugController_getFunction: {
+ parameters: {
+ path: {
+ /** @description Project ref */
+ ref: string;
+ /** @description Function slug */
+ function_slug: string;
};
};
responses: {
200: {
content: {
- "application/json": components["schemas"]["GetProviderResponse"];
+ "application/json": components["schemas"]["FunctionSlugResponse"];
};
};
403: never;
- /** @description Either SAML 2.0 was not enabled for this project, or the provider does not exist */
- 404: never;
+ /** @description Failed to retrieve function with given slug */
+ 500: never;
};
};
- /** Updates a SSO provider by its UUID */
- ProvidersController_updateProviderById: {
+ /**
+ * Delete a function
+ * @description Deletes a function with the specified slug from the specified project.
+ */
+ FunctionSlugController_deleteFunction: {
parameters: {
path: {
/** @description Project ref */
ref: string;
- provider_id: string;
+ /** @description Function slug */
+ function_slug: string;
+ };
+ };
+ responses: {
+ 200: never;
+ 403: never;
+ /** @description Failed to delete function with given slug */
+ 500: never;
+ };
+ };
+ /**
+ * Update a function
+ * @description Updates a function with the specified slug and project.
+ */
+ FunctionSlugController_updateFunction: {
+ parameters: {
+ query?: {
+ slug?: string;
+ name?: string;
+ verify_jwt?: boolean;
+ import_map?: boolean;
+ entrypoint_path?: string;
+ import_map_path?: string;
+ };
+ path: {
+ /** @description Project ref */
+ ref: string;
+ /** @description Function slug */
+ function_slug: string;
};
};
requestBody: {
content: {
- "application/json": components["schemas"]["UpdateProviderBody"];
+ "application/json": components["schemas"]["UpdateFunctionBody"];
+ "application/vnd.denoland.eszip": components["schemas"]["UpdateFunctionBody"];
};
};
responses: {
200: {
content: {
- "application/json": components["schemas"]["UpdateProviderResponse"];
+ "application/json": components["schemas"]["FunctionResponse"];
};
};
403: never;
- /** @description Either SAML 2.0 was not enabled for this project, or the provider does not exist */
- 404: never;
+ /** @description Failed to update function with given slug */
+ 500: never;
};
};
- /** Removes a SSO provider by its UUID */
- ProvidersController_removeProviderById: {
+ /**
+ * Retrieve a function body
+ * @description Retrieves a function body for the specified slug and project.
+ */
+ FunctionSlugController_getFunctionBody: {
parameters: {
path: {
/** @description Project ref */
ref: string;
- provider_id: string;
+ /** @description Function slug */
+ function_slug: string;
};
};
responses: {
- 200: {
- content: {
- "application/json": components["schemas"]["DeleteProviderResponse"];
- };
- };
+ 200: never;
403: never;
- /** @description Either SAML 2.0 was not enabled for this project, or the provider does not exist */
- 404: never;
+ /** @description Failed to retrieve function body with given slug */
+ 500: never;
};
};
/** Create an organization */
diff --git a/studio/data/branches/branches-query.ts b/studio/data/branches/branches-query.ts
index b7dd3bf0042..77940400bfb 100644
--- a/studio/data/branches/branches-query.ts
+++ b/studio/data/branches/branches-query.ts
@@ -1,8 +1,8 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+import { components } from 'data/api'
import { get } from 'data/fetchers'
-import { branchKeys } from './keys'
import { ResponseError } from 'types'
-import { components } from 'data/api'
+import { branchKeys } from './keys'
export type BranchesVariables = {
projectRef?: string
diff --git a/studio/data/integrations/integrations-github-pull-requests-query.ts b/studio/data/integrations/integrations-github-pull-requests-query.ts
new file mode 100644
index 00000000000..acc3ca168d6
--- /dev/null
+++ b/studio/data/integrations/integrations-github-pull-requests-query.ts
@@ -0,0 +1,65 @@
+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 = {
+ organizationIntegrationId?: string
+ repoOwner: string
+ repoName: string
+ target?: string
+}
+
+export type GitHubPullRequest = components['schemas']['GetGithubPullRequest']
+
+export async function getGitHubPullRequests(
+ { organizationIntegrationId, repoOwner, repoName, target }: GithubPullRequestsVariables,
+ signal?: AbortSignal
+) {
+ if (!organizationIntegrationId) throw new Error('Organization integration ID is required')
+ if (!target) throw new Error('Target branch is required')
+
+ const { data, error } = await get(
+ `/platform/integrations/github/pull-requests/{organization_integration_id}/{repo_owner}/{repo_name}/{target}`,
+ {
+ params: {
+ path: {
+ organization_integration_id: organizationIntegrationId,
+ repo_owner: repoOwner,
+ repo_name: repoName,
+ target,
+ },
+ },
+ signal,
+ }
+ )
+
+ if (error) throw error
+ return data
+}
+
+export type GithubPullRequestsData = Awaited<ReturnType<typeof getGitHubPullRequests>>
+export type GithubPullRequestsError = ResponseError
+
+export const useGithubPullRequestsQuery = <TData = GithubPullRequestsData>(
+ { organizationIntegrationId, repoOwner, repoName, target }: GithubPullRequestsVariables,
+ {
+ enabled = true,
+ ...options
+ }: UseQueryOptions<GithubPullRequestsData, GithubPullRequestsError, TData> = {}
+) =>
+ useQuery<GithubPullRequestsData, GithubPullRequestsError, TData>(
+ integrationKeys.githubPullRequestsList(organizationIntegrationId, repoOwner, repoName, target),
+ ({ signal }) =>
+ getGitHubPullRequests({ organizationIntegrationId, repoOwner, repoName, target }, signal),
+ {
+ enabled:
+ enabled &&
+ typeof organizationIntegrationId !== 'undefined' &&
+ typeof repoOwner !== 'undefined' &&
+ typeof repoName !== 'undefined' &&
+ typeof target !== 'undefined',
+ ...options,
+ }
+ )
diff --git a/studio/data/integrations/keys.ts b/studio/data/integrations/keys.ts
index 27a4a3128fb..f881bb9d572 100644
--- a/studio/data/integrations/keys.ts
+++ b/studio/data/integrations/keys.ts
@@ -13,6 +13,19 @@ export const integrationKeys = {
repo_owner: string,
repo_name: string
) => ['organizations', organization_integration_id, 'branches', repo_owner, repo_name],
+ 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,
+ ],
githubConnectionsList: (organization_integration_id: string | undefined) =>
['organizations', organization_integration_id, 'github-connections'] as const,
}
diff --git a/studio/types/base.ts b/studio/types/base.ts
index 93d9c2fe7c6..8c99c88ed41 100644
--- a/studio/types/base.ts
+++ b/studio/types/base.ts
@@ -34,7 +34,7 @@ export interface Project extends ProjectBase {
lastDatabaseResizeAt?: string | null
maxDatabasePreprovisionGb?: string | null
parent_project_ref?: string
- has_branch_enabled?: boolean
+ is_branch_enabled?: boolean
/**
* postgrestStatus is available on client side only.