releaseCardCommits.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import styled from '@emotion/styled';
  2. import AvatarList from 'sentry/components/avatar/avatarList';
  3. import {t, tn} from 'sentry/locale';
  4. import {space} from 'sentry/styles/space';
  5. import {Release} from 'sentry/types';
  6. type Props = {
  7. release: Release;
  8. withHeading: boolean;
  9. };
  10. function ReleaseCardCommits({release, withHeading = true}: Props) {
  11. const commitCount = release.commitCount || 0;
  12. const authorCount = (release.authors && release.authors.length) || 0;
  13. if (commitCount === 0) {
  14. return null;
  15. }
  16. const releaseSummary = [
  17. tn('%s commit', '%s commits', commitCount),
  18. t('by'),
  19. tn('%s author', '%s authors', authorCount),
  20. ].join(' ');
  21. return (
  22. <div className="release-stats">
  23. {withHeading && <ReleaseSummaryHeading>{releaseSummary}</ReleaseSummaryHeading>}
  24. <span style={{display: 'inline-block'}}>
  25. <AvatarList users={release.authors} avatarSize={25} typeAvatars="authors" />
  26. </span>
  27. </div>
  28. );
  29. }
  30. const ReleaseSummaryHeading = styled('div')`
  31. color: ${p => p.theme.gray300};
  32. font-size: ${p => p.theme.fontSizeSmall};
  33. line-height: 1.2;
  34. font-weight: 600;
  35. text-transform: uppercase;
  36. margin-bottom: ${space(0.5)};
  37. `;
  38. export default ReleaseCardCommits;