mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 18:35:07 +03:00
Fix pull requests + preview branches section not using the parent project ref to pull data when on a preview branch
This commit is contained in:
1 parent
e76b4655c3
commit
5d327d0ed0
3 files changed
+21
-11
No files matched your search
@@ -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 !== undefined
|
||||
const projectRef =
|
||||
projectDetails !== undefined ? (isBranch ? projectDetails.parent_project_ref : ref) : undefined
|
||||
project !== undefined ? (isBranch ? project.parent_project_ref : ref) : undefined
|
||||
|
||||
const 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 })
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user