index.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import {PureComponent} from 'react';
  2. import styled from '@emotion/styled';
  3. import {openModal} from 'sentry/actionCreators/modal';
  4. import Link from 'sentry/components/links/link';
  5. import {SentryAppPublishRequestModal} from 'sentry/components/modals/sentryAppPublishRequestModal/sentryAppPublishRequestModal';
  6. import PanelItem from 'sentry/components/panels/panelItem';
  7. import SentryAppIcon from 'sentry/components/sentryAppIcon';
  8. import {space} from 'sentry/styles/space';
  9. import type {SentryApp} from 'sentry/types/integrations';
  10. import type {Organization} from 'sentry/types/organization';
  11. import SentryApplicationRowButtons from './sentryApplicationRowButtons';
  12. type Props = {
  13. app: SentryApp;
  14. onPublishSubmission: () => void;
  15. onRemoveApp: (app: SentryApp) => void;
  16. organization: Organization;
  17. };
  18. export default class SentryApplicationRow extends PureComponent<Props> {
  19. get isInternal() {
  20. return this.props.app.status === 'internal';
  21. }
  22. hideStatus() {
  23. // no publishing for internal apps so hide the status on the developer settings page
  24. return this.isInternal;
  25. }
  26. renderStatus() {
  27. const {app} = this.props;
  28. if (this.hideStatus()) {
  29. return null;
  30. }
  31. return <PublishStatus status={app.status} />;
  32. }
  33. handlePublish = () => {
  34. const {app, onPublishSubmission} = this.props;
  35. openModal(deps => (
  36. <SentryAppPublishRequestModal
  37. organization={this.props.organization}
  38. app={app}
  39. onPublishSubmission={onPublishSubmission}
  40. {...deps}
  41. />
  42. ));
  43. };
  44. render() {
  45. const {app, organization, onRemoveApp} = this.props;
  46. return (
  47. <SentryAppItem data-test-id={app.slug}>
  48. <StyledFlex>
  49. <SentryAppIcon sentryApp={app} size={36} />
  50. <SentryAppBox>
  51. <SentryAppName hideStatus={this.hideStatus()}>
  52. <Link to={`/settings/${organization.slug}/developer-settings/${app.slug}/`}>
  53. {app.name}
  54. </Link>
  55. </SentryAppName>
  56. <SentryAppDetails>{this.renderStatus()}</SentryAppDetails>
  57. </SentryAppBox>
  58. <Box>
  59. <SentryApplicationRowButtons
  60. organization={organization}
  61. app={app}
  62. onClickRemove={onRemoveApp}
  63. onClickPublish={this.handlePublish}
  64. />
  65. </Box>
  66. </StyledFlex>
  67. </SentryAppItem>
  68. );
  69. }
  70. }
  71. const Flex = styled('div')`
  72. display: flex;
  73. `;
  74. const Box = styled('div')``;
  75. const SentryAppItem = styled(PanelItem)`
  76. flex-direction: column;
  77. padding: 5px;
  78. `;
  79. const StyledFlex = styled(Flex)`
  80. justify-content: center;
  81. padding: 10px;
  82. `;
  83. const SentryAppBox = styled('div')`
  84. padding-left: 15px;
  85. padding-right: 15px;
  86. flex: 1;
  87. `;
  88. const SentryAppDetails = styled(Flex)`
  89. align-items: center;
  90. margin-top: 6px;
  91. font-size: 0.8em;
  92. `;
  93. const SentryAppName = styled('div')<{hideStatus: boolean}>`
  94. margin-top: ${p => (p.hideStatus ? '10px' : '0px')};
  95. `;
  96. const CenterFlex = styled(Flex)`
  97. align-items: center;
  98. `;
  99. type PublishStatusProps = {status: SentryApp['status']; theme?: any};
  100. const PublishStatus = styled(({status, ...props}: PublishStatusProps) => (
  101. <CenterFlex>
  102. <div {...props}>{status}</div>
  103. </CenterFlex>
  104. ))`
  105. color: ${(props: PublishStatusProps) =>
  106. props.status === 'published' ? props.theme.success : props.theme.gray300};
  107. font-weight: light;
  108. margin-right: ${space(0.75)};
  109. `;