From 8a5e6099360279b8a833da5ae1eb0c1062af8a28 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Tue, 5 May 2026 04:38:46 -0400 Subject: [PATCH] fix: add query params for simple-redirect integrations (#45562) This change updates the handler for simple GET installations to correctly appending the organization_slug and project_ref parameters as documented in our Partner Integrations Guide. Fixes INT-111 ## Summary by CodeRabbit * **Bug Fixes** * Integration installs now open in a new browser tab instead of replacing the current page. * Organization and project context are appended to integration installation links so setups receive correct context. * Missing or invalid installation links now fall back to the home page to avoid navigation errors. --------- Co-authored-by: Joshen Lim --- .../InstallOAuthIntegrationButton.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabV2/InstallIntegrationSheet/InstallOAuthIntegrationButton.tsx b/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabV2/InstallIntegrationSheet/InstallOAuthIntegrationButton.tsx index 5e695ad6aa3..fb08a5e10c6 100644 --- a/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabV2/InstallIntegrationSheet/InstallOAuthIntegrationButton.tsx +++ b/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabV2/InstallIntegrationSheet/InstallOAuthIntegrationButton.tsx @@ -6,6 +6,7 @@ import { Button } from 'ui' import type { IntegrationDefinition } from '@/components/interfaces/Integrations/Landing/Integrations.constants' import { useAPIKeysQuery } from '@/data/api-keys/api-keys-query' import { useInstallOAuthIntegrationMutation } from '@/data/marketplace/install-oauth-integration-mutation' +import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization' interface InstallOAuthIntegrationButtonProps { integration: IntegrationDefinition @@ -13,6 +14,7 @@ interface InstallOAuthIntegrationButtonProps { export function InstallOAuthIntegrationButton({ integration }: InstallOAuthIntegrationButtonProps) { const { ref: projectRef } = useParams() + const { data: selectedOrg } = useSelectedOrganizationQuery() const { data: apiKeys, isLoading: isApiKeysLoading } = useAPIKeysQuery( { projectRef, reveal: false }, @@ -55,7 +57,16 @@ export function InstallOAuthIntegrationButton({ integration }: InstallOAuthInteg if (!integration.listingId) return toast.error('Listing ID is required') installOAuthIntegration({ projectRef, id: integration.listingId }) } else { - window.location.href = integration.installUrl ?? '/' + let redirectUrl = '/' + + if (integration.installUrl) { + const url = new URL(integration.installUrl) + url.searchParams.append('organization_slug', selectedOrg?.slug ?? '') + url.searchParams.append('project_id', projectRef) + redirectUrl = url.href + } + + window.open(redirectUrl, '_blank', 'noreferrer') } }