import React, { FC } from 'react'; import { Button, IconButton } from '@grafana/ui'; import cn from 'classnames/bind'; import CopyToClipboard from 'react-copy-to-clipboard'; import { formatSourceCodeJsonString } from 'utils/string'; import { openNotification } from 'utils/utils'; import styles from './SourceCode.module.scss'; const cx = cn.bind(styles); interface SourceCodeProps { noMaxHeight?: boolean; showClipboardIconOnly?: boolean; showCopyToClipboard?: boolean; children?: string; rootClassName?: string; preClassName?: string; prettifyJsonString?: boolean; } export const SourceCode: FC = ({ children, noMaxHeight = false, showClipboardIconOnly = false, showCopyToClipboard = true, rootClassName, preClassName, prettifyJsonString, }) => { const showClipboardCopy = showClipboardIconOnly || showCopyToClipboard; return (
{showClipboardCopy && ( { openNotification('Copied!'); }} > {showClipboardIconOnly ? ( ) : ( )} )}
        {prettifyJsonString ? formatSourceCodeJsonString(children) : children}
      
); };