import { css } from '@emotion/css'; import { memo } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Icon, Tooltip, useStyles2, type PopoverContent } from '@grafana/ui'; import { FuncInstance } from '../gfunc'; import { FunctionEditorControls, FunctionEditorControlsProps } from './FunctionEditorControls'; interface FunctionEditorProps extends FunctionEditorControlsProps { func: FuncInstance; } const getStyles = (theme: GrafanaTheme2) => { return { icon: css({ marginRight: theme.spacing(0.5), }), label: css({ fontWeight: theme.typography.fontWeightMedium, fontSize: theme.typography.bodySmall.fontSize, cursor: 'pointer', display: 'inline-block', }), }; }; const FunctionEditor = ({ onMoveLeft, onMoveRight, func, ...props }: FunctionEditorProps) => { const styles = useStyles2(getStyles); const renderContent: PopoverContent = ({ updatePopperPosition }) => ( { onMoveLeft(func); updatePopperPosition?.(); }} onMoveRight={() => { onMoveRight(func); updatePopperPosition?.(); }} /> ); return ( <> {func.def.unknown && ( } placement="bottom" interactive> )} {func.def.name} ); }; const TooltipContent = memo(() => { return ( This function is not supported. Check your function for typos and{' '} read the docs {' '} to see whether you need to upgrade your data source’s version to make this function available. ); }); TooltipContent.displayName = 'FunctionEditorTooltipContent'; export { FunctionEditor };