sidebarOrgSummary.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import styled from '@emotion/styled';
  2. import OrganizationAvatar from 'sentry/components/avatar/organizationAvatar';
  3. import {IconWarning} from 'sentry/icons';
  4. import {tn} from 'sentry/locale';
  5. import space from 'sentry/styles/space';
  6. import {OrganizationSummary} from 'sentry/types';
  7. type Props = {
  8. organization: OrganizationSummary;
  9. className?: string;
  10. /**
  11. * Show the project count under the organization name.
  12. */
  13. projectCount?: number;
  14. };
  15. const SidebarOrgSummary = styled(({organization, projectCount, ...props}: Props) => (
  16. <div {...props}>
  17. {organization.status.id === 'pending_deletion' ? (
  18. <PendingDeletionAvatar data-test-id="pending-deletion-icon" />
  19. ) : (
  20. <OrganizationAvatar organization={organization} size={36} />
  21. )}
  22. <div>
  23. <Name pendingDeletion={organization.status.id === 'pending_deletion'}>
  24. {organization.name}
  25. </Name>
  26. {!!projectCount && (
  27. <ProjectCount>{tn('%s project', '%s projects', projectCount)}</ProjectCount>
  28. )}
  29. </div>
  30. </div>
  31. ))`
  32. display: grid;
  33. grid-template-columns: max-content minmax(0, 1fr);
  34. gap: ${space(1)};
  35. align-items: center;
  36. padding: ${space(1)} ${p => p.theme.sidebar.menuSpacing};
  37. `;
  38. const Name = styled('div')<{pendingDeletion: boolean}>`
  39. color: ${p => (p.pendingDeletion ? p.theme.subText : p.theme.textColor)};
  40. font-size: ${p => p.theme.fontSizeLarge};
  41. line-height: 1.1;
  42. font-weight: bold;
  43. ${p => p.theme.overflowEllipsis};
  44. `;
  45. const ProjectCount = styled('div')`
  46. color: ${p => p.theme.subText};
  47. font-size: ${p => p.theme.fontSizeMedium};
  48. line-height: 1;
  49. margin-top: ${space(0.5)};
  50. ${p => p.theme.overflowEllipsis};
  51. `;
  52. const PendingDeletionAvatar = styled('div')`
  53. height: 36px;
  54. width: 36px;
  55. display: flex;
  56. align-items: center;
  57. justify-content: center;
  58. border: 2px dashed ${p => p.theme.gray200};
  59. border-radius: 4px;
  60. `;
  61. PendingDeletionAvatar.defaultProps = {
  62. children: <IconWarning size="sm" color="gray200" />,
  63. };
  64. export default SidebarOrgSummary;