otherProjects.tsx 2.3 KB

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