otherProjects.tsx 2.5 KB

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