suspectReleases.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import styled from '@emotion/styled';
  2. import AsyncComponent from 'sentry/components/asyncComponent';
  3. import Placeholder from 'sentry/components/placeholder';
  4. import Version from 'sentry/components/version';
  5. import {t} from 'sentry/locale';
  6. import space from 'sentry/styles/space';
  7. import type {Group, Release} from 'sentry/types';
  8. import AvatarList from '../avatar/avatarList';
  9. import TimeSince from '../timeSince';
  10. import SidebarSection from './sidebarSection';
  11. type Props = AsyncComponent['props'] & {
  12. group: Group;
  13. };
  14. type State = AsyncComponent['state'] & {
  15. suspectReleases: Release[] | null;
  16. };
  17. class SuspectReleases extends AsyncComponent<Props, State> {
  18. getEndpoints(): ReturnType<AsyncComponent['getEndpoints']> {
  19. const {group} = this.props;
  20. return [['suspectReleases', `/issues/${group.id}/suspect-releases/`]];
  21. }
  22. renderLoading() {
  23. return (
  24. <SidebarSection data-test-id="linked-issues" title={t('Linked Issues')}>
  25. <Placeholder height="60px" />
  26. </SidebarSection>
  27. );
  28. }
  29. renderBody() {
  30. if (!this.state.suspectReleases?.length) {
  31. return null;
  32. }
  33. return (
  34. <SidebarSection secondary title={t('Suspect Releases')}>
  35. {this.state.suspectReleases?.map(release => (
  36. <SuspectReleaseWrapper key={release.version}>
  37. <div>
  38. <StyledVersion version={release.version} />
  39. {release.lastDeploy && (
  40. <ReleaseDeployedDate>
  41. {release.lastDeploy.environment
  42. ? t('Deployed to %s ', release.lastDeploy.environment)
  43. : t('Deployed ')}
  44. <TimeSince date={release.lastDeploy.dateFinished} />
  45. </ReleaseDeployedDate>
  46. )}
  47. </div>
  48. <AvatarList
  49. users={release.authors}
  50. avatarSize={25}
  51. tooltipOptions={{container: 'body'} as any}
  52. typeMembers="authors"
  53. />
  54. </SuspectReleaseWrapper>
  55. ))}
  56. </SidebarSection>
  57. );
  58. }
  59. }
  60. const SuspectReleaseWrapper = styled('div')`
  61. display: flex;
  62. gap: ${space(1)};
  63. justify-content: space-between;
  64. align-items: center;
  65. line-height: 1.2;
  66. margin: ${space(1.5)} 0;
  67. `;
  68. const StyledVersion = styled(Version)`
  69. margin-bottom: ${space(0.75)};
  70. `;
  71. const ReleaseDeployedDate = styled('div')`
  72. font-size: ${p => p.theme.fontSizeSmall};
  73. color: ${p => p.theme.subText};
  74. `;
  75. export default SuspectReleases;