The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Fix pull requests + preview branches section not using the parent project ref to pull data when on a preview branch
Joshen Lim5d327d0ed068
diff --git a/studio/components/interfaces/BranchManagement/BranchManagement.tsx b/studio/components/interfaces/BranchManagement/BranchManagement.tsxindex 5cd9623eb07..4590a688e83 100644--- a/studio/components/interfaces/BranchManagement/BranchManagement.tsx+++ b/studio/components/interfaces/BranchManagement/BranchManagement.tsx@@ -36,16 +36,16 @@ const BranchManagement = () => {const { ui } = useStore()const router = useRouter()const { ref } = useParams()- const projectDetails = useSelectedProject()+ const project = useSelectedProject()const selectedOrg = useSelectedOrganization()const hasAccessToBranching =selectedOrg?.opt_in_tags?.includes('PREVIEW_BRANCHES_OPT_IN') ?? false+ const hasBranchEnabled = project?.is_branch_enabled- const isBranch = projectDetails?.parent_project_ref !== undefined- const hasBranchEnabled = projectDetails?.is_branch_enabled+ const isBranch = project?.parent_project_ref !== undefinedconst projectRef =- projectDetails !== undefined ? (isBranch ? projectDetails.parent_project_ref : ref) : undefined+ project !== undefined ? (isBranch ? project.parent_project_ref : ref) : undefinedconst snap = useAppUiStateSnapshot()const [showCreateBranch, setShowCreateBranch] = useState(false)@@ -64,7 +64,7 @@ const BranchManagement = () => {?.filter((integration) => integration.integration.name === 'GitHub').flatMap((integration) => integration.connections)const githubConnection = githubConnections?.find(- (connection) => connection.supabase_project_ref === ref+ (connection) => connection.supabase_project_ref === projectRef)const { data: branches } = useBranchesQuery({ projectRef })diff --git a/studio/components/interfaces/BranchManagement/PreviewBranches.tsx b/studio/components/interfaces/BranchManagement/PreviewBranches.tsxindex 6b11a67ae32..4580d704189 100644--- a/studio/components/interfaces/BranchManagement/PreviewBranches.tsx+++ b/studio/components/interfaces/BranchManagement/PreviewBranches.tsx@@ -5,7 +5,7 @@ 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 { useSelectedOrganization, useSelectedProject } from 'hooks'import { useOrgIntegrationsQuery } from 'data/integrations/integrations-query-org-only'import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'import AlertError from 'components/ui/AlertError'@@ -22,8 +22,13 @@ const PreviewBranches = ({onSelectDeleteBranch,}: PreviewBranchesProps) => {const { ref } = useParams()+ const project = useSelectedProject()const selectedOrg = useSelectedOrganization()+ const isBranch = project?.parent_project_ref !== undefined+ const projectRef =+ project !== undefined ? (isBranch ? project.parent_project_ref : ref) : undefined+const { data: integrations } = useOrgIntegrationsQuery({orgSlug: selectedOrg?.slug,})@@ -33,7 +38,7 @@ const PreviewBranches = ({integration.organization.slug === selectedOrg?.slug)const githubConnection = githubIntegration?.connections.find(- (connection) => connection.supabase_project_ref === ref+ (connection) => connection.supabase_project_ref === projectRef)const [repoOwner, repoName] = githubConnection?.metadata.name.split('/') || []@@ -43,7 +48,7 @@ const PreviewBranches = ({isLoading: isLoadingBranches,isError: isErrorBranches,isSuccess: isSuccessBranches,- } = useBranchesQuery({ projectRef: ref })+ } = useBranchesQuery({ projectRef })const [[mainBranch], previewBranches] = partition(branches, (branch) => branch.is_default)const { data: allPullRequests } = useGithubPullRequestsQuery({diff --git a/studio/components/interfaces/BranchManagement/PullRequests.tsx b/studio/components/interfaces/BranchManagement/PullRequests.tsxindex 882840d6693..0a6f0154283 100644--- a/studio/components/interfaces/BranchManagement/PullRequests.tsx+++ b/studio/components/interfaces/BranchManagement/PullRequests.tsx@@ -5,7 +5,7 @@ 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 { useSelectedOrganization, useSelectedProject } from 'hooks'import { BranchContainer, BranchHeader, PullRequestPanel } from './BranchPanels'import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'import AlertError from 'components/ui/AlertError'@@ -22,9 +22,14 @@ const PullRequests = ({onSelectDeleteBranch,}: PullRequestsProps) => {const { ref } = useParams()+ const project = useSelectedProject()const selectedOrg = useSelectedOrganization()const pullRequestUrl = generateCreatePullRequestURL()+ const isBranch = project?.parent_project_ref !== undefined+ const projectRef =+ project !== undefined ? (isBranch ? project.parent_project_ref : ref) : undefined+const { data: integrations, isLoading: isLoadingIntegrations } = useOrgIntegrationsQuery({orgSlug: selectedOrg?.slug,})@@ -35,11 +40,11 @@ const PullRequests = ({)const githubConnection = githubIntegration?.connections?.find(- (connection) => connection.supabase_project_ref === ref+ (connection) => connection.supabase_project_ref === projectRef)const [repoOwner, repoName] = githubConnection?.metadata.name.split('/') || []- const { data: branches, isLoading: isLoadingBranches } = useBranchesQuery({ projectRef: ref })+ const { data: branches, isLoading: isLoadingBranches } = useBranchesQuery({ projectRef })const mainBranch = branches?.find((branch) => branch.is_default)const {