index.tsx 3.1 KB

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