suspectReleases.tsx 2.7 KB

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