index.tsx 3.1 KB

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