import './Overview.styles.scss'; import MEditor, { EditorProps, Monaco } from '@monaco-editor/react'; import { Color } from '@signozhq/design-tokens'; import { Button, Collapse, Divider, Input, Switch, Tag, Typography, } from 'antd'; import { AddToQueryHOCProps } from 'components/Logs/AddToQueryHOC'; import { OptionsQuery } from 'container/OptionsMenu/types'; import { useIsDarkMode } from 'hooks/useDarkMode'; import { ChevronDown, ChevronRight, Search } from 'lucide-react'; import { ReactNode, useState } from 'react'; import { IField } from 'types/api/logs/fields'; import { ILog } from 'types/api/logs/log'; import { ActionItemProps } from './ActionItem'; import TableView from './TableView'; interface OverviewProps { logData: ILog; isListViewPanel?: boolean; selectedOptions: OptionsQuery; listViewPanelSelectedFields?: IField[] | null; } type Props = OverviewProps & Partial> & Pick; function Overview({ logData, onAddToQuery, onClickActionItem, isListViewPanel = false, selectedOptions, listViewPanelSelectedFields, }: Props): JSX.Element { const [isWrapWord, setIsWrapWord] = useState(true); const [isSearchVisible, setIsSearchVisible] = useState(false); const [isAttributesExpanded, setIsAttributesExpanded] = useState( true, ); const [fieldSearchInput, setFieldSearchInput] = useState(''); const isDarkMode = useIsDarkMode(); const options: EditorProps['options'] = { automaticLayout: true, readOnly: true, height: '40vh', wordWrap: isWrapWord ? 'on' : 'off', minimap: { enabled: false, }, fontWeight: 400, fontFamily: 'Geist Mono', fontSize: 13, lineHeight: '18px', colorDecorators: true, scrollBeyondLastLine: false, scrollbar: { vertical: 'hidden', horizontal: 'hidden', }, }; const handleWrapWord = (checked: boolean): void => { setIsWrapWord(checked); }; function setEditorTheme(monaco: Monaco): void { monaco.editor.defineTheme('my-theme', { base: 'vs-dark', inherit: true, rules: [ { token: 'string.key.json', foreground: Color.BG_VANILLA_400 }, { token: 'string.value.json', foreground: Color.BG_ROBIN_400 }, ], colors: { 'editor.background': Color.BG_INK_400, }, }); } const handleSearchVisible = (): void => { setIsSearchVisible(!isSearchVisible); }; const toogleAttributePanelOpenState = (): void => { setIsAttributesExpanded(!isAttributesExpanded); }; return (
props.isActive ? : } items={[ { key: '1', label: ( body ), children: (
{}} height="20vh" theme={isDarkMode ? 'my-theme' : 'light'} onMount={(_, monaco): void => { document.fonts.ready.then(() => { monaco.editor.remeasureFonts(); }); }} // eslint-disable-next-line react/jsx-no-bind beforeMount={setEditorTheme} />
Wrap text
), // extra: JSON, className: 'collapse-content', }, ]} /> props.isActive ? : } items={[ { key: '1', label: ( // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
Attributes {isAttributesExpanded && (
), children: ( <> {isSearchVisible && ( setFieldSearchInput(e.target.value)} /> )} ), className: 'collapse-content attribute-collapse', }, ]} />
); } Overview.defaultProps = { isListViewPanel: false, listViewPanelSelectedFields: null, }; export default Overview;