From 48ce60553f9f2bdb8236e49ed165ce1bb2ff4be7 Mon Sep 17 00:00:00 2001 From: Saxon Fletcher Date: Fri, 4 Jul 2025 09:14:39 +1000 Subject: [PATCH] fix branch query --- .../interfaces/BranchManagement/Branch.Commands.tsx | 2 +- .../SidePanelGitHubRepoLinker.tsx | 2 +- .../components/layouts/AppLayout/BranchDropdown.tsx | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx b/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx index 40a6f0b94cc..6980de47929 100644 --- a/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx +++ b/apps/studio/components/interfaces/BranchManagement/Branch.Commands.tsx @@ -17,7 +17,7 @@ export function useBranchCommands() { let { data: branches } = useBranchesQuery( { - projectRef: selectedProject?.parentRef, + projectRef: selectedProject?.parent_project_ref || selectedProject?.ref, }, { enabled: isBranchingEnabled } ) diff --git a/apps/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx b/apps/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx index 609931bd89b..36272d090a1 100644 --- a/apps/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx +++ b/apps/studio/components/interfaces/Organization/IntegrationSettings/SidePanelGitHubRepoLinker.tsx @@ -108,7 +108,7 @@ const SidePanelGitHubRepoLinker = ({ projectRef }: SidePanelGitHubRepoLinkerProp ) const { data: existingBranches } = useBranchesQuery( - { projectRef: selectedProject?.ref }, + { projectRef: selectedProject?.parent_project_ref || selectedProject?.ref }, { enabled: !!selectedProject?.ref } ) diff --git a/apps/studio/components/layouts/AppLayout/BranchDropdown.tsx b/apps/studio/components/layouts/AppLayout/BranchDropdown.tsx index ce72522330b..8e6c1593772 100644 --- a/apps/studio/components/layouts/AppLayout/BranchDropdown.tsx +++ b/apps/studio/components/layouts/AppLayout/BranchDropdown.tsx @@ -80,10 +80,14 @@ export const BranchDropdown = () => { const projectDetails = useSelectedProject() const snap = useAppStateSnapshot() - const isBranch = projectDetails?.parent_project_ref !== undefined - const projectRef = - projectDetails !== undefined ? (isBranch ? projectDetails.parent_project_ref : ref) : undefined - const { data: branches, isLoading, isError, isSuccess } = useBranchesQuery({ projectRef }) + const projectRef = projectDetails?.parent_project_ref || ref + + const { + data: branches, + isLoading, + isError, + isSuccess, + } = useBranchesQuery({ projectRef }, { enabled: Boolean(projectDetails) }) const isBranchingEnabled = projectDetails?.is_branch_enabled === true const selectedBranch = branches?.find((branch) => branch.project_ref === ref)