import { css } from '@emotion/css'; import React, { FC, useState } from 'react'; import { PanelMenuItem } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; import { Icon, IconName, useTheme } from '@grafana/ui'; interface Props { children?: any; } export const PanelHeaderMenuItem: FC = (props) => { const [ref, setRef] = useState(null); const isSubMenu = props.type === 'submenu'; const isDivider = props.type === 'divider'; const theme = useTheme(); const menuIconClassName = css` margin-right: ${theme.spacing.sm}; a::after { display: none; } `; const shortcutIconClassName = css` position: absolute; top: 7px; right: ${theme.spacing.xs}; color: ${theme.colors.textWeak}; `; return isDivider ? (
  • ) : (
  • {props.iconClassName && } {props.text} {isSubMenu && } {props.shortcut && ( {props.shortcut} )} {props.children}
  • ); }; function getDropdownLocationCssClass(element: HTMLElement | null) { if (!element) { return 'invisible'; } const wrapperPos = element.parentElement!.getBoundingClientRect(); const pos = element.getBoundingClientRect(); if (pos.width === 0) { return 'invisible'; } if (wrapperPos.right + pos.width + 10 > window.innerWidth) { return 'pull-left'; } else { return 'pull-right'; } }