Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(data-warehouse): tell members why they can't connect a source (#112603)

Tom Owers5b679cb81022
diff --git a/products/data_warehouse/frontend/shared/components/forms/IntegrationChoice.tsx b/products/data_warehouse/frontend/shared/components/forms/IntegrationChoice.tsx
index d5766ee684dd..b5537c543216 100644
--- a/products/data_warehouse/frontend/shared/components/forms/IntegrationChoice.tsx
+++ b/products/data_warehouse/frontend/shared/components/forms/IntegrationChoice.tsx
@@ -6,8 +6,11 @@ import {
IntegrationChoice,
IntegrationConfigureProps,
} from 'lib/components/CyclotronJob/integrations/IntegrationChoice'
+import { getIntegrationSetup } from 'lib/components/CyclotronJob/integrations/integrationSetupRegistry'
+import { useIntegrationManagementRestriction } from 'lib/integrations/integrationPermissions'
import { integrationsLogic, OAUTH_INTEGRATION_ID_PARAM } from 'lib/integrations/integrationsLogic'
import { describeOAuthCallbackError, INTEGRATION_ERROR_PARAM } from 'lib/integrations/oauthCallbackErrors'
+import { getIntegrationNameFromKind } from 'lib/integrations/utils'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { urls } from 'scenes/urls'
@@ -48,9 +51,18 @@ export function SourceIntegrationChoice({
const { saveFormStateBeforeRedirect } = useActions(sourceWizardLogic)
const { location, searchParams } = useValues(router)
const { integrations, integrationsLoading } = useValues(integrationsLogic)
+ const integrationManagementRestriction = useIntegrationManagementRestriction()
const sourceKind = sourceConfig.name.toLowerCase()
const kind = integration ?? sourceKind
+ // Members can't start an OAuth connect (see IntegrationChoice), and the only hint is a tooltip
+ // on a disabled menu item. With no existing connection to pick, they have no way forward.
+ const blockedFromConnecting =
+ !!integrationManagementRestriction &&
+ !integrationsLoading &&
+ !getIntegrationSetup(kind) &&
+ !integrations?.some((existing) => existing.kind === kind)
+
// A failed authorization sends the user back here, where the connect button is. The callback
// carries the reason in the URL rather than a toast, which would be gone before they retry.
const oauthError = searchParams[INTEGRATION_ERROR_PARAM]
@@ -96,6 +108,12 @@ export function SourceIntegrationChoice({
{oauthError && (
<LemonBanner type="error">{describeOAuthCallbackError(String(oauthError), sourceKind)}</LemonBanner>
)}
+ {blockedFromConnecting && (
+ <LemonBanner type="info">
+ Only project admins can connect a new {getIntegrationNameFromKind(kind)} account. Ask a project
+ admin to connect it, then pick it here.
+ </LemonBanner>
+ )}
<IntegrationChoice
{...props}
value={value}