docIntegrationDetailedView.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import styled from '@emotion/styled';
  2. import DocIntegrationAvatar from 'sentry/components/avatar/docIntegrationAvatar';
  3. import {Button} from 'sentry/components/button';
  4. import type DeprecatedAsyncComponent from 'sentry/components/deprecatedAsyncComponent';
  5. import ExternalLink from 'sentry/components/links/externalLink';
  6. import {IconOpen} from 'sentry/icons';
  7. import {t} from 'sentry/locale';
  8. import {space} from 'sentry/styles/space';
  9. import type {DocIntegration} from 'sentry/types';
  10. import withOrganization from 'sentry/utils/withOrganization';
  11. import AbstractIntegrationDetailedView from './abstractIntegrationDetailedView';
  12. type Tab = AbstractIntegrationDetailedView['state']['tab'];
  13. type State = {
  14. doc: DocIntegration;
  15. };
  16. class DocIntegrationDetailedView extends AbstractIntegrationDetailedView<
  17. AbstractIntegrationDetailedView['props'],
  18. State & AbstractIntegrationDetailedView['state']
  19. > {
  20. tabs: Tab[] = ['overview'];
  21. getEndpoints(): ReturnType<DeprecatedAsyncComponent['getEndpoints']> {
  22. const {
  23. params: {integrationSlug},
  24. } = this.props;
  25. return [['doc', `/doc-integrations/${integrationSlug}/`]];
  26. }
  27. get integrationType() {
  28. return 'document' as const;
  29. }
  30. get integration(): DocIntegration {
  31. return this.state.doc;
  32. }
  33. get description() {
  34. return this.integration.description;
  35. }
  36. get author() {
  37. return this.integration.author;
  38. }
  39. get resourceLinks() {
  40. return this.integration.resources ?? [];
  41. }
  42. get installationStatus() {
  43. return null;
  44. }
  45. get integrationName() {
  46. return this.integration.name;
  47. }
  48. get featureData() {
  49. return this.integration.features ?? [];
  50. }
  51. get requiresAccess() {
  52. return false;
  53. }
  54. componentDidMount() {
  55. super.componentDidMount();
  56. this.trackIntegrationAnalytics('integrations.integration_viewed', {
  57. integration_tab: 'overview',
  58. });
  59. }
  60. trackClick = () => {
  61. this.trackIntegrationAnalytics('integrations.installation_start');
  62. };
  63. renderTopButton() {
  64. return (
  65. <ExternalLink
  66. href={this.integration.url}
  67. onClick={this.trackClick}
  68. data-test-id="learn-more"
  69. >
  70. <LearnMoreButton
  71. size="sm"
  72. priority="primary"
  73. style={{marginLeft: space(1)}}
  74. icon={<StyledIconOpen />}
  75. >
  76. {t('Learn More')}
  77. </LearnMoreButton>
  78. </ExternalLink>
  79. );
  80. }
  81. renderIntegrationIcon() {
  82. return <DocIntegrationAvatar docIntegration={this.integration} size={50} />;
  83. }
  84. // No configurations.
  85. renderConfigurations() {
  86. return null;
  87. }
  88. }
  89. const LearnMoreButton = styled(Button)`
  90. margin-left: ${space(1)};
  91. `;
  92. const StyledIconOpen = styled(IconOpen)`
  93. transition: 0.1s linear color;
  94. margin: 0 ${space(0.5)};
  95. position: relative;
  96. top: 1px;
  97. `;
  98. export default withOrganization(DocIntegrationDetailedView);