integrationItem.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import {Component} from 'react';
  2. import styled from '@emotion/styled';
  3. import space from 'sentry/styles/space';
  4. import {Integration} from 'sentry/types';
  5. import IntegrationIcon from 'sentry/views/organizationIntegrations/integrationIcon';
  6. type DefaultProps = {
  7. compact: boolean;
  8. };
  9. type Props = DefaultProps & {
  10. integration: Integration;
  11. };
  12. export default class IntegrationItem extends Component<Props> {
  13. static defaultProps: DefaultProps = {
  14. compact: false,
  15. };
  16. render() {
  17. const {integration, compact} = this.props;
  18. return (
  19. <Flex>
  20. <div>
  21. <IntegrationIcon size={compact ? 22 : 32} integration={integration} />
  22. </div>
  23. <Labels compact={compact}>
  24. <IntegrationName data-test-id="integration-name">
  25. {integration.name}
  26. </IntegrationName>
  27. <DomainName compact={compact}>{integration.domainName}</DomainName>
  28. </Labels>
  29. </Flex>
  30. );
  31. }
  32. }
  33. const Flex = styled('div')`
  34. display: flex;
  35. align-items: center;
  36. `;
  37. type StyledProps = Pick<Props, 'compact'>;
  38. const Labels = styled('div')<StyledProps>`
  39. box-sizing: border-box;
  40. display: flex;
  41. ${p => (p.compact ? 'align-items: center;' : '')};
  42. flex-direction: ${p => (p.compact ? 'row' : 'column')};
  43. padding-left: ${space(1)};
  44. min-width: 0;
  45. justify-content: center;
  46. `;
  47. const IntegrationName = styled('div')`
  48. font-size: ${p => p.theme.fontSizeMedium};
  49. font-weight: bold;
  50. `;
  51. // Not using the overflowEllipsis style import here
  52. // as it sets width 100% which causes layout issues in the
  53. // integration list.
  54. const DomainName = styled('div')<StyledProps>`
  55. color: ${p => p.theme.subText};
  56. margin-left: ${p => (p.compact ? space(1) : 'inherit')};
  57. margin-top: ${p => (!p.compact ? 0 : 'inherit')};
  58. font-size: ${p => p.theme.fontSizeSmall};
  59. overflow: hidden;
  60. text-overflow: ellipsis;
  61. `;