index.tsx 941 B

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