otherProjects.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import styled from '@emotion/styled';
  2. import type {Location} from 'history';
  3. import {Button, LinkButton} from 'sentry/components/button';
  4. import Collapsible from 'sentry/components/collapsible';
  5. import IdBadge from 'sentry/components/idBadge';
  6. import {extractSelectionParameters} from 'sentry/components/organizations/pageFilters/utils';
  7. import * as SidebarSection from 'sentry/components/sidebarSection';
  8. import {t, tn} from 'sentry/locale';
  9. import {space} from 'sentry/styles/space';
  10. import type {Organization} from 'sentry/types/organization';
  11. import type {ReleaseProject} from 'sentry/types/release';
  12. type Props = {
  13. location: Location;
  14. organization: Organization;
  15. projects: ReleaseProject[];
  16. version: string;
  17. };
  18. function OtherProjects({projects, location, version, organization}: Props) {
  19. return (
  20. <SidebarSection.Wrap>
  21. <SidebarSection.Title>
  22. {tn(
  23. 'Other Project for This Release',
  24. 'Other Projects for This Release',
  25. projects.length
  26. )}
  27. </SidebarSection.Title>
  28. <SidebarSection.Content>
  29. <Collapsible
  30. expandButton={({onExpand, numberOfHiddenItems}) => (
  31. <Button priority="link" onClick={onExpand}>
  32. {tn(
  33. 'Show %s collapsed project',
  34. 'Show %s collapsed projects',
  35. numberOfHiddenItems
  36. )}
  37. </Button>
  38. )}
  39. >
  40. {projects.map(project => (
  41. <Row key={project.id}>
  42. <IdBadge project={project} avatarSize={16} />
  43. <LinkButton
  44. size="xs"
  45. to={{
  46. pathname: `/organizations/${
  47. organization.slug
  48. }/releases/${encodeURIComponent(version)}/`,
  49. query: {
  50. ...extractSelectionParameters(location.query),
  51. project: project.id,
  52. yAxis: undefined,
  53. },
  54. }}
  55. >
  56. {t('View')}
  57. </LinkButton>
  58. </Row>
  59. ))}
  60. </Collapsible>
  61. </SidebarSection.Content>
  62. </SidebarSection.Wrap>
  63. );
  64. }
  65. const Row = styled('div')`
  66. display: grid;
  67. grid-template-columns: 1fr max-content;
  68. align-items: center;
  69. justify-content: space-between;
  70. margin-bottom: ${space(0.75)};
  71. font-size: ${p => p.theme.fontSizeMedium};
  72. @media (min-width: ${p => p.theme.breakpoints.medium}) and (max-width: ${p =>
  73. p.theme.breakpoints.large}) {
  74. grid-template-columns: 200px max-content;
  75. }
  76. `;
  77. export default OtherProjects;