1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import ExternalLink from 'sentry/components/links/externalLink';
- import Link from 'sentry/components/links/link';
- type Props = {
- // SidebarMenuItemLink content (accepted via string or components / DOM nodes)
- children: React.ReactNode;
- /**
- * Use this prop if button is an external link
- */
- href?: string;
- /**
- * It is raised when the user clicks on the element - optional
- */
- onClick?: () => void;
- /**
- * specifies whether to open the linked document in a new tab
- */
- openInNewTab?: boolean;
- /**
- * Inline styles
- */
- style?: React.CSSProperties;
- /**
- * Use this prop if button is a react-router link
- */
- to?: string;
- };
- const SidebarMenuItemLink = ({to, href, ...props}: Props) => {
- if (href) {
- return <ExternalLink href={href} {...props} />;
- }
- if (to) {
- return <Link to={to} {...props} />;
- }
- return <div tabIndex={0} {...props} />;
- };
- export default SidebarMenuItemLink;
|