@burdenoff/microfe-integrations 2026.830.1 → 2026.830.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/integrations/IntegrationsAdminRoot.d.ts.map +1 -1
  2. package/dist/integrations/IntegrationsAdminRoot.js +35 -26
  3. package/dist/integrations/IntegrationsAdminRoot.js.map +1 -1
  4. package/dist/integrations/IntegrationsRoot.d.ts.map +1 -1
  5. package/dist/integrations/IntegrationsRoot.js +47 -38
  6. package/dist/integrations/IntegrationsRoot.js.map +1 -1
  7. package/dist/integrations/components/AddConnectionDialog.d.ts.map +1 -1
  8. package/dist/integrations/components/AddConnectionDialog.js +151 -152
  9. package/dist/integrations/components/AddConnectionDialog.js.map +1 -1
  10. package/dist/integrations/components/AuthMethodSelector.d.ts.map +1 -1
  11. package/dist/integrations/components/AuthMethodSelector.js +48 -40
  12. package/dist/integrations/components/AuthMethodSelector.js.map +1 -1
  13. package/dist/integrations/components/AuthMethodsEditor.d.ts.map +1 -1
  14. package/dist/integrations/components/AuthMethodsEditor.js +207 -190
  15. package/dist/integrations/components/AuthMethodsEditor.js.map +1 -1
  16. package/dist/integrations/components/ConnectionCard.d.ts.map +1 -1
  17. package/dist/integrations/components/ConnectionCard.js +102 -98
  18. package/dist/integrations/components/ConnectionCard.js.map +1 -1
  19. package/dist/integrations/components/ConnectionStatusBadge.d.ts.map +1 -1
  20. package/dist/integrations/components/ConnectionStatusBadge.js +9 -5
  21. package/dist/integrations/components/ConnectionStatusBadge.js.map +1 -1
  22. package/dist/integrations/components/CredentialStorageSelector.d.ts.map +1 -1
  23. package/dist/integrations/components/CredentialStorageSelector.js +124 -121
  24. package/dist/integrations/components/CredentialStorageSelector.js.map +1 -1
  25. package/dist/integrations/components/ProviderCard.d.ts.map +1 -1
  26. package/dist/integrations/components/ProviderCard.js +25 -65
  27. package/dist/integrations/components/ProviderCard.js.map +1 -1
  28. package/dist/integrations/components/SchemaForm.d.ts.map +1 -1
  29. package/dist/integrations/components/SchemaForm.js +116 -111
  30. package/dist/integrations/components/SchemaForm.js.map +1 -1
  31. package/dist/integrations/hooks/useFormatDate.d.ts +7 -0
  32. package/dist/integrations/hooks/useFormatDate.d.ts.map +1 -0
  33. package/dist/integrations/hooks/useFormatDate.js +17 -0
  34. package/dist/integrations/hooks/useFormatDate.js.map +1 -0
  35. package/dist/integrations/hooks/useFormatLastUsed.d.ts +9 -0
  36. package/dist/integrations/hooks/useFormatLastUsed.d.ts.map +1 -0
  37. package/dist/integrations/hooks/useFormatLastUsed.js +15 -0
  38. package/dist/integrations/hooks/useFormatLastUsed.js.map +1 -0
  39. package/dist/integrations/hooks/useLabel.d.ts +13 -0
  40. package/dist/integrations/hooks/useLabel.d.ts.map +1 -0
  41. package/dist/integrations/hooks/useLabel.js +20 -0
  42. package/dist/integrations/hooks/useLabel.js.map +1 -0
  43. package/dist/integrations/hooks/useTr.d.ts +17 -0
  44. package/dist/integrations/hooks/useTr.d.ts.map +1 -0
  45. package/dist/integrations/hooks/useTr.js +14 -0
  46. package/dist/integrations/hooks/useTr.js.map +1 -0
  47. package/dist/integrations/pages/AddConnectionWizard.d.ts.map +1 -1
  48. package/dist/integrations/pages/AddConnectionWizard.js +396 -387
  49. package/dist/integrations/pages/AddConnectionWizard.js.map +1 -1
  50. package/dist/integrations/pages/ConnectionDetail.d.ts.map +1 -1
  51. package/dist/integrations/pages/ConnectionDetail.js +128 -128
  52. package/dist/integrations/pages/ConnectionDetail.js.map +1 -1
  53. package/dist/integrations/pages/ConnectionLogs.d.ts.map +1 -1
  54. package/dist/integrations/pages/ConnectionLogs.js +210 -181
  55. package/dist/integrations/pages/ConnectionLogs.js.map +1 -1
  56. package/dist/integrations/pages/ConnectionsList.d.ts.map +1 -1
  57. package/dist/integrations/pages/ConnectionsList.js +136 -115
  58. package/dist/integrations/pages/ConnectionsList.js.map +1 -1
  59. package/dist/integrations/pages/IntegrationsOverview.d.ts.map +1 -1
  60. package/dist/integrations/pages/IntegrationsOverview.js +76 -77
  61. package/dist/integrations/pages/IntegrationsOverview.js.map +1 -1
  62. package/dist/integrations/pages/IntegrationsSettings.d.ts.map +1 -1
  63. package/dist/integrations/pages/IntegrationsSettings.js +59 -61
  64. package/dist/integrations/pages/IntegrationsSettings.js.map +1 -1
  65. package/dist/integrations/pages/IntegrationsUserLandingPage.d.ts.map +1 -1
  66. package/dist/integrations/pages/IntegrationsUserLandingPage.js +29 -28
  67. package/dist/integrations/pages/IntegrationsUserLandingPage.js.map +1 -1
  68. package/dist/integrations/pages/ProviderCatalog.d.ts.map +1 -1
  69. package/dist/integrations/pages/ProviderCatalog.js +99 -141
  70. package/dist/integrations/pages/ProviderCatalog.js.map +1 -1
  71. package/dist/integrations/pages/ProviderDetail.d.ts.map +1 -1
  72. package/dist/integrations/pages/ProviderDetail.js +208 -220
  73. package/dist/integrations/pages/ProviderDetail.js.map +1 -1
  74. package/dist/integrations/pages/ProviderEditorPage.d.ts.map +1 -1
  75. package/dist/integrations/pages/ProviderEditorPage.js +262 -261
  76. package/dist/integrations/pages/ProviderEditorPage.js.map +1 -1
  77. package/dist/integrations/translations/en.d.ts +745 -0
  78. package/dist/integrations/translations/en.d.ts.map +1 -0
  79. package/dist/integrations/utils/integrationsHelpers.js +2 -16
  80. package/dist/integrations/utils/integrationsHelpers.js.map +1 -1
  81. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"AddConnectionDialog.js","names":[],"sources":["../../../src/integrations/components/AddConnectionDialog.tsx"],"sourcesContent":["/**\n * AddConnectionDialog -- n8n-style popup for creating new connections.\n *\n * Replaces the full-page AddConnectionWizard with an inline modal dialog.\n * Uses the same hooks and GraphQL operations that already exist in\n * microfe-integrations (useCreateConnection, useInitiateOAuth, etc.).\n *\n * Opens from any page via Zustand store state, so there is no navigation\n * to /connections/add — the dialog overlays the current page.\n */\n\nimport { useState, useMemo, useCallback, useEffect, useRef, useId } from 'react';\nimport {\n X,\n Check,\n Loader2,\n AlertCircle,\n CheckCircle2,\n Search,\n ExternalLink,\n Shield,\n Link2,\n Info,\n} from 'lucide-react';\nimport { cn } from '../utils/cn';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\nimport {\n getAuthTypeLabel,\n getCategoryLabel,\n legacyFlowForAuthType,\n} from '../utils/integrationsHelpers';\nimport { useIntegrations } from '../providers/IntegrationsProvider';\nimport { INTEGRATION_PERMISSIONS } from '../constants/permissions';\nimport { useProviders, useProvider } from '../hooks/useProviders';\nimport {\n useCreateConnection,\n useInitiateOAuth,\n useAuthenticateConnection,\n useAuthenticateWithServiceAccount,\n} from '../hooks/useConnections';\nimport { useGetConnectionLazyQuery } from '../../generated/wspace-operations';\nimport { waitForOAuthPopupCompletion } from '../utils/oauthPopup';\nimport {\n CredentialStorageSelector,\n type CredentialStorageState,\n} from './CredentialStorageSelector';\nimport { AuthMethodNotice, AuthMethodSelector } from './AuthMethodSelector';\nimport { ProviderIcon } from './ProviderIcon';\nimport {\n SchemaForm,\n initialValuesFromSchema,\n isSchemaComplete,\n parseFormSchema,\n visibleValues,\n} from './SchemaForm';\nimport type { IntegrationProvider } from '../types';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface AddConnectionDialogProps {\n /** Whether the dialog is open */\n open: boolean;\n /** Callback to close the dialog */\n onClose: () => void;\n /** Pre-selected provider ID (skips provider picker step) */\n preselectedProviderId?: string | null;\n /** Callback when a connection is successfully created */\n onConnectionCreated?: (connectionId: string) => void;\n}\n\ntype DialogTab = 'connection' | 'details';\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * Above the app shell's header (`z-index: 100`).\n *\n * The dialog used to sit at Tailwind's `z-50`, so the shell header painted over\n * its top edge and swallowed the title and the Method control — the dialog\n * looked \"cut off\" no matter how its height was constrained. A modal must\n * out-rank the chrome it covers, and Tailwind's scale stops well below it.\n */\nconst OVERLAY_Z = 1100;\nconst DIALOG_Z = 1101;\n\nexport function AddConnectionDialog({\n open,\n onClose,\n preselectedProviderId,\n onConnectionCreated,\n}: AddConnectionDialogProps) {\n // Provider data\n const { apiGatewayUrl } = useIntegrations();\n const { providers, loading: providersLoading } = useProviders();\n // A preselected id may not be in the catalog page (disabled provider linked\n // from its own detail page). Resolve such ids via a direct by-id fetch so the\n // dialog never dead-ends on a blank body.\n const providerInList = useMemo(\n () =>\n preselectedProviderId\n ? ((providers ?? []).find((p: IntegrationProvider) => p.id === preselectedProviderId) ??\n null)\n : null,\n [providers, preselectedProviderId]\n );\n // Only fetch once the catalog has loaded and confirmed the id isn't in the\n // filtered list — avoids a redundant GetProvider for visible providers.\n const { provider: fetchedPreselectedProvider, loading: fetchedPreselectedLoading } = useProvider(\n !providersLoading && preselectedProviderId && !providerInList ? preselectedProviderId : ''\n );\n const resolvedPreselectedProvider = providerInList ?? fetchedPreselectedProvider;\n // True while a preselected provider is still being resolved (catalog load or\n // the by-id fallback fetch) — keeps the body showing a spinner, not blank.\n const preselectedResolving =\n !!preselectedProviderId &&\n !resolvedPreselectedProvider &&\n (providersLoading || fetchedPreselectedLoading);\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const canCreate = !permissionsLoading && hasPermission(INTEGRATION_PERMISSIONS.CONNECTION_CREATE);\n\n // Mutations\n const { createConnection, loading: creating } = useCreateConnection();\n const { initiateOAuth, loading: oauthLoading } = useInitiateOAuth();\n const { authenticateConnection, loading: authenticating } = useAuthenticateConnection();\n const { authenticateWithServiceAccount, loading: serviceAccountLoading } =\n useAuthenticateWithServiceAccount();\n const [fetchConnection] = useGetConnectionLazyQuery({ fetchPolicy: 'network-only' });\n\n // State\n const [selectedProvider, setSelectedProvider] = useState<IntegrationProvider | null>(null);\n const [showPicker, setShowPicker] = useState(!preselectedProviderId);\n const [activeTab, setActiveTab] = useState<DialogTab>('connection');\n const [searchQuery, setSearchQuery] = useState('');\n const [connectionName, setConnectionName] = useState('');\n const [connectionDescription, setConnectionDescription] = useState('');\n /** Auth method the user picked; null until a provider is selected. */\n const [selectedAuthMethodKey, setSelectedAuthMethodKey] = useState<string | null>(null);\n /** Values for the selected method's schema-described fields. */\n const [fieldValues, setFieldValues] = useState<Record<string, unknown>>({});\n const [credentialStorage, setCredentialStorage] = useState<CredentialStorageState>({\n mode: 'managed',\n vaultId: '',\n secretId: '',\n managedSecretName: '',\n });\n const [errorMessage, setErrorMessage] = useState('');\n const [success, setSuccess] = useState(false);\n const [oauthWaiting, setOauthWaiting] = useState(false);\n const [, setCreatedConnectionId] = useState<string | null>(null);\n\n const oauthPopupRef = useRef<Window | null>(null);\n const oauthCleanupRef = useRef<(() => void) | null>(null);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const idPrefix = useId();\n const fieldId = (name: string) => `${idPrefix}-${name}`;\n\n // ── Auth method resolution ────────────────────────────────────────────────\n // Everything the auth section renders and submits derives from the selected\n // method. Providers with a single method behave exactly as before.\n const authMethods = useMemo(\n () => (selectedProvider?.authMethods ?? []).filter((method) => method.isEnabled),\n [selectedProvider]\n );\n const selectedAuthMethod = useMemo(\n () =>\n authMethods.find((method) => method.key === selectedAuthMethodKey) ?? authMethods[0] ?? null,\n [authMethods, selectedAuthMethodKey]\n );\n // Fall back to the provider's own authType for providers whose methods have\n // not been fetched (older fragments) or backfilled yet.\n const authFlow = selectedAuthMethod?.flow ?? legacyFlowForAuthType(selectedProvider?.authType);\n const authTypeForMethod = selectedAuthMethod?.authType ?? selectedProvider?.authType;\n // Memoized: a fresh array each render would re-create handleSubmit's\n // useCallback on every render.\n const authScopes = useMemo(\n () =>\n selectedAuthMethod?.defaultScopes?.length\n ? selectedAuthMethod.defaultScopes\n : (selectedProvider?.defaultScopes ?? []),\n [selectedAuthMethod, selectedProvider]\n );\n const activeSchema = useMemo(\n () => parseFormSchema(selectedAuthMethod?.configSchema ?? selectedProvider?.configSchema),\n [selectedAuthMethod, selectedProvider]\n );\n\n // Selecting a different method must not carry the previous method's values\n // over — they belong to a different credential shape entirely.\n useEffect(() => {\n // Seeded from the schema's declared defaults, not empty: a rendered control\n // shows its default as selected, so leaving state empty made validation\n // treat a visible value as missing and dropped it from the submission.\n setFieldValues(initialValuesFromSchema(activeSchema));\n setErrorMessage('');\n // activeSchema is derived from these two, so it is not an extra trigger.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedAuthMethodKey, selectedProvider?.id]);\n\n useEffect(() => {\n if (!open) return undefined;\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n onClose();\n }\n };\n\n window.addEventListener('keydown', handleKeyDown);\n return () => window.removeEventListener('keydown', handleKeyDown);\n }, [open, onClose]);\n\n // Cleanup OAuth listener and popup on unmount.\n useEffect(() => {\n return () => {\n oauthCleanupRef.current?.();\n if (oauthPopupRef.current && !oauthPopupRef.current.closed) {\n oauthPopupRef.current.close();\n }\n };\n }, []);\n\n // Reset state when dialog opens\n useEffect(() => {\n if (open) {\n setActiveTab('connection');\n setSearchQuery('');\n setConnectionName('');\n setConnectionDescription('');\n setSelectedAuthMethodKey(null);\n setFieldValues({});\n setCredentialStorage({ mode: 'managed', vaultId: '', secretId: '', managedSecretName: '' });\n setErrorMessage('');\n setSuccess(false);\n setOauthWaiting(false);\n setCreatedConnectionId(null);\n\n if (preselectedProviderId) {\n setShowPicker(false);\n setSelectedProvider(null); // will be set by effect below\n } else {\n setShowPicker(true);\n setSelectedProvider(null);\n }\n }\n }, [open, preselectedProviderId]);\n\n // Find and set preselected provider (from the filtered list or, for hidden\n // built-ins, the direct by-id fetch above).\n useEffect(() => {\n if (open && preselectedProviderId && resolvedPreselectedProvider && !selectedProvider) {\n setSelectedProvider(resolvedPreselectedProvider);\n setConnectionName(`${resolvedPreselectedProvider.name} Connection`);\n setShowPicker(false);\n }\n }, [open, preselectedProviderId, resolvedPreselectedProvider, selectedProvider]);\n\n // Auto-focus search input when picker is shown\n useEffect(() => {\n if (open && showPicker) {\n const timeoutId = setTimeout(() => searchInputRef.current?.focus(), 100);\n return () => clearTimeout(timeoutId);\n }\n return undefined;\n }, [open, showPicker]);\n\n // Filter providers for picker\n const filteredProviders = useMemo(() => {\n const installed = (providers ?? []).filter(\n (p: IntegrationProvider) => p.pluginStatus === 'installed' && p.isEnabled\n );\n if (!searchQuery.trim()) return installed;\n const q = searchQuery.toLowerCase();\n return installed.filter(\n (p: IntegrationProvider) =>\n p.name.toLowerCase().includes(q) ||\n (p.description ?? '').toLowerCase().includes(q) ||\n p.key.toLowerCase().includes(q)\n );\n }, [providers, searchQuery]);\n\n // Group providers by category\n const groupedProviders = useMemo(() => {\n const groups: Record<string, IntegrationProvider[]> = {};\n filteredProviders.forEach((p: IntegrationProvider) => {\n const cat = p.category;\n if (!groups[cat]) groups[cat] = [];\n groups[cat].push(p);\n });\n return groups;\n }, [filteredProviders]);\n\n const handleSelectProvider = useCallback((provider: IntegrationProvider) => {\n setSelectedProvider(provider);\n setConnectionName(`${provider.name} Connection`);\n setShowPicker(false);\n setErrorMessage('');\n }, []);\n\n const isAuthenticating =\n creating || oauthLoading || oauthWaiting || authenticating || serviceAccountLoading;\n\n // Main submit handler\n const handleSubmit = useCallback(async () => {\n if (!selectedProvider || !connectionName.trim()) return;\n\n // Methods that mint tokens on demand store no credential, so they need no\n // vault/secret — skip the credential-storage requirement entirely.\n const isServiceAccount = authFlow === 'minted';\n\n if (!isServiceAccount) {\n if (!credentialStorage.vaultId) {\n setErrorMessage('Please select a vault for this connection');\n return;\n }\n if (credentialStorage.mode === 'existing' && !credentialStorage.secretId) {\n setErrorMessage('Please select an existing vault secret');\n return;\n }\n }\n\n if (authFlow === 'oauth2' && activeSchema && !isSchemaComplete(activeSchema, fieldValues)) {\n setErrorMessage('Please fill in all required fields');\n return;\n }\n\n if (selectedAuthMethod && !selectedAuthMethod.isConfigured) {\n setErrorMessage(\n 'This authentication method is not configured in this environment. Ask an administrator to add its credentials, or pick another method.'\n );\n return;\n }\n\n try {\n setErrorMessage('');\n\n // Step 1: Create the connection\n const connId = await createConnection({\n name: connectionName.trim(),\n description: connectionDescription.trim() || undefined,\n providerId: selectedProvider.id,\n authMethodKey: selectedAuthMethodKey ?? undefined,\n // OAuth methods collect non-secret routing settings (tenant subdomain,\n // base URL) rather than a credential, so they belong on the connection\n // config, which getConnectionToken already reads for baseUrl.\n ...(authFlow === 'oauth2' && activeSchema\n ? { config: visibleValues(activeSchema, fieldValues) as Record<string, unknown> }\n : {}),\n ...(isServiceAccount\n ? {}\n : {\n vaultId: credentialStorage.vaultId,\n credentialSecretId:\n credentialStorage.mode === 'existing' ? credentialStorage.secretId : undefined,\n managedSecretName:\n credentialStorage.mode === 'managed'\n ? credentialStorage.managedSecretName.trim() || undefined\n : undefined,\n }),\n });\n\n if (!connId) {\n setErrorMessage('Failed to create connection');\n return;\n }\n\n setCreatedConnectionId(connId);\n\n // Step 2: Authenticate. Driven by the auth method's *flow*, not by a\n // per-auth-type branch: FIELDS methods all submit their schema values\n // through one generic mutation, so adding an auth type needs no new case\n // here and no new mutation to call.\n switch (authFlow) {\n case 'oauth2': {\n const callbackUrl = apiGatewayUrl\n ? `${apiGatewayUrl}/integrations/oauth/callback`\n : '/integrations/oauth/callback';\n const result = await initiateOAuth(connId, callbackUrl, selectedProvider.key);\n if (result?.redirectUrl) {\n const width = 600;\n const height = 700;\n const left = window.screenX + (window.innerWidth - width) / 2;\n const top = window.screenY + (window.innerHeight - height) / 2;\n const popup = window.open(\n result.redirectUrl,\n 'oauth_popup',\n `width=${width},height=${height},left=${left},top=${top},toolbar=no,menubar=no,scrollbars=yes,resizable=yes`\n );\n if (!popup) {\n setErrorMessage(\n 'Popup was blocked. Please allow popups for this site and try again.'\n );\n return;\n }\n oauthPopupRef.current = popup;\n setOauthWaiting(true);\n\n oauthCleanupRef.current?.();\n oauthCleanupRef.current = waitForOAuthPopupCompletion({\n connectionId: connId,\n popup,\n fetchConnectionStatus: async () => {\n const { data } = await fetchConnection({ variables: { id: connId } });\n return data?.getConnection ?? null;\n },\n onSuccess: () => {\n setSuccess(true);\n onConnectionCreated?.(connId);\n },\n onError: setErrorMessage,\n onSettled: () => {\n oauthCleanupRef.current = null;\n oauthPopupRef.current = null;\n setOauthWaiting(false);\n },\n });\n\n return;\n }\n setSuccess(true);\n onConnectionCreated?.(connId);\n break;\n }\n case 'minted': {\n // Nothing to collect and nothing stored. SERVICE_ACCOUNT still records\n // the user's delegation for the reserved app; WORKSPACE_APP_TOKEN\n // connections are pure config and are already usable.\n if (authTypeForMethod === 'service_account') {\n await authenticateWithServiceAccount(\n connId,\n authScopes.length > 0 ? authScopes : undefined\n );\n }\n setSuccess(true);\n onConnectionCreated?.(connId);\n break;\n }\n default: {\n // FIELDS: submit whatever the method's schema asked for.\n if (activeSchema) {\n if (!isSchemaComplete(activeSchema, fieldValues)) {\n setErrorMessage('Please fill in all required fields');\n return;\n }\n }\n // Only fields the user can currently see: a `showIf` field that was\n // filled and then hidden must not be submitted, or we would store a\n // credential the user no longer intends to send.\n const values: Record<string, unknown> = {};\n for (const [field, value] of Object.entries(visibleValues(activeSchema, fieldValues))) {\n if (typeof value === 'string') {\n const trimmed = value.trim();\n if (trimmed) values[field] = trimmed;\n } else if (value !== undefined && value !== null) {\n values[field] = value;\n }\n }\n await authenticateConnection(connId, selectedAuthMethodKey ?? undefined, values);\n setSuccess(true);\n onConnectionCreated?.(connId);\n }\n }\n } catch (err) {\n setErrorMessage(err instanceof Error ? err.message : 'Connection failed');\n }\n }, [\n selectedProvider,\n connectionName,\n connectionDescription,\n selectedAuthMethodKey,\n authFlow,\n authTypeForMethod,\n authScopes,\n activeSchema,\n fieldValues,\n selectedAuthMethod,\n createConnection,\n initiateOAuth,\n fetchConnection,\n authenticateConnection,\n authenticateWithServiceAccount,\n apiGatewayUrl,\n onConnectionCreated,\n credentialStorage,\n ]);\n\n // Tab items\n const tabs: { key: DialogTab; label: string; icon: typeof Link2 }[] = [\n { key: 'connection', label: 'Connection', icon: Link2 },\n { key: 'details', label: 'Details', icon: Info },\n ];\n\n if (!open) return null;\n\n if (!canCreate && !permissionsLoading) {\n return (\n <>\n <div\n style={{ zIndex: OVERLAY_Z }}\n className=\"fixed inset-0 bg-bg-overlay animate-in fade-in-0 duration-200\"\n onClick={onClose}\n />\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"add-connection-denied-title\"\n style={{ zIndex: DIALOG_Z }}\n className=\"fixed inset-x-4 top-1/2 mx-auto flex max-w-md -translate-y-1/2 flex-col items-center gap-4 rounded-xl border border-border-subtle bg-bg-surface p-8 shadow-2xl text-center\"\n >\n <Shield size={40} className=\"text-text-secondary\" />\n <h2 id=\"add-connection-denied-title\" className=\"text-lg font-semibold text-text-primary\">\n Access Denied\n </h2>\n <p className=\"text-sm text-text-secondary\">\n You don&apos;t have permission to create connections.\n </p>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"px-4 py-2 text-sm font-medium rounded-md border border-border-subtle hover:bg-accent transition-colors\"\n >\n Close\n </button>\n </div>\n </>\n );\n }\n\n return (\n <>\n {/* Backdrop */}\n <div\n style={{ zIndex: OVERLAY_Z }}\n className=\"fixed inset-0 bg-bg-overlay animate-in fade-in-0 duration-200\"\n onClick={onClose}\n />\n\n {/* Dialog */}\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"add-connection-dialog-title\"\n /* `sm:` centres the dialog with `top-1/2 bottom-auto`, which leaves its\n height unbounded — a tall provider form grew past the viewport and was\n clipped at BOTH ends, taking the title and the Save button with it.\n The max-height puts the overflow back where it belongs: the scrollable\n body below. */\n style={{ zIndex: DIALOG_Z }}\n className=\"fixed inset-x-4 top-4 bottom-4 mx-auto flex w-auto max-w-3xl flex-col overflow-hidden rounded-xl border border-border-subtle bg-bg-surface shadow-2xl animate-in fade-in-0 zoom-in-95 duration-200 sm:inset-x-6 sm:top-1/2 sm:bottom-auto sm:max-h-[min(90vh,56rem)] sm:w-full sm:-translate-y-1/2\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between px-5 py-4 border-b border-border-subtle flex-shrink-0\">\n <div className=\"flex items-center gap-3\">\n {selectedProvider && !showPicker ? (\n <>\n <ProviderIcon provider={selectedProvider} size={32} />\n <div>\n <h2\n id=\"add-connection-dialog-title\"\n className=\"text-base font-semibold text-text-primary\"\n >\n {selectedProvider.name} account\n </h2>\n <p className=\"text-xs text-text-secondary\">\n {getAuthTypeLabel(selectedProvider.authType)}\n </p>\n </div>\n </>\n ) : (\n <div>\n <h2\n id=\"add-connection-dialog-title\"\n className=\"text-base font-semibold text-text-primary\"\n >\n Add new credential\n </h2>\n <p className=\"text-xs text-text-secondary\">\n Select an app or service to connect to\n </p>\n </div>\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n {selectedProvider && !showPicker && !success && (\n <button\n type=\"button\"\n onClick={handleSubmit}\n disabled={isAuthenticating || !connectionName.trim()}\n className=\"inline-flex items-center gap-1.5 px-4 py-1.5 text-sm font-medium rounded-md bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bg/90 transition-colors disabled:opacity-50\"\n >\n {isAuthenticating ? (\n <Loader2 size={14} className=\"animate-spin\" />\n ) : (\n <Check size={14} />\n )}\n {oauthWaiting ? 'Waiting...' : 'Save'}\n </button>\n )}\n <button\n type=\"button\"\n onClick={onClose}\n className=\"p-1.5 rounded-md hover:bg-accent transition-colors text-text-secondary hover:text-text-primary\"\n aria-label=\"Close\"\n >\n <X size={20} />\n </button>\n </div>\n </div>\n\n {/* Body */}\n <div className=\"flex flex-1 min-h-0 overflow-hidden\">\n {/* Provider Picker Mode */}\n {showPicker && !selectedProvider && (\n <div className=\"flex-1 p-5 overflow-y-auto\">\n <p className=\"text-sm text-text-secondary mb-3\">\n Select an app or service to connect to\n </p>\n <div className=\"relative mb-4\">\n <Search\n size={16}\n className=\"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary\"\n />\n <input\n ref={searchInputRef}\n type=\"text\"\n value={searchQuery}\n onChange={(e) => setSearchQuery(e.target.value)}\n placeholder=\"Search providers...\"\n aria-label=\"Search providers\"\n className=\"w-full pl-9 pr-3 py-2.5 border border-border-subtle rounded-md bg-bg-surface text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n />\n </div>\n\n {providersLoading ? (\n <div className=\"flex items-center justify-center py-8\">\n <Loader2 size={24} className=\"animate-spin text-text-secondary\" />\n </div>\n ) : filteredProviders.length === 0 ? (\n <IllustratedEmptyState\n illustration={searchQuery ? 'empty-search' : 'empty-data'}\n title={searchQuery ? 'No matching providers' : 'No providers available'}\n description={\n searchQuery\n ? `No installed provider matches “${searchQuery}”. Try a different term.`\n : 'Install and enable a provider from the catalog to create a connection.'\n }\n />\n ) : (\n <div className=\"max-h-[400px] overflow-y-auto space-y-1\">\n {Object.entries(groupedProviders).map(([category, categoryProviders]) => (\n <div key={category}>\n <div className=\"px-2 py-1.5 text-xs font-semibold text-text-secondary uppercase tracking-wider\">\n {getCategoryLabel(category as IntegrationProvider['category'])}\n </div>\n {categoryProviders.map((provider) => (\n <button\n key={provider.id}\n type=\"button\"\n onClick={() => handleSelectProvider(provider)}\n className=\"w-full flex items-center gap-3 px-3 py-2.5 rounded-md hover:bg-accent/50 transition-colors text-left\"\n >\n <ProviderIcon provider={provider} size={32} />\n <div className=\"flex-1 min-w-0\">\n <div className=\"text-sm font-medium text-text-primary\">\n {provider.name}\n </div>\n <div className=\"text-xs text-text-secondary\">\n {getAuthTypeLabel(provider.authType)}\n </div>\n </div>\n </button>\n ))}\n </div>\n ))}\n </div>\n )}\n </div>\n )}\n\n {/* Loading preselected provider (catalog load or by-id fallback fetch) */}\n {!showPicker && !selectedProvider && preselectedResolving && (\n <div className=\"flex-1 flex items-center justify-center\">\n <Loader2 size={32} className=\"animate-spin text-text-secondary\" />\n </div>\n )}\n\n {/* Preselected provider couldn't be resolved (invalid id / fetch error) */}\n {!showPicker && !selectedProvider && !preselectedResolving && preselectedProviderId && (\n <div className=\"flex-1 flex flex-col items-center justify-center p-8 text-center\">\n <AlertCircle size={32} className=\"text-text-secondary mb-3\" />\n <p className=\"text-sm text-text-secondary\">This provider isn&apos;t available.</p>\n </div>\n )}\n\n {/* Success State */}\n {success && selectedProvider && (\n <div className=\"flex-1 flex flex-col items-center justify-center p-8 text-center\">\n <div className=\"p-3 rounded-full bg-status-success-bg-subtle mb-4\">\n <CheckCircle2 size={48} className=\"text-status-success-text\" />\n </div>\n <h3 className=\"text-lg font-semibold text-text-primary mb-1\">Connection Created!</h3>\n <p className=\"text-sm text-text-secondary mb-6\">\n Your {selectedProvider.name} connection has been set up successfully.\n </p>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"px-4 py-2 text-sm font-medium rounded-md bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bg/90 transition-colors\"\n >\n Close dialog\n </button>\n </div>\n )}\n\n {/* Form Mode (with sidebar tabs) */}\n {selectedProvider && !showPicker && !success && (\n <>\n {/* Left Sidebar Tabs */}\n <div className=\"w-full border-b border-border-subtle sm:w-40 sm:border-b-0 sm:border-r flex-shrink-0 py-3 overflow-x-auto\">\n {tabs.map((tab) => {\n const TabIcon = tab.icon;\n return (\n <button\n key={tab.key}\n type=\"button\"\n onClick={() => setActiveTab(tab.key)}\n className={cn(\n 'flex min-w-max items-center gap-2 px-4 py-2 text-sm font-medium transition-colors sm:w-full',\n activeTab === tab.key\n ? 'text-text-primary bg-accent/50 border-b-2 border-primary sm:border-b-0 sm:border-l-2'\n : 'text-text-secondary hover:text-text-primary hover:bg-accent/30 border-b-2 border-transparent sm:border-b-0 sm:border-l-2'\n )}\n >\n <TabIcon size={16} />\n {tab.label}\n </button>\n );\n })}\n </div>\n\n {/* Main Content Area */}\n <div className=\"flex-1 p-5 overflow-y-auto\">\n {/* Connection Tab */}\n {activeTab === 'connection' && (\n <div className=\"space-y-5\">\n {/* Error Banner */}\n {errorMessage && (\n <div className=\"flex items-center gap-2 px-3 py-2 rounded-md bg-status-error-bg/10 border border-status-error-border/20\">\n <AlertCircle size={16} className=\"text-status-error-text flex-shrink-0\" />\n <span className=\"text-sm text-status-error-text\">{errorMessage}</span>\n </div>\n )}\n\n {/* Connection Name */}\n <div>\n <label\n htmlFor={fieldId('conn-name')}\n className=\"block text-sm font-medium text-text-primary mb-1.5\"\n >\n Connection Name <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n id={fieldId('conn-name')}\n aria-label=\"Connection Name\"\n type=\"text\"\n value={connectionName}\n onChange={(e) => setConnectionName(e.target.value)}\n placeholder={`My ${selectedProvider.name} Connection`}\n disabled={isAuthenticating}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50\"\n />\n </div>\n\n {/* Description */}\n <div>\n <label\n htmlFor={fieldId('conn-desc')}\n className=\"block text-sm font-medium text-text-primary mb-1.5\"\n >\n Description\n </label>\n <input\n id={fieldId('conn-desc')}\n aria-label=\"Description\"\n type=\"text\"\n value={connectionDescription}\n onChange={(e) => setConnectionDescription(e.target.value)}\n placeholder=\"Optional description\"\n disabled={isAuthenticating}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50\"\n />\n </div>\n\n {/* First-party SERVICE_ACCOUNT connections store no\n credential, so they need no vault/secret picker. */}\n {selectedProvider.authType !== 'service_account' && (\n <CredentialStorageSelector\n value={credentialStorage}\n onChange={setCredentialStorage}\n providerAuthType={selectedProvider.authType}\n />\n )}\n\n {/* Authentication — entirely data-driven.\n The method dropdown appears only when the provider offers\n a choice; the fields below come from that method's\n configSchema, so no provider or auth type has bespoke\n markup here. */}\n <div className=\"rounded-md border border-border-subtle/50 bg-bg-surface p-4 space-y-3\">\n {/* The method sits on the heading row, right-aligned —\n it decides what every field below it is, so it belongs\n with the section title rather than among the fields it\n governs. Single-method providers show the method's\n name here instead, since there is nothing to choose. */}\n <div className=\"flex items-center justify-between gap-3\">\n <h3 className=\"font-medium text-text-primary flex items-center gap-2 text-sm\">\n <Shield size={16} className=\"text-primary\" />\n Authentication\n {authMethods.length <= 1 && (\n <span className=\"text-text-secondary font-normal\">\n &middot;{' '}\n {selectedAuthMethod?.displayName ??\n getAuthTypeLabel(selectedProvider.authType)}\n </span>\n )}\n </h3>\n <AuthMethodSelector\n methods={authMethods}\n // Raw key, not the resolved method: the selector needs\n // to see null vs stale itself, or its placeholder can\n // never render.\n selectedKey={selectedAuthMethodKey}\n onSelect={setSelectedAuthMethodKey}\n disabled={isAuthenticating}\n idPrefix={fieldId('auth-method')}\n compact\n />\n </div>\n\n {/* What the chosen method means, kept beside the fields\n it governs. */}\n <div className=\"space-y-2\">\n <AuthMethodNotice method={selectedAuthMethod} />\n </div>\n\n {authFlow === 'oauth2' && (\n <>\n {/* An OAuth method may still declare fields — a tenant\n subdomain, a base URL, bring-your-own-app settings.\n Rendering them only for the `fields` flow made such\n methods impossible to use: the inputs never\n appeared and nothing was ever collected. */}\n {activeSchema && (\n <SchemaForm\n schema={activeSchema}\n values={fieldValues}\n onChange={setFieldValues}\n disabled={isAuthenticating}\n idPrefix={fieldId('oauth-cfg')}\n />\n )}\n <div className=\"flex items-center gap-2 px-3 py-2 rounded-md bg-status-info-bg-subtle border border-border-default\">\n <ExternalLink\n size={14}\n className=\"text-status-info-text flex-shrink-0\"\n />\n <span className=\"text-xs text-status-info-text\">\n A popup window will open for {selectedProvider.name} sign-in\n </span>\n </div>\n </>\n )}\n\n {authFlow === 'minted' && (\n <div className=\"flex items-center gap-2 px-3 py-2 rounded-md bg-status-info-bg-subtle border border-border-default\">\n <Shield size={14} className=\"text-status-info-text flex-shrink-0\" />\n <span className=\"text-xs text-status-info-text\">\n No credentials to enter — access is granted on your behalf and tokens\n are issued per use.\n </span>\n </div>\n )}\n\n {authFlow === 'fields' &&\n (activeSchema ? (\n <>\n <p className=\"text-xs text-text-secondary\">\n Secret values are stored encrypted and never shown again.\n </p>\n <SchemaForm\n schema={activeSchema}\n values={fieldValues}\n onChange={setFieldValues}\n disabled={isAuthenticating}\n idPrefix={fieldId('cred')}\n />\n </>\n ) : (\n <div className=\"flex items-center gap-2 px-3 py-2 rounded-md bg-status-error-bg-subtle border border-border-default\">\n <AlertCircle\n size={16}\n className=\"text-status-error-text flex-shrink-0\"\n />\n <span className=\"text-sm text-status-error-text\">\n This authentication method does not declare a configuration form.\n </span>\n </div>\n ))}\n </div>\n </div>\n )}\n\n {/* Details Tab */}\n {activeTab === 'details' && (\n <div className=\"space-y-4\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Details</h3>\n <div className=\"space-y-3\">\n <div className=\"flex items-center gap-3 p-3 rounded-md border border-border-subtle\">\n <ProviderIcon provider={selectedProvider} size={40} />\n <div>\n <p className=\"text-sm font-medium text-text-primary\">\n {selectedProvider.name}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {getAuthTypeLabel(selectedProvider.authType)} &middot;{' '}\n {getCategoryLabel(selectedProvider.category)}\n </p>\n </div>\n </div>\n {selectedProvider.description && (\n <div>\n <div className=\"text-xs font-medium text-text-secondary uppercase tracking-wider\">\n Description\n </div>\n <p className=\"text-sm text-text-primary mt-1\">\n {selectedProvider.description}\n </p>\n </div>\n )}\n {selectedProvider.website && (\n <div>\n <div className=\"text-xs font-medium text-text-secondary uppercase tracking-wider\">\n Website\n </div>\n <a\n href={selectedProvider.website}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"block text-sm text-primary hover:underline mt-1\"\n >\n {selectedProvider.website}\n </a>\n </div>\n )}\n {selectedProvider.docsUrl && (\n <div>\n <div className=\"text-xs font-medium text-text-secondary uppercase tracking-wider\">\n Documentation\n </div>\n <a\n href={selectedProvider.docsUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"block text-sm text-primary hover:underline mt-1\"\n >\n {selectedProvider.docsUrl}\n </a>\n </div>\n )}\n </div>\n </div>\n )}\n </div>\n </>\n )}\n </div>\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuFA,IAAM,KAAY,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AA;QAEP,EAAiB,WAChB,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,OAAD;SAAK,WAAU;mBAAmE;SAE5E,CAAA,EACN,kBAAC,KAAD;SACE,MAAM,EAAiB;SACvB,QAAO;SACP,KAAI;SACJ,WAAU;mBAET,EAAiB;SAChB,CAAA,CACA,EAAA,CAAA;QAEJ;SACF;QAEJ;OACL,EAAA,CAAA;IAED;KACF;IACL,EAAA,CAAA,GArea"}
1
+ {"version":3,"file":"AddConnectionDialog.js","names":[],"sources":["../../../src/integrations/components/AddConnectionDialog.tsx"],"sourcesContent":["/**\n * AddConnectionDialog -- n8n-style popup for creating new connections.\n *\n * Replaces the full-page AddConnectionWizard with an inline modal dialog.\n * Uses the same hooks and GraphQL operations that already exist in\n * microfe-integrations (useCreateConnection, useInitiateOAuth, etc.).\n *\n * Opens from any page via Zustand store state, so there is no navigation\n * to /connections/add — the dialog overlays the current page.\n */\n\nimport { useState, useMemo, useCallback, useEffect, useRef, useId } from 'react';\nimport {\n X,\n Check,\n Loader2,\n AlertCircle,\n CheckCircle2,\n Search,\n ExternalLink,\n Shield,\n Link2,\n Info,\n} from 'lucide-react';\nimport { cn } from '../utils/cn';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../hooks/useTr';\nimport { useCategoryLabel, useAuthTypeLabel } from '../hooks/useLabel';\nimport { legacyFlowForAuthType } from '../utils/integrationsHelpers';\nimport { useIntegrations } from '../providers/IntegrationsProvider';\nimport { INTEGRATION_PERMISSIONS } from '../constants/permissions';\nimport { useProviders, useProvider } from '../hooks/useProviders';\nimport {\n useCreateConnection,\n useInitiateOAuth,\n useAuthenticateConnection,\n useAuthenticateWithServiceAccount,\n} from '../hooks/useConnections';\nimport { useGetConnectionLazyQuery } from '../../generated/wspace-operations';\nimport { waitForOAuthPopupCompletion } from '../utils/oauthPopup';\nimport {\n CredentialStorageSelector,\n type CredentialStorageState,\n} from './CredentialStorageSelector';\nimport { AuthMethodNotice, AuthMethodSelector } from './AuthMethodSelector';\nimport { ProviderIcon } from './ProviderIcon';\nimport {\n SchemaForm,\n initialValuesFromSchema,\n isSchemaComplete,\n parseFormSchema,\n visibleValues,\n} from './SchemaForm';\nimport type { IntegrationProvider } from '../types';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface AddConnectionDialogProps {\n /** Whether the dialog is open */\n open: boolean;\n /** Callback to close the dialog */\n onClose: () => void;\n /** Pre-selected provider ID (skips provider picker step) */\n preselectedProviderId?: string | null;\n /** Callback when a connection is successfully created */\n onConnectionCreated?: (connectionId: string) => void;\n}\n\ntype DialogTab = 'connection' | 'details';\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * Above the app shell's header (`z-index: 100`).\n *\n * The dialog used to sit at Tailwind's `z-50`, so the shell header painted over\n * its top edge and swallowed the title and the Method control — the dialog\n * looked \"cut off\" no matter how its height was constrained. A modal must\n * out-rank the chrome it covers, and Tailwind's scale stops well below it.\n */\nconst OVERLAY_Z = 1100;\nconst DIALOG_Z = 1101;\n\nexport function AddConnectionDialog({\n open,\n onClose,\n preselectedProviderId,\n onConnectionCreated,\n}: AddConnectionDialogProps) {\n // Provider data\n const tr = useTr();\n const getCategoryLabel = useCategoryLabel();\n const getAuthTypeLabel = useAuthTypeLabel();\n const { apiGatewayUrl } = useIntegrations();\n const { providers, loading: providersLoading } = useProviders();\n // A preselected id may not be in the catalog page (disabled provider linked\n // from its own detail page). Resolve such ids via a direct by-id fetch so the\n // dialog never dead-ends on a blank body.\n const providerInList = useMemo(\n () =>\n preselectedProviderId\n ? ((providers ?? []).find((p: IntegrationProvider) => p.id === preselectedProviderId) ??\n null)\n : null,\n [providers, preselectedProviderId]\n );\n // Only fetch once the catalog has loaded and confirmed the id isn't in the\n // filtered list — avoids a redundant GetProvider for visible providers.\n const { provider: fetchedPreselectedProvider, loading: fetchedPreselectedLoading } = useProvider(\n !providersLoading && preselectedProviderId && !providerInList ? preselectedProviderId : ''\n );\n const resolvedPreselectedProvider = providerInList ?? fetchedPreselectedProvider;\n // True while a preselected provider is still being resolved (catalog load or\n // the by-id fallback fetch) — keeps the body showing a spinner, not blank.\n const preselectedResolving =\n !!preselectedProviderId &&\n !resolvedPreselectedProvider &&\n (providersLoading || fetchedPreselectedLoading);\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const canCreate = !permissionsLoading && hasPermission(INTEGRATION_PERMISSIONS.CONNECTION_CREATE);\n\n // Mutations\n const { createConnection, loading: creating } = useCreateConnection();\n const { initiateOAuth, loading: oauthLoading } = useInitiateOAuth();\n const { authenticateConnection, loading: authenticating } = useAuthenticateConnection();\n const { authenticateWithServiceAccount, loading: serviceAccountLoading } =\n useAuthenticateWithServiceAccount();\n const [fetchConnection] = useGetConnectionLazyQuery({ fetchPolicy: 'network-only' });\n\n // State\n const [selectedProvider, setSelectedProvider] = useState<IntegrationProvider | null>(null);\n const [showPicker, setShowPicker] = useState(!preselectedProviderId);\n const [activeTab, setActiveTab] = useState<DialogTab>('connection');\n const [searchQuery, setSearchQuery] = useState('');\n const [connectionName, setConnectionName] = useState('');\n const [connectionDescription, setConnectionDescription] = useState('');\n /** Auth method the user picked; null until a provider is selected. */\n const [selectedAuthMethodKey, setSelectedAuthMethodKey] = useState<string | null>(null);\n /** Values for the selected method's schema-described fields. */\n const [fieldValues, setFieldValues] = useState<Record<string, unknown>>({});\n const [credentialStorage, setCredentialStorage] = useState<CredentialStorageState>({\n mode: 'managed',\n vaultId: '',\n secretId: '',\n managedSecretName: '',\n });\n const [errorMessage, setErrorMessage] = useState('');\n const [success, setSuccess] = useState(false);\n const [oauthWaiting, setOauthWaiting] = useState(false);\n const [, setCreatedConnectionId] = useState<string | null>(null);\n\n const oauthPopupRef = useRef<Window | null>(null);\n const oauthCleanupRef = useRef<(() => void) | null>(null);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const idPrefix = useId();\n const fieldId = (name: string) => `${idPrefix}-${name}`;\n\n // ── Auth method resolution ────────────────────────────────────────────────\n // Everything the auth section renders and submits derives from the selected\n // method. Providers with a single method behave exactly as before.\n const authMethods = useMemo(\n () => (selectedProvider?.authMethods ?? []).filter((method) => method.isEnabled),\n [selectedProvider]\n );\n const selectedAuthMethod = useMemo(\n () =>\n authMethods.find((method) => method.key === selectedAuthMethodKey) ?? authMethods[0] ?? null,\n [authMethods, selectedAuthMethodKey]\n );\n // Fall back to the provider's own authType for providers whose methods have\n // not been fetched (older fragments) or backfilled yet.\n const authFlow = selectedAuthMethod?.flow ?? legacyFlowForAuthType(selectedProvider?.authType);\n const authTypeForMethod = selectedAuthMethod?.authType ?? selectedProvider?.authType;\n // Memoized: a fresh array each render would re-create handleSubmit's\n // useCallback on every render.\n const authScopes = useMemo(\n () =>\n selectedAuthMethod?.defaultScopes?.length\n ? selectedAuthMethod.defaultScopes\n : (selectedProvider?.defaultScopes ?? []),\n [selectedAuthMethod, selectedProvider]\n );\n const activeSchema = useMemo(\n () => parseFormSchema(selectedAuthMethod?.configSchema ?? selectedProvider?.configSchema),\n [selectedAuthMethod, selectedProvider]\n );\n\n // Selecting a different method must not carry the previous method's values\n // over — they belong to a different credential shape entirely.\n useEffect(() => {\n // Seeded from the schema's declared defaults, not empty: a rendered control\n // shows its default as selected, so leaving state empty made validation\n // treat a visible value as missing and dropped it from the submission.\n setFieldValues(initialValuesFromSchema(activeSchema));\n setErrorMessage('');\n // activeSchema is derived from these two, so it is not an extra trigger.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedAuthMethodKey, selectedProvider?.id]);\n\n useEffect(() => {\n if (!open) return undefined;\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n onClose();\n }\n };\n\n window.addEventListener('keydown', handleKeyDown);\n return () => window.removeEventListener('keydown', handleKeyDown);\n }, [open, onClose]);\n\n // Cleanup OAuth listener and popup on unmount.\n useEffect(() => {\n return () => {\n oauthCleanupRef.current?.();\n if (oauthPopupRef.current && !oauthPopupRef.current.closed) {\n oauthPopupRef.current.close();\n }\n };\n }, []);\n\n // Reset state when dialog opens\n useEffect(() => {\n if (open) {\n setActiveTab('connection');\n setSearchQuery('');\n setConnectionName('');\n setConnectionDescription('');\n setSelectedAuthMethodKey(null);\n setFieldValues({});\n setCredentialStorage({ mode: 'managed', vaultId: '', secretId: '', managedSecretName: '' });\n setErrorMessage('');\n setSuccess(false);\n setOauthWaiting(false);\n setCreatedConnectionId(null);\n\n if (preselectedProviderId) {\n setShowPicker(false);\n setSelectedProvider(null); // will be set by effect below\n } else {\n setShowPicker(true);\n setSelectedProvider(null);\n }\n }\n }, [open, preselectedProviderId]);\n\n // Find and set preselected provider (from the filtered list or, for hidden\n // built-ins, the direct by-id fetch above).\n useEffect(() => {\n if (open && preselectedProviderId && resolvedPreselectedProvider && !selectedProvider) {\n setSelectedProvider(resolvedPreselectedProvider);\n setConnectionName(`${resolvedPreselectedProvider.name} Connection`);\n setShowPicker(false);\n }\n }, [open, preselectedProviderId, resolvedPreselectedProvider, selectedProvider]);\n\n // Auto-focus search input when picker is shown\n useEffect(() => {\n if (open && showPicker) {\n const timeoutId = setTimeout(() => searchInputRef.current?.focus(), 100);\n return () => clearTimeout(timeoutId);\n }\n return undefined;\n }, [open, showPicker]);\n\n // Filter providers for picker\n const filteredProviders = useMemo(() => {\n const installed = (providers ?? []).filter(\n (p: IntegrationProvider) => p.pluginStatus === 'installed' && p.isEnabled\n );\n if (!searchQuery.trim()) return installed;\n const q = searchQuery.toLowerCase();\n return installed.filter(\n (p: IntegrationProvider) =>\n p.name.toLowerCase().includes(q) ||\n (p.description ?? '').toLowerCase().includes(q) ||\n p.key.toLowerCase().includes(q)\n );\n }, [providers, searchQuery]);\n\n // Group providers by category\n const groupedProviders = useMemo(() => {\n const groups: Record<string, IntegrationProvider[]> = {};\n filteredProviders.forEach((p: IntegrationProvider) => {\n const cat = p.category;\n if (!groups[cat]) groups[cat] = [];\n groups[cat].push(p);\n });\n return groups;\n }, [filteredProviders]);\n\n const handleSelectProvider = useCallback((provider: IntegrationProvider) => {\n setSelectedProvider(provider);\n setConnectionName(`${provider.name} Connection`);\n setShowPicker(false);\n setErrorMessage('');\n }, []);\n\n const isAuthenticating =\n creating || oauthLoading || oauthWaiting || authenticating || serviceAccountLoading;\n\n // Main submit handler\n const handleSubmit = useCallback(async () => {\n if (!selectedProvider || !connectionName.trim()) return;\n\n // Methods that mint tokens on demand store no credential, so they need no\n // vault/secret — skip the credential-storage requirement entirely.\n const isServiceAccount = authFlow === 'minted';\n\n if (!isServiceAccount) {\n if (!credentialStorage.vaultId) {\n setErrorMessage(\n tr(\n 'integrations.addConnection.errors.vaultRequired',\n 'Please select a vault for storing or referencing credentials'\n )\n );\n return;\n }\n if (credentialStorage.mode === 'existing' && !credentialStorage.secretId) {\n setErrorMessage(\n tr(\n 'integrations.addConnection.errors.secretRequired',\n 'Please select an existing vault secret to reuse'\n )\n );\n return;\n }\n }\n\n if (authFlow === 'oauth2' && activeSchema && !isSchemaComplete(activeSchema, fieldValues)) {\n setErrorMessage(\n tr('integrations.addConnection.errors.fieldsRequired', 'Please fill in all required fields')\n );\n return;\n }\n\n if (selectedAuthMethod && !selectedAuthMethod.isConfigured) {\n setErrorMessage(\n tr(\n 'integrations.addConnection.authentication.methodNotConfigured',\n 'This authentication method is not configured in this environment. Ask an administrator to add its credentials, or pick another method.'\n )\n );\n return;\n }\n\n try {\n setErrorMessage('');\n\n // Step 1: Create the connection\n const connId = await createConnection({\n name: connectionName.trim(),\n description: connectionDescription.trim() || undefined,\n providerId: selectedProvider.id,\n authMethodKey: selectedAuthMethodKey ?? undefined,\n // OAuth methods collect non-secret routing settings (tenant subdomain,\n // base URL) rather than a credential, so they belong on the connection\n // config, which getConnectionToken already reads for baseUrl.\n ...(authFlow === 'oauth2' && activeSchema\n ? { config: visibleValues(activeSchema, fieldValues) as Record<string, unknown> }\n : {}),\n ...(isServiceAccount\n ? {}\n : {\n vaultId: credentialStorage.vaultId,\n credentialSecretId:\n credentialStorage.mode === 'existing' ? credentialStorage.secretId : undefined,\n managedSecretName:\n credentialStorage.mode === 'managed'\n ? credentialStorage.managedSecretName.trim() || undefined\n : undefined,\n }),\n });\n\n if (!connId) {\n setErrorMessage(\n tr('integrations.addConnection.errors.createFailed', 'Failed to create connection')\n );\n return;\n }\n\n setCreatedConnectionId(connId);\n\n // Step 2: Authenticate. Driven by the auth method's *flow*, not by a\n // per-auth-type branch: FIELDS methods all submit their schema values\n // through one generic mutation, so adding an auth type needs no new case\n // here and no new mutation to call.\n switch (authFlow) {\n case 'oauth2': {\n const callbackUrl = apiGatewayUrl\n ? `${apiGatewayUrl}/integrations/oauth/callback`\n : '/integrations/oauth/callback';\n const result = await initiateOAuth(connId, callbackUrl, selectedProvider.key);\n if (result?.redirectUrl) {\n const width = 600;\n const height = 700;\n const left = window.screenX + (window.innerWidth - width) / 2;\n const top = window.screenY + (window.innerHeight - height) / 2;\n const popup = window.open(\n result.redirectUrl,\n 'oauth_popup',\n `width=${width},height=${height},left=${left},top=${top},toolbar=no,menubar=no,scrollbars=yes,resizable=yes`\n );\n if (!popup) {\n setErrorMessage(\n tr(\n 'integrations.addConnection.authentication.popupBlocked',\n 'Popup was blocked. Please allow popups for this site and try again.'\n )\n );\n return;\n }\n oauthPopupRef.current = popup;\n setOauthWaiting(true);\n\n oauthCleanupRef.current?.();\n oauthCleanupRef.current = waitForOAuthPopupCompletion({\n connectionId: connId,\n popup,\n fetchConnectionStatus: async () => {\n const { data } = await fetchConnection({ variables: { id: connId } });\n return data?.getConnection ?? null;\n },\n onSuccess: () => {\n setSuccess(true);\n onConnectionCreated?.(connId);\n },\n onError: setErrorMessage,\n onSettled: () => {\n oauthCleanupRef.current = null;\n oauthPopupRef.current = null;\n setOauthWaiting(false);\n },\n });\n\n return;\n }\n setSuccess(true);\n onConnectionCreated?.(connId);\n break;\n }\n case 'minted': {\n // Nothing to collect and nothing stored. SERVICE_ACCOUNT still records\n // the user's delegation for the reserved app; WORKSPACE_APP_TOKEN\n // connections are pure config and are already usable.\n if (authTypeForMethod === 'service_account') {\n await authenticateWithServiceAccount(\n connId,\n authScopes.length > 0 ? authScopes : undefined\n );\n }\n setSuccess(true);\n onConnectionCreated?.(connId);\n break;\n }\n default: {\n // FIELDS: submit whatever the method's schema asked for.\n if (activeSchema) {\n if (!isSchemaComplete(activeSchema, fieldValues)) {\n setErrorMessage(\n tr(\n 'integrations.addConnection.errors.fieldsRequired',\n 'Please fill in all required fields'\n )\n );\n return;\n }\n }\n // Only fields the user can currently see: a `showIf` field that was\n // filled and then hidden must not be submitted, or we would store a\n // credential the user no longer intends to send.\n const values: Record<string, unknown> = {};\n for (const [field, value] of Object.entries(visibleValues(activeSchema, fieldValues))) {\n if (typeof value === 'string') {\n const trimmed = value.trim();\n if (trimmed) values[field] = trimmed;\n } else if (value !== undefined && value !== null) {\n values[field] = value;\n }\n }\n await authenticateConnection(connId, selectedAuthMethodKey ?? undefined, values);\n setSuccess(true);\n onConnectionCreated?.(connId);\n }\n }\n } catch (err) {\n setErrorMessage(\n err instanceof Error\n ? err.message\n : tr('integrations.addConnection.errors.authFailed', 'Authentication failed')\n );\n }\n }, [\n selectedProvider,\n connectionName,\n connectionDescription,\n selectedAuthMethodKey,\n authFlow,\n authTypeForMethod,\n authScopes,\n activeSchema,\n fieldValues,\n selectedAuthMethod,\n createConnection,\n initiateOAuth,\n fetchConnection,\n authenticateConnection,\n authenticateWithServiceAccount,\n apiGatewayUrl,\n onConnectionCreated,\n credentialStorage,\n tr,\n ]);\n\n // Tab items\n const tabs: { key: DialogTab; label: string; icon: typeof Link2 }[] = [\n {\n key: 'connection',\n label: tr('integrations.addConnection.tabs.connection', 'Connection'),\n icon: Link2,\n },\n { key: 'details', label: tr('integrations.addConnection.tabs.details', 'Details'), icon: Info },\n ];\n\n if (!open) return null;\n\n if (!canCreate && !permissionsLoading) {\n return (\n <>\n <div\n style={{ zIndex: OVERLAY_Z }}\n className=\"fixed inset-0 bg-bg-overlay animate-in fade-in-0 duration-200\"\n onClick={onClose}\n />\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"add-connection-denied-title\"\n style={{ zIndex: DIALOG_Z }}\n className=\"fixed inset-x-4 top-1/2 mx-auto flex max-w-md -translate-y-1/2 flex-col items-center gap-4 rounded-xl border border-border-subtle bg-bg-surface p-8 shadow-2xl text-center\"\n >\n <Shield size={40} className=\"text-text-secondary\" />\n <h2 id=\"add-connection-denied-title\" className=\"text-lg font-semibold text-text-primary\">\n {tr('integrations.addConnection.denied.title', 'Access Denied')}\n </h2>\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'integrations.addConnection.denied.description',\n \"You don't have permission to create connections.\"\n )}\n </p>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"px-4 py-2 text-sm font-medium rounded-md border border-border-subtle hover:bg-accent transition-colors\"\n >\n {tr('integrations.common.close', 'Close')}\n </button>\n </div>\n </>\n );\n }\n\n return (\n <>\n {/* Backdrop */}\n <div\n style={{ zIndex: OVERLAY_Z }}\n className=\"fixed inset-0 bg-bg-overlay animate-in fade-in-0 duration-200\"\n onClick={onClose}\n />\n\n {/* Dialog */}\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"add-connection-dialog-title\"\n /* `sm:` centres the dialog with `top-1/2 bottom-auto`, which leaves its\n height unbounded — a tall provider form grew past the viewport and was\n clipped at BOTH ends, taking the title and the Save button with it.\n The max-height puts the overflow back where it belongs: the scrollable\n body below. */\n style={{ zIndex: DIALOG_Z }}\n className=\"fixed inset-x-4 top-4 bottom-4 mx-auto flex w-auto max-w-3xl flex-col overflow-hidden rounded-xl border border-border-subtle bg-bg-surface shadow-2xl animate-in fade-in-0 zoom-in-95 duration-200 sm:inset-x-6 sm:top-1/2 sm:bottom-auto sm:max-h-[min(90vh,56rem)] sm:w-full sm:-translate-y-1/2\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between px-5 py-4 border-b border-border-subtle flex-shrink-0\">\n <div className=\"flex items-center gap-3\">\n {selectedProvider && !showPicker ? (\n <>\n <ProviderIcon provider={selectedProvider} size={32} />\n <div>\n <h2\n id=\"add-connection-dialog-title\"\n className=\"text-base font-semibold text-text-primary\"\n >\n {tr('integrations.addConnection.dialog.accountTitle', '{{provider}} account', {\n provider: selectedProvider.name,\n })}\n </h2>\n <p className=\"text-xs text-text-secondary\">\n {getAuthTypeLabel(selectedProvider.authType)}\n </p>\n </div>\n </>\n ) : (\n <div>\n <h2\n id=\"add-connection-dialog-title\"\n className=\"text-base font-semibold text-text-primary\"\n >\n {tr('integrations.addConnection.dialog.title', 'Add new credential')}\n </h2>\n <p className=\"text-xs text-text-secondary\">\n {tr(\n 'integrations.addConnection.dialog.subtitle',\n 'Select an app or service to connect to'\n )}\n </p>\n </div>\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n {selectedProvider && !showPicker && !success && (\n <button\n type=\"button\"\n onClick={handleSubmit}\n disabled={isAuthenticating || !connectionName.trim()}\n className=\"inline-flex items-center gap-1.5 px-4 py-1.5 text-sm font-medium rounded-md bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bg/90 transition-colors disabled:opacity-50\"\n >\n {isAuthenticating ? (\n <Loader2 size={14} className=\"animate-spin\" />\n ) : (\n <Check size={14} />\n )}\n {oauthWaiting\n ? tr('integrations.addConnection.actions.waiting', 'Waiting...')\n : tr('integrations.common.save', 'Save')}\n </button>\n )}\n <button\n type=\"button\"\n onClick={onClose}\n className=\"p-1.5 rounded-md hover:bg-accent transition-colors text-text-secondary hover:text-text-primary\"\n aria-label={tr('integrations.addConnection.actions.close', 'Close dialog')}\n >\n <X size={20} />\n </button>\n </div>\n </div>\n\n {/* Body */}\n <div className=\"flex flex-1 min-h-0 overflow-hidden\">\n {/* Provider Picker Mode */}\n {showPicker && !selectedProvider && (\n <div className=\"flex-1 p-5 overflow-y-auto\">\n <p className=\"text-sm text-text-secondary mb-3\">\n {tr(\n 'integrations.addConnection.dialog.subtitle',\n 'Select an app or service to connect to'\n )}\n </p>\n <div className=\"relative mb-4\">\n <Search\n size={16}\n className=\"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary\"\n />\n <input\n ref={searchInputRef}\n type=\"text\"\n value={searchQuery}\n onChange={(e) => setSearchQuery(e.target.value)}\n placeholder={tr(\n 'integrations.addConnection.search.placeholder',\n 'Search installed providers...'\n )}\n aria-label={tr(\n 'integrations.addConnection.search.ariaLabel',\n 'Search installed providers'\n )}\n className=\"w-full pl-9 pr-3 py-2.5 border border-border-subtle rounded-md bg-bg-surface text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n />\n </div>\n\n {providersLoading ? (\n <div className=\"flex items-center justify-center py-8\">\n <Loader2 size={24} className=\"animate-spin text-text-secondary\" />\n </div>\n ) : filteredProviders.length === 0 ? (\n <IllustratedEmptyState\n illustration={searchQuery ? 'empty-search' : 'empty-data'}\n title={\n searchQuery\n ? tr(\n 'integrations.addConnection.empty.noMatchingProviders',\n 'No matching providers'\n )\n : tr(\n 'integrations.addConnection.empty.noInstalledProviders',\n 'No installed providers yet'\n )\n }\n description={\n searchQuery\n ? tr(\n 'integrations.addConnection.empty.matchingDescription',\n 'No installed provider matches your search. Try a different term or install one from the catalog.',\n { query: searchQuery }\n )\n : tr(\n 'integrations.addConnection.empty.installedDescription',\n 'You need at least one installed, enabled provider before you can create a connection. Install one from the catalog to get started.'\n )\n }\n />\n ) : (\n <div className=\"max-h-[400px] overflow-y-auto space-y-1\">\n {Object.entries(groupedProviders).map(([category, categoryProviders]) => (\n <div key={category}>\n <div className=\"px-2 py-1.5 text-xs font-semibold text-text-secondary uppercase tracking-wider\">\n {getCategoryLabel(category as IntegrationProvider['category'])}\n </div>\n {categoryProviders.map((provider) => (\n <button\n key={provider.id}\n type=\"button\"\n onClick={() => handleSelectProvider(provider)}\n className=\"w-full flex items-center gap-3 px-3 py-2.5 rounded-md hover:bg-accent/50 transition-colors text-left\"\n >\n <ProviderIcon provider={provider} size={32} />\n <div className=\"flex-1 min-w-0\">\n <div className=\"text-sm font-medium text-text-primary\">\n {provider.name}\n </div>\n <div className=\"text-xs text-text-secondary\">\n {getAuthTypeLabel(provider.authType)}\n </div>\n </div>\n </button>\n ))}\n </div>\n ))}\n </div>\n )}\n </div>\n )}\n\n {/* Loading preselected provider (catalog load or by-id fallback fetch) */}\n {!showPicker && !selectedProvider && preselectedResolving && (\n <div className=\"flex-1 flex items-center justify-center\">\n <Loader2 size={32} className=\"animate-spin text-text-secondary\" />\n </div>\n )}\n\n {/* Preselected provider couldn't be resolved (invalid id / fetch error) */}\n {!showPicker && !selectedProvider && !preselectedResolving && preselectedProviderId && (\n <div className=\"flex-1 flex flex-col items-center justify-center p-8 text-center\">\n <AlertCircle size={32} className=\"text-text-secondary mb-3\" />\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'integrations.addConnection.providerUnavailable',\n \"This provider isn't available.\"\n )}\n </p>\n </div>\n )}\n\n {/* Success State */}\n {success && selectedProvider && (\n <div className=\"flex-1 flex flex-col items-center justify-center p-8 text-center\">\n <div className=\"p-3 rounded-full bg-status-success-bg-subtle mb-4\">\n <CheckCircle2 size={48} className=\"text-status-success-text\" />\n </div>\n <h3 className=\"text-lg font-semibold text-text-primary mb-1\">\n {tr('integrations.addConnection.success.title', 'Connection Created!')}\n </h3>\n <p className=\"text-sm text-text-secondary mb-6\">\n {tr(\n 'integrations.addConnection.success.description',\n 'Your {{provider}} connection has been set up successfully.',\n { provider: selectedProvider.name }\n )}\n </p>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"px-4 py-2 text-sm font-medium rounded-md bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bg/90 transition-colors\"\n >\n {tr('integrations.addConnection.actions.close', 'Close dialog')}\n </button>\n </div>\n )}\n\n {/* Form Mode (with sidebar tabs) */}\n {selectedProvider && !showPicker && !success && (\n <>\n {/* Left Sidebar Tabs */}\n <div className=\"w-full border-b border-border-subtle sm:w-40 sm:border-b-0 sm:border-r flex-shrink-0 py-3 overflow-x-auto\">\n {tabs.map((tab) => {\n const TabIcon = tab.icon;\n return (\n <button\n key={tab.key}\n type=\"button\"\n onClick={() => setActiveTab(tab.key)}\n className={cn(\n 'flex min-w-max items-center gap-2 px-4 py-2 text-sm font-medium transition-colors sm:w-full',\n activeTab === tab.key\n ? 'text-text-primary bg-accent/50 border-b-2 border-primary sm:border-b-0 sm:border-l-2'\n : 'text-text-secondary hover:text-text-primary hover:bg-accent/30 border-b-2 border-transparent sm:border-b-0 sm:border-l-2'\n )}\n >\n <TabIcon size={16} />\n {tab.label}\n </button>\n );\n })}\n </div>\n\n {/* Main Content Area */}\n <div className=\"flex-1 p-5 overflow-y-auto\">\n {/* Connection Tab */}\n {activeTab === 'connection' && (\n <div className=\"space-y-5\">\n {/* Error Banner */}\n {errorMessage && (\n <div className=\"flex items-center gap-2 px-3 py-2 rounded-md bg-status-error-bg/10 border border-status-error-border/20\">\n <AlertCircle size={16} className=\"text-status-error-text flex-shrink-0\" />\n <span className=\"text-sm text-status-error-text\">{errorMessage}</span>\n </div>\n )}\n\n {/* Connection Name */}\n <div>\n <label\n htmlFor={fieldId('conn-name')}\n className=\"block text-sm font-medium text-text-primary mb-1.5\"\n >\n {tr('integrations.addConnection.fields.connectionName', 'Connection Name')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n id={fieldId('conn-name')}\n aria-label={tr(\n 'integrations.addConnection.fields.connectionName',\n 'Connection Name'\n )}\n type=\"text\"\n value={connectionName}\n onChange={(e) => setConnectionName(e.target.value)}\n placeholder={tr(\n 'integrations.addConnection.fields.connectionNamePlaceholder',\n 'e.g., My {{provider}} Connection',\n { provider: selectedProvider.name }\n )}\n disabled={isAuthenticating}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50\"\n />\n </div>\n\n {/* Description */}\n <div>\n <label\n htmlFor={fieldId('conn-desc')}\n className=\"block text-sm font-medium text-text-primary mb-1.5\"\n >\n {tr('integrations.addConnection.fields.description', 'Description')}\n </label>\n <input\n id={fieldId('conn-desc')}\n aria-label={tr(\n 'integrations.addConnection.fields.description',\n 'Description'\n )}\n type=\"text\"\n value={connectionDescription}\n onChange={(e) => setConnectionDescription(e.target.value)}\n placeholder={tr(\n 'integrations.addConnection.fields.descriptionPlaceholder',\n 'Optional description...'\n )}\n disabled={isAuthenticating}\n className=\"w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50\"\n />\n </div>\n\n {/* First-party SERVICE_ACCOUNT connections store no\n credential, so they need no vault/secret picker. */}\n {selectedProvider.authType !== 'service_account' && (\n <CredentialStorageSelector\n value={credentialStorage}\n onChange={setCredentialStorage}\n providerAuthType={selectedProvider.authType}\n />\n )}\n\n {/* Authentication — entirely data-driven.\n The method dropdown appears only when the provider offers\n a choice; the fields below come from that method's\n configSchema, so no provider or auth type has bespoke\n markup here. */}\n <div className=\"rounded-md border border-border-subtle/50 bg-bg-surface p-4 space-y-3\">\n {/* The method sits on the heading row, right-aligned —\n it decides what every field below it is, so it belongs\n with the section title rather than among the fields it\n governs. Single-method providers show the method's\n name here instead, since there is nothing to choose. */}\n <div className=\"flex items-center justify-between gap-3\">\n <h3 className=\"font-medium text-text-primary flex items-center gap-2 text-sm\">\n <Shield size={16} className=\"text-primary\" />\n {tr('integrations.addConnection.authentication.title', 'Authentication')}\n {authMethods.length <= 1 && (\n <span className=\"text-text-secondary font-normal\">\n &middot;{' '}\n {selectedAuthMethod?.displayName ??\n getAuthTypeLabel(selectedProvider.authType)}\n </span>\n )}\n </h3>\n <AuthMethodSelector\n methods={authMethods}\n // Raw key, not the resolved method: the selector needs\n // to see null vs stale itself, or its placeholder can\n // never render.\n selectedKey={selectedAuthMethodKey}\n onSelect={setSelectedAuthMethodKey}\n disabled={isAuthenticating}\n idPrefix={fieldId('auth-method')}\n compact\n />\n </div>\n\n {/* What the chosen method means, kept beside the fields\n it governs. */}\n <div className=\"space-y-2\">\n <AuthMethodNotice method={selectedAuthMethod} />\n </div>\n\n {authFlow === 'oauth2' && (\n <>\n {/* An OAuth method may still declare fields — a tenant\n subdomain, a base URL, bring-your-own-app settings.\n Rendering them only for the `fields` flow made such\n methods impossible to use: the inputs never\n appeared and nothing was ever collected. */}\n {activeSchema && (\n <SchemaForm\n schema={activeSchema}\n values={fieldValues}\n onChange={setFieldValues}\n disabled={isAuthenticating}\n idPrefix={fieldId('oauth-cfg')}\n />\n )}\n <div className=\"flex items-center gap-2 px-3 py-2 rounded-md bg-status-info-bg-subtle border border-border-default\">\n <ExternalLink\n size={14}\n className=\"text-status-info-text flex-shrink-0\"\n />\n <span className=\"text-xs text-status-info-text\">\n {tr(\n 'integrations.addConnection.authentication.oauthPopupInfo',\n 'A popup window will open for {{provider}} sign-in',\n { provider: selectedProvider.name }\n )}\n </span>\n </div>\n </>\n )}\n\n {authFlow === 'minted' && (\n <div className=\"flex items-center gap-2 px-3 py-2 rounded-md bg-status-info-bg-subtle border border-border-default\">\n <Shield size={14} className=\"text-status-info-text flex-shrink-0\" />\n <span className=\"text-xs text-status-info-text\">\n {tr(\n 'integrations.addConnection.authentication.serviceAccount.description',\n 'No credentials to enter — access is granted on your behalf and tokens are issued per use.',\n { provider: selectedProvider.name }\n )}\n </span>\n </div>\n )}\n\n {authFlow === 'fields' &&\n (activeSchema ? (\n <>\n <p className=\"text-xs text-text-secondary\">\n {tr(\n 'integrations.addConnection.authentication.secretsEncrypted',\n 'Secret values are stored encrypted and never shown again.'\n )}\n </p>\n <SchemaForm\n schema={activeSchema}\n values={fieldValues}\n onChange={setFieldValues}\n disabled={isAuthenticating}\n idPrefix={fieldId('cred')}\n />\n </>\n ) : (\n <div className=\"flex items-center gap-2 px-3 py-2 rounded-md bg-status-error-bg-subtle border border-border-default\">\n <AlertCircle\n size={16}\n className=\"text-status-error-text flex-shrink-0\"\n />\n <span className=\"text-sm text-status-error-text\">\n {tr(\n 'integrations.addConnection.authentication.noForm',\n 'This authentication method does not declare a configuration form.'\n )}\n </span>\n </div>\n ))}\n </div>\n </div>\n )}\n\n {/* Details Tab */}\n {activeTab === 'details' && (\n <div className=\"space-y-4\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {tr('integrations.addConnection.tabs.details', 'Details')}\n </h3>\n <div className=\"space-y-3\">\n <div className=\"flex items-center gap-3 p-3 rounded-md border border-border-subtle\">\n <ProviderIcon provider={selectedProvider} size={40} />\n <div>\n <p className=\"text-sm font-medium text-text-primary\">\n {selectedProvider.name}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {getAuthTypeLabel(selectedProvider.authType)} &middot;{' '}\n {getCategoryLabel(selectedProvider.category)}\n </p>\n </div>\n </div>\n {selectedProvider.description && (\n <div>\n <div className=\"text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr('integrations.addConnection.fields.description', 'Description')}\n </div>\n <p className=\"text-sm text-text-primary mt-1\">\n {selectedProvider.description}\n </p>\n </div>\n )}\n {selectedProvider.website && (\n <div>\n <div className=\"text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr('integrations.providerDetail.sections.website', 'Website')}\n </div>\n <a\n href={selectedProvider.website}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"block text-sm text-primary hover:underline mt-1\"\n >\n {selectedProvider.website}\n </a>\n </div>\n )}\n {selectedProvider.docsUrl && (\n <div>\n <div className=\"text-xs font-medium text-text-secondary uppercase tracking-wider\">\n {tr(\n 'integrations.providerDetail.sections.documentation',\n 'Documentation'\n )}\n </div>\n <a\n href={selectedProvider.docsUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"block text-sm text-primary hover:underline mt-1\"\n >\n {selectedProvider.docsUrl}\n </a>\n </div>\n )}\n </div>\n </div>\n )}\n </div>\n </>\n )}\n </div>\n </div>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqFA,IAAM,KA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ourceRoot":"","sources":["../../../src/integrations/components/AuthMethodSelector.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD,UAAU,uBAAuB;IAC/B,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAkBD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC;IAAE,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;CAAE,CAgBzE,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAiE1D,CAAC"}
1
+ {"version":3,"file":"AuthMethodSelector.d.ts","sourceRoot":"","sources":["../../../src/integrations/components/AuthMethodSelector.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD,UAAU,uBAAuB;IAC/B,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAkBD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC;IAAE,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;CAAE,CAmBzE,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAwE1D,CAAC"}
@@ -1,58 +1,66 @@
1
- import { AlertCircle as e } from "lucide-react";
2
- import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
1
+ import { useTr as e } from "../hooks/useTr.js";
2
+ import { AlertCircle as t } from "lucide-react";
3
+ import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
3
4
  //#region src/integrations/components/AuthMethodSelector.tsx
4
- function i(e, t) {
5
+ function a(e, t) {
5
6
  return e.find((e) => e.key === t) ?? null ?? (t ? null : e[0] ?? null);
6
7
  }
7
- var a = ({ method: i }) => i ? /* @__PURE__ */ r(t, { children: [i.description && /* @__PURE__ */ n("p", {
8
- className: "text-xs text-text-secondary",
9
- children: i.description
10
- }), !i.isConfigured && /* @__PURE__ */ r("div", {
11
- className: "flex items-start gap-2 px-3 py-2 rounded-md bg-status-warning-bg-subtle border border-border-default",
12
- children: [/* @__PURE__ */ n(e, {
13
- size: 14,
14
- className: "text-status-warning-text flex-shrink-0 mt-0.5"
15
- }), /* @__PURE__ */ n("span", {
16
- className: "text-xs text-status-warning-text",
17
- children: "This method has no credentials configured in this environment. Ask an administrator to add them, or pick another method."
18
- })]
19
- })] }) : null, o = ({ methods: e, selectedKey: t, onSelect: o, disabled: s, idPrefix: c = "auth-method", compact: l = !1 }) => {
20
- let u = e.filter((e) => e.isEnabled);
21
- if (u.length <= 1) return null;
22
- let d = i(u, t), f = /* @__PURE__ */ r("select", {
23
- id: `${c}-auth-method`,
24
- "aria-label": "Authentication Method",
25
- value: d ? d.key : "",
26
- onChange: (e) => o(e.target.value),
27
- disabled: s,
28
- className: l ? "max-w-[15rem] truncate rounded-md border border-border-subtle bg-bg-surface px-2.5 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50" : "w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50",
29
- children: [!d && /* @__PURE__ */ n("option", {
8
+ var o = ({ method: a }) => {
9
+ let o = e();
10
+ return a ? /* @__PURE__ */ i(n, { children: [a.description && /* @__PURE__ */ r("p", {
11
+ className: "text-xs text-text-secondary",
12
+ children: a.description
13
+ }), !a.isConfigured && /* @__PURE__ */ i("div", {
14
+ className: "flex items-start gap-2 px-3 py-2 rounded-md bg-status-warning-bg-subtle border border-border-default",
15
+ children: [/* @__PURE__ */ r(t, {
16
+ size: 14,
17
+ className: "text-status-warning-text flex-shrink-0 mt-0.5"
18
+ }), /* @__PURE__ */ r("span", {
19
+ className: "text-xs text-status-warning-text",
20
+ children: o("integrations.addConnection.authentication.methodNotConfigured", "This authentication method is not configured in this environment. Ask an administrator to add its credentials, or pick another method.")
21
+ })]
22
+ })] }) : null;
23
+ }, s = ({ methods: t, selectedKey: n, onSelect: s, disabled: c, idPrefix: l = "auth-method", compact: u = !1 }) => {
24
+ let d = e(), f = t.filter((e) => e.isEnabled);
25
+ if (f.length <= 1) return null;
26
+ let p = a(f, n), m = /* @__PURE__ */ i("select", {
27
+ id: `${l}-auth-method`,
28
+ "aria-label": d("integrations.addConnection.fields.authMethod", "Authentication Method"),
29
+ value: p ? p.key : "",
30
+ onChange: (e) => s(e.target.value),
31
+ disabled: c,
32
+ className: u ? "max-w-[15rem] truncate rounded-md border border-border-subtle bg-bg-surface px-2.5 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50" : "w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50",
33
+ children: [!p && /* @__PURE__ */ r("option", {
30
34
  value: "",
31
35
  disabled: !0,
32
- children: "Select an authentication method"
33
- }), u.map((e) => /* @__PURE__ */ r("option", {
36
+ children: d("integrations.addConnection.fields.authMethodPlaceholder", "Select an authentication method")
37
+ }), f.map((e) => /* @__PURE__ */ i("option", {
34
38
  value: e.key,
35
39
  disabled: !e.isConfigured,
36
- children: [e.displayName, e.isConfigured ? "" : " — not configured"]
40
+ children: [e.displayName, e.isConfigured ? "" : ` — ${d("integrations.providerEditor.authMethods.notConfigured", "not configured")}`]
37
41
  }, e.key))]
38
42
  });
39
- return l ? f : /* @__PURE__ */ r("div", { children: [
40
- /* @__PURE__ */ r("label", {
41
- htmlFor: `${c}-auth-method`,
43
+ return u ? m : /* @__PURE__ */ i("div", { children: [
44
+ /* @__PURE__ */ i("label", {
45
+ htmlFor: `${l}-auth-method`,
42
46
  className: "block text-sm font-medium text-text-primary mb-1.5",
43
- children: ["Authentication Method ", /* @__PURE__ */ n("span", {
44
- className: "text-status-error-text",
45
- children: "*"
46
- })]
47
+ children: [
48
+ d("integrations.addConnection.fields.authMethod", "Authentication Method"),
49
+ " ",
50
+ /* @__PURE__ */ r("span", {
51
+ className: "text-status-error-text",
52
+ children: "*"
53
+ })
54
+ ]
47
55
  }),
48
- f,
49
- /* @__PURE__ */ n("div", {
56
+ m,
57
+ /* @__PURE__ */ r("div", {
50
58
  className: "mt-1 space-y-2",
51
- children: /* @__PURE__ */ n(a, { method: d })
59
+ children: /* @__PURE__ */ r(o, { method: p })
52
60
  })
53
61
  ] });
54
62
  };
55
63
  //#endregion
56
- export { a as AuthMethodNotice, o as AuthMethodSelector };
64
+ export { o as AuthMethodNotice, s as AuthMethodSelector };
57
65
 
58
66
  //# sourceMappingURL=AuthMethodSelector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuthMethodSelector.js","names":[],"sources":["../../../src/integrations/components/AuthMethodSelector.tsx"],"sourcesContent":["/**\n * AuthMethodSelector — lets the user choose how to authenticate when a provider\n * offers more than one way (e.g. Gmail via OAuth or via a service account).\n *\n * Renders nothing when there is only one method, so the ~30 single-method\n * providers look exactly as they did before multi-auth existed.\n */\nimport type { FC } from 'react';\nimport { AlertCircle } from 'lucide-react';\nimport type { IntegrationAuthMethod } from '../types';\n\ninterface AuthMethodSelectorProps {\n methods: IntegrationAuthMethod[];\n selectedKey: string | null;\n onSelect: (key: string) => void;\n disabled?: boolean;\n idPrefix?: string;\n /**\n * Bare select, without the label, description or warning.\n *\n * For the dialog header, where space is tight and the explanatory copy lives\n * beside the fields the method governs — see {@link AuthMethodNotice}.\n */\n compact?: boolean;\n}\n\n/**\n * Resolve the method a key refers to.\n *\n * A null key means \"the provider's default\", which is what submission uses, so\n * the dropdown must show that method rather than an empty box. A *stale* key —\n * one matching nothing after switching providers or a method being removed — is\n * the only case that should surface the placeholder.\n */\nfunction resolveSelected(\n selectable: IntegrationAuthMethod[],\n selectedKey: string | null\n): IntegrationAuthMethod | null {\n const matched = selectable.find((method) => method.key === selectedKey) ?? null;\n return matched ?? (selectedKey ? null : (selectable[0] ?? null));\n}\n\n/**\n * The chosen method's description, and a warning when this environment has no\n * credentials for it.\n *\n * Split out from the selector so the two can live in different places: the\n * control in the dialog header, its consequences next to the fields.\n */\nexport const AuthMethodNotice: FC<{ method: IntegrationAuthMethod | null }> = ({ method }) => {\n if (!method) return null;\n return (\n <>\n {method.description && <p className=\"text-xs text-text-secondary\">{method.description}</p>}\n {!method.isConfigured && (\n <div className=\"flex items-start gap-2 px-3 py-2 rounded-md bg-status-warning-bg-subtle border border-border-default\">\n <AlertCircle size={14} className=\"text-status-warning-text flex-shrink-0 mt-0.5\" />\n <span className=\"text-xs text-status-warning-text\">\n This method has no credentials configured in this environment. Ask an administrator to\n add them, or pick another method.\n </span>\n </div>\n )}\n </>\n );\n};\n\nexport const AuthMethodSelector: FC<AuthMethodSelectorProps> = ({\n methods,\n selectedKey,\n onSelect,\n disabled,\n idPrefix = 'auth-method',\n compact = false,\n}) => {\n const selectable = methods.filter((method) => method.isEnabled);\n if (selectable.length <= 1) return null;\n\n const selected = resolveSelected(selectable, selectedKey);\n\n const select = (\n <select\n id={`${idPrefix}-auth-method`}\n aria-label=\"Authentication Method\"\n value={selected ? selected.key : ''}\n onChange={(event) => onSelect(event.target.value)}\n disabled={disabled}\n className={\n compact\n ? 'max-w-[15rem] truncate rounded-md border border-border-subtle bg-bg-surface px-2.5 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50'\n : 'w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50'\n }\n >\n {/* Rendered whenever nothing matches — a null key, or a stale one after\n switching providers or a method being removed. Without it the\n browser shows the first method as selected while state says\n otherwise, and picking that method fires no change event. */}\n {!selected && (\n <option value=\"\" disabled>\n Select an authentication method\n </option>\n )}\n {selectable.map((method) => (\n <option key={method.key} value={method.key} disabled={!method.isConfigured}>\n {method.displayName}\n {/* Unconfigured methods stay listed rather than disappearing — a\n documented option vanishing reads as a bug, whereas a labelled\n one tells the user exactly what to ask an admin for — but they\n are not selectable, so the dialog cannot create a connection\n that is guaranteed to fail at authentication. */}\n {method.isConfigured ? '' : ' — not configured'}\n </option>\n ))}\n </select>\n );\n\n if (compact) return select;\n\n return (\n <div>\n <label\n htmlFor={`${idPrefix}-auth-method`}\n className=\"block text-sm font-medium text-text-primary mb-1.5\"\n >\n Authentication Method <span className=\"text-status-error-text\">*</span>\n </label>\n {select}\n <div className=\"mt-1 space-y-2\">\n <AuthMethodNotice method={selected} />\n </div>\n </div>\n );\n};\n"],"mappings":";;;AAkCA,SAAS,EACP,GACA,GAC8B;AAE9B,QADgB,EAAW,MAAM,MAAW,EAAO,QAAQ,EAAY,IAAI,SACxD,IAAc,OAAQ,EAAW,MAAM;;AAU5D,IAAa,KAAkE,EAAE,gBAC1E,IAEH,kBAAA,GAAA,EAAA,UAAA,CACG,EAAO,eAAe,kBAAC,KAAD;CAAG,WAAU;WAA+B,EAAO;CAAgB,CAAA,EACzF,CAAC,EAAO,gBACP,kBAAC,OAAD;CAAK,WAAU;WAAf,CACE,kBAAC,GAAD;EAAa,MAAM;EAAI,WAAU;EAAkD,CAAA,EACnF,kBAAC,QAAD;EAAM,WAAU;YAAmC;EAG5C,CAAA,CACH;GAEP,EAAA,CAAA,GAbe,MAiBT,KAAmD,EAC9D,YACA,gBACA,aACA,aACA,cAAW,eACX,aAAU,SACN;CACJ,IAAM,IAAa,EAAQ,QAAQ,MAAW,EAAO,UAAU;AAC/D,KAAI,EAAW,UAAU,EAAG,QAAO;CAEnC,IAAM,IAAW,EAAgB,GAAY,EAAY,EAEnD,IACJ,kBAAC,UAAD;EACE,IAAI,GAAG,EAAS;EAChB,cAAW;EACX,OAAO,IAAW,EAAS,MAAM;EACjC,WAAW,MAAU,EAAS,EAAM,OAAO,MAAM;EACvC;EACV,WACE,IACI,qMACA;YATR,CAgBG,CAAC,KACA,kBAAC,UAAD;GAAQ,OAAM;GAAG,UAAA;aAAS;GAEjB,CAAA,EAEV,EAAW,KAAK,MACf,kBAAC,UAAD;GAAyB,OAAO,EAAO;GAAK,UAAU,CAAC,EAAO;aAA9D,CACG,EAAO,aAMP,EAAO,eAAe,KAAK,oBACrB;KARI,EAAO,IAQX,CACT,CACK;;AAKX,QAFI,IAAgB,IAGlB,kBAAC,OAAD,EAAA,UAAA;EACE,kBAAC,SAAD;GACE,SAAS,GAAG,EAAS;GACrB,WAAU;aAFZ,CAGC,0BACuB,kBAAC,QAAD;IAAM,WAAU;cAAyB;IAAQ,CAAA,CACjE;;EACP;EACD,kBAAC,OAAD;GAAK,WAAU;aACb,kBAAC,GAAD,EAAkB,QAAQ,GAAY,CAAA;GAClC,CAAA;EACF,EAAA,CAAA"}
1
+ {"version":3,"file":"AuthMethodSelector.js","names":[],"sources":["../../../src/integrations/components/AuthMethodSelector.tsx"],"sourcesContent":["/**\n * AuthMethodSelector — lets the user choose how to authenticate when a provider\n * offers more than one way (e.g. Gmail via OAuth or via a service account).\n *\n * Renders nothing when there is only one method, so the ~30 single-method\n * providers look exactly as they did before multi-auth existed.\n */\nimport type { FC } from 'react';\nimport { AlertCircle } from 'lucide-react';\nimport { useTr } from '../hooks/useTr';\nimport type { IntegrationAuthMethod } from '../types';\n\ninterface AuthMethodSelectorProps {\n methods: IntegrationAuthMethod[];\n selectedKey: string | null;\n onSelect: (key: string) => void;\n disabled?: boolean;\n idPrefix?: string;\n /**\n * Bare select, without the label, description or warning.\n *\n * For the dialog header, where space is tight and the explanatory copy lives\n * beside the fields the method governs — see {@link AuthMethodNotice}.\n */\n compact?: boolean;\n}\n\n/**\n * Resolve the method a key refers to.\n *\n * A null key means \"the provider's default\", which is what submission uses, so\n * the dropdown must show that method rather than an empty box. A *stale* key —\n * one matching nothing after switching providers or a method being removed — is\n * the only case that should surface the placeholder.\n */\nfunction resolveSelected(\n selectable: IntegrationAuthMethod[],\n selectedKey: string | null\n): IntegrationAuthMethod | null {\n const matched = selectable.find((method) => method.key === selectedKey) ?? null;\n return matched ?? (selectedKey ? null : (selectable[0] ?? null));\n}\n\n/**\n * The chosen method's description, and a warning when this environment has no\n * credentials for it.\n *\n * Split out from the selector so the two can live in different places: the\n * control in the dialog header, its consequences next to the fields.\n */\nexport const AuthMethodNotice: FC<{ method: IntegrationAuthMethod | null }> = ({ method }) => {\n const tr = useTr();\n if (!method) return null;\n return (\n <>\n {method.description && <p className=\"text-xs text-text-secondary\">{method.description}</p>}\n {!method.isConfigured && (\n <div className=\"flex items-start gap-2 px-3 py-2 rounded-md bg-status-warning-bg-subtle border border-border-default\">\n <AlertCircle size={14} className=\"text-status-warning-text flex-shrink-0 mt-0.5\" />\n <span className=\"text-xs text-status-warning-text\">\n {tr(\n 'integrations.addConnection.authentication.methodNotConfigured',\n 'This authentication method is not configured in this environment. Ask an administrator to add its credentials, or pick another method.'\n )}\n </span>\n </div>\n )}\n </>\n );\n};\n\nexport const AuthMethodSelector: FC<AuthMethodSelectorProps> = ({\n methods,\n selectedKey,\n onSelect,\n disabled,\n idPrefix = 'auth-method',\n compact = false,\n}) => {\n const tr = useTr();\n const selectable = methods.filter((method) => method.isEnabled);\n if (selectable.length <= 1) return null;\n\n const selected = resolveSelected(selectable, selectedKey);\n\n const select = (\n <select\n id={`${idPrefix}-auth-method`}\n aria-label={tr('integrations.addConnection.fields.authMethod', 'Authentication Method')}\n value={selected ? selected.key : ''}\n onChange={(event) => onSelect(event.target.value)}\n disabled={disabled}\n className={\n compact\n ? 'max-w-[15rem] truncate rounded-md border border-border-subtle bg-bg-surface px-2.5 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50'\n : 'w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50'\n }\n >\n {/* Rendered whenever nothing matches — a null key, or a stale one after\n switching providers or a method being removed. Without it the\n browser shows the first method as selected while state says\n otherwise, and picking that method fires no change event. */}\n {!selected && (\n <option value=\"\" disabled>\n {tr(\n 'integrations.addConnection.fields.authMethodPlaceholder',\n 'Select an authentication method'\n )}\n </option>\n )}\n {selectable.map((method) => (\n <option key={method.key} value={method.key} disabled={!method.isConfigured}>\n {method.displayName}\n {/* Unconfigured methods stay listed rather than disappearing — a\n documented option vanishing reads as a bug, whereas a labelled\n one tells the user exactly what to ask an admin for — but they\n are not selectable, so the dialog cannot create a connection\n that is guaranteed to fail at authentication. */}\n {method.isConfigured\n ? ''\n : ` — ${tr('integrations.providerEditor.authMethods.notConfigured', 'not configured')}`}\n </option>\n ))}\n </select>\n );\n\n if (compact) return select;\n\n return (\n <div>\n <label\n htmlFor={`${idPrefix}-auth-method`}\n className=\"block text-sm font-medium text-text-primary mb-1.5\"\n >\n {tr('integrations.addConnection.fields.authMethod', 'Authentication Method')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n {select}\n <div className=\"mt-1 space-y-2\">\n <AuthMethodNotice method={selected} />\n </div>\n </div>\n );\n};\n"],"mappings":";;;;AAmCA,SAAS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AG,EAAS;GACrB,WAAU;aAFZ;IAIG,EAAG,gDAAgD,wBAAwB;IAAE;IAC9E,kBAAC,QAAD;KAAM,WAAU;eAAyB;KAAQ,CAAA;IAC3C;;EACP;EACD,kBAAC,OAAD;GAAK,WAAU;aACb,kBAAC,GAAD,EAAkB,QAAQ,GAAY,CAAA;GAClC,CAAA;EACF,EAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"AuthMethodsEditor.d.ts","sourceRoot":"","sources":["../../../src/integrations/components/AuthMethodsEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAKhC,OAAO,KAAK,EAAyB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAsD3E,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CAgSxD,CAAC"}
1
+ {"version":3,"file":"AuthMethodsEditor.d.ts","sourceRoot":"","sources":["../../../src/integrations/components/AuthMethodsEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAMhC,OAAO,KAAK,EAAyB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAsD3E,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CA2XxD,CAAC"}