sidebarMenuItemLink.tsx 939 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import Link from 'sentry/components/links/link';
  3. type Props = {
  4. // SidebarMenuItemLink content (accepted via string or components / DOM nodes)
  5. children: React.ReactNode;
  6. /**
  7. * Use this prop if button is an external link
  8. */
  9. href?: string;
  10. /**
  11. * It is raised when the user clicks on the element - optional
  12. */
  13. onClick?: () => void;
  14. /**
  15. * specifies whether to open the linked document in a new tab
  16. */
  17. openInNewTab?: boolean;
  18. /**
  19. * Inline styles
  20. */
  21. style?: React.CSSProperties;
  22. /**
  23. * Use this prop if button is a react-router link
  24. */
  25. to?: string;
  26. };
  27. const SidebarMenuItemLink = ({to, href, ...props}: Props) => {
  28. if (href) {
  29. return <ExternalLink href={href} {...props} />;
  30. }
  31. if (to) {
  32. return <Link to={to} {...props} />;
  33. }
  34. return <div tabIndex={0} {...props} />;
  35. };
  36. export default SidebarMenuItemLink;