import {Fragment, useCallback, useEffect, useState} from 'react'; import styled from '@emotion/styled'; import {motion} from 'framer-motion'; import {openInviteMembersModal} from 'sentry/actionCreators/modal'; import {Alert} from 'sentry/components/alert'; import {Button} from 'sentry/components/button'; import ExternalLink from 'sentry/components/links/externalLink'; import LoadingError from 'sentry/components/loadingError'; import LoadingIndicator from 'sentry/components/loadingIndicator'; import type { BasePlatformOptions, DocsParams, } from 'sentry/components/onboarding/gettingStartedDoc/types'; import {useLoadGettingStarted} from 'sentry/components/onboarding/gettingStartedDoc/utils/useLoadGettingStarted'; import { PlatformOptionsControl, useUrlPlatformOptions, } from 'sentry/components/onboarding/platformOptionsControl'; import {t, tct} from 'sentry/locale'; import ConfigStore from 'sentry/stores/configStore'; import {useLegacyStore} from 'sentry/stores/useLegacyStore'; import {space} from 'sentry/styles/space'; import type {IntegrationProvider} from 'sentry/types/integrations'; import type {PlatformIntegration, Project} from 'sentry/types/project'; import {trackAnalytics} from 'sentry/utils/analytics'; import getDynamicText from 'sentry/utils/getDynamicText'; import useApi from 'sentry/utils/useApi'; import useOrganization from 'sentry/utils/useOrganization'; import SetupIntroduction from 'sentry/views/onboarding/components/setupIntroduction'; import {AddIntegrationButton} from 'sentry/views/settings/organizationIntegrations/addIntegrationButton'; import AddInstallationInstructions from './components/integrations/addInstallationInstructions'; import PostInstallCodeSnippet from './components/integrations/postInstallCodeSnippet'; export enum InstallationMode { AUTO = 'auto', MANUAL = 'manual', } export const platformOptions = { installationMode: { label: t('Installation Mode'), items: [ { label: t('Auto'), value: InstallationMode.AUTO, }, { label: t('Manual'), value: InstallationMode.MANUAL, }, ], defaultValue: InstallationMode.AUTO, }, } satisfies BasePlatformOptions; type Props = { integrationSlug: string; platform: PlatformIntegration; project: Project; }; function IntegrationSetup({project, integrationSlug, platform}: Props) { const [hasError, setHasError] = useState(false); const [installed, setInstalled] = useState(false); const [provider, setProvider] = useState(null); const organization = useOrganization(); const {isSelfHosted, urlPrefix} = useLegacyStore(ConfigStore); const { isLoading, docs: docsConfig, dsn, projectKeyId, refetch, } = useLoadGettingStarted({ orgSlug: organization.slug, projSlug: project.slug, platform, }); const selectedPlatformOptions = useUrlPlatformOptions(docsConfig?.platformOptions); const api = useApi(); const fetchData = useCallback(() => { if (!integrationSlug) { return Promise.resolve(); } const endpoint = `/organizations/${organization.slug}/config/integrations/?provider_key=${integrationSlug}`; return api .requestPromise(endpoint) .then(integrations => { setProvider(integrations.providers[0]); setHasError(false); }) .catch(error => { setHasError(true); throw error; }); }, [integrationSlug, api, organization.slug]); useEffect(() => { fetchData(); }, [fetchData]); const loadingError = ( ); const testOnlyAlert = ( Platform documentation is not rendered in for tests in CI ); const renderIntegrationInstructions = () => { if (!provider) { return null; } return ( {tct( "Don't have have permissions to create a Cloudformation stack? [link:Invite your team instead].", { link: (