overview.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import {browserHistory, RouteComponentProps} from 'react-router';
  2. import styled from '@emotion/styled';
  3. import AsyncComponent from 'app/components/asyncComponent';
  4. import AutoSelectText from 'app/components/autoSelectText';
  5. import Button from 'app/components/button';
  6. import ExternalLink from 'app/components/links/externalLink';
  7. import PlatformPicker from 'app/components/platformPicker';
  8. import SentryDocumentTitle from 'app/components/sentryDocumentTitle';
  9. import {PlatformKey} from 'app/data/platformCategories';
  10. import {t, tct} from 'app/locale';
  11. import space from 'app/styles/space';
  12. import {Organization} from 'app/types';
  13. import recreateRoute from 'app/utils/recreateRoute';
  14. import withOrganization from 'app/utils/withOrganization';
  15. import SettingsPageHeader from 'app/views/settings/components/settingsPageHeader';
  16. import TextBlock from 'app/views/settings/components/text/textBlock';
  17. import {ProjectKey} from 'app/views/settings/project/projectKeys/types';
  18. type Props = RouteComponentProps<{orgId: string; projectId: string}, {}> & {
  19. organization: Organization;
  20. } & AsyncComponent['props'];
  21. type State = {
  22. keyList: Array<ProjectKey> | null;
  23. } & AsyncComponent['state'];
  24. class ProjectInstallOverview extends AsyncComponent<Props, State> {
  25. get isGettingStarted() {
  26. return window.location.href.indexOf('getting-started') > 0;
  27. }
  28. getEndpoints(): ReturnType<AsyncComponent['getEndpoints']> {
  29. const {orgId, projectId} = this.props.params;
  30. return [['keyList', `/projects/${orgId}/${projectId}/keys/`]];
  31. }
  32. redirectToDocs = (platform: PlatformKey | null) => {
  33. const {orgId, projectId} = this.props.params;
  34. const installUrl = this.isGettingStarted
  35. ? `/organizations/${orgId}/projects/${projectId}/getting-started/${platform}/`
  36. : recreateRoute(`install/${platform}/`, {
  37. ...this.props,
  38. stepBack: -3,
  39. });
  40. browserHistory.push(installUrl);
  41. };
  42. toggleDsn = () => {
  43. this.setState(state => ({showDsn: !state.showDsn}));
  44. };
  45. render() {
  46. const {orgId, projectId} = this.props.params;
  47. const {keyList, showDsn} = this.state;
  48. const issueStreamLink = `/organizations/${orgId}/issues/#welcome`;
  49. return (
  50. <div>
  51. <SentryDocumentTitle title={t('Instrumentation')} projectSlug={projectId} />
  52. <SettingsPageHeader title={t('Configure your application')} />
  53. <TextBlock>
  54. {t(
  55. 'Get started by selecting the platform or language that powers your application.'
  56. )}
  57. </TextBlock>
  58. {showDsn ? (
  59. <DsnInfo>
  60. <DsnContainer>
  61. <strong>{t('DSN')}</strong>
  62. <DsnValue>{keyList?.[0].dsn.public}</DsnValue>
  63. </DsnContainer>
  64. <Button priority="primary" to={issueStreamLink}>
  65. {t('Got it! Take me to the Issue Stream.')}
  66. </Button>
  67. </DsnInfo>
  68. ) : (
  69. <p>
  70. <small>
  71. {tct('Already have things setup? [link:Get your DSN]', {
  72. link: <Button priority="link" onClick={this.toggleDsn} />,
  73. })}
  74. .
  75. </small>
  76. </p>
  77. )}
  78. <PlatformPicker setPlatform={this.redirectToDocs} showOther={false} />
  79. <p>
  80. {tct(
  81. `For a complete list of client integrations, please see
  82. [docLink:our in-depth documentation].`,
  83. {docLink: <ExternalLink href="https://docs.sentry.io" />}
  84. )}
  85. </p>
  86. </div>
  87. );
  88. }
  89. }
  90. const DsnValue = styled(p => (
  91. <code {...p}>
  92. <AutoSelectText>{p.children}</AutoSelectText>
  93. </code>
  94. ))`
  95. overflow: hidden;
  96. `;
  97. const DsnInfo = styled('div')`
  98. margin-bottom: ${space(3)};
  99. `;
  100. const DsnContainer = styled('div')`
  101. display: grid;
  102. grid-template-columns: max-content 1fr;
  103. grid-gap: ${space(1.5)} ${space(2)};
  104. align-items: center;
  105. margin-bottom: ${space(2)};
  106. `;
  107. export default withOrganization(ProjectInstallOverview);