import {browserHistory, RouteComponentProps} from 'react-router'; import styled from '@emotion/styled'; import AsyncComponent from 'sentry/components/asyncComponent'; import AutoSelectText from 'sentry/components/autoSelectText'; import {Button} from 'sentry/components/button'; import ExternalLink from 'sentry/components/links/externalLink'; import PlatformPicker from 'sentry/components/platformPicker'; import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; import {PlatformKey} from 'sentry/data/platformCategories'; import {t, tct} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import {Organization} from 'sentry/types'; import recreateRoute from 'sentry/utils/recreateRoute'; import {normalizeUrl} from 'sentry/utils/withDomainRequired'; import withOrganization from 'sentry/utils/withOrganization'; import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader'; import TextBlock from 'sentry/views/settings/components/text/textBlock'; import {ProjectKey} from 'sentry/views/settings/project/projectKeys/types'; type Props = RouteComponentProps<{projectId: string}, {}> & { organization: Organization; } & AsyncComponent['props']; type State = { keyList: Array | null; } & AsyncComponent['state']; class ProjectInstallOverview extends AsyncComponent { get isGettingStarted() { return window.location.href.indexOf('getting-started') > 0; } getEndpoints(): ReturnType { const {organization} = this.props; const {projectId} = this.props.params; return [['keyList', `/projects/${organization.slug}/${projectId}/keys/`]]; } redirectToDocs = (platform: PlatformKey | null) => { const {organization} = this.props; const {projectId} = this.props.params; const installUrl = this.isGettingStarted ? `/organizations/${organization.slug}/projects/${projectId}/getting-started/${platform}/` : recreateRoute(`${platform}/`, { ...this.props, stepBack: -1, }); browserHistory.push(normalizeUrl(installUrl)); }; toggleDsn = () => { this.setState(state => ({showDsn: !state.showDsn})); }; render() { const {organization} = this.props; const {projectId} = this.props.params; const {keyList, showDsn} = this.state; const issueStreamLink = `/organizations/${organization.slug}/issues/#welcome`; return (
{t( 'Get started by selecting the platform or language that powers your application.' )} {showDsn ? ( {t('DSN')} {keyList?.[0].dsn.public} ) : (

{tct('Already have things setup? [link:Get your DSN]', { link: (

); } } const DsnValue = styled(p => ( {p.children} ))` overflow: hidden; `; const DsnInfo = styled('div')` margin-bottom: ${space(3)}; `; const DsnContainer = styled('div')` display: grid; grid-template-columns: max-content 1fr; gap: ${space(1.5)} ${space(2)}; align-items: center; margin-bottom: ${space(2)}; `; export default withOrganization(ProjectInstallOverview);