index.tsx 973 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import * as React from 'react';
  2. import styled from '@emotion/styled';
  3. import ErrorBoundary from 'sentry/components/errorBoundary';
  4. import getBadge from './getBadge';
  5. type Props = React.ComponentProps<typeof getBadge> & Record<string, any>;
  6. /**
  7. * Public interface for all "id badges":
  8. * Organization, project, team, user
  9. */
  10. const IdBadge = (props: Props) => {
  11. const componentBadge = getBadge(props);
  12. if (!componentBadge) {
  13. throw new Error(
  14. 'IdBadge: required property missing (organization, project, team, member, user) or misconfigured'
  15. );
  16. }
  17. return <InlineErrorBoundary mini>{componentBadge}</InlineErrorBoundary>;
  18. };
  19. export default IdBadge;
  20. const InlineErrorBoundary = styled(ErrorBoundary)`
  21. background-color: transparent;
  22. border-color: transparent;
  23. display: flex;
  24. align-items: center;
  25. margin-bottom: 0;
  26. box-shadow: none;
  27. padding: 0; /* Because badges don't have any padding, so this should make the boundary fit well */
  28. `;