All files / src/form/cells StacktraceCell.tsx

12.5% Statements 1/8
0% Branches 0/4
0% Functions 0/4
12.5% Lines 1/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62                                66x                                                                                          
import { CellComponentDisplayPage } from '@props/RecordProps';
import { Drawer, Tag } from 'antd';
import React, { ReactElement, Suspense, useState } from 'react';
import { BugOutlined } from '@ant-design/icons';
import { emptyMethod } from '@utils/Constants';
import CodeEditor from '../fields/CodeEditor';
import { useTranslation } from 'react-i18next';
import { stopPropagationAndPreventDefault } from '@utils/ObjectUtils';
import { isBlank } from '@utils/StringUtils';
 
export interface StacktraceCellProps {
  zIndex: number;
  value?: string;
  page?: CellComponentDisplayPage;
}
 
const StacktraceCell = (props: StacktraceCellProps): ReactElement => {
  const { zIndex, value } = props;
  const [visible, setVisible] = useState<boolean>(false);
  const { t } = useTranslation();
  return (isBlank(value))? (<></>) : (
    <>
      <Tag
        onClick={() => setVisible(true)}
        icon={<BugOutlined style={{color: "red"}}/>}
        style={{cursor: "pointer", borderRadius: "4px"}}
      >
        {t('Exception')}
      </Tag>
      <Drawer
        title={undefined}
        width={1200}
        rootStyle={{ zIndex: zIndex + 2}}
        rootClassName="action-button-popover-container stacktrace-drawer"
        open={visible}
        closeIcon={undefined}
        headerStyle={{ display: "none" }}
        onClose={() => setVisible(false)}
      >
        <pre
          className="line-numbers code-cell"
          onClick={(event: React.MouseEvent<unknown>) => stopPropagationAndPreventDefault(event)}
        >
          <Suspense fallback={<div />}>
            <CodeEditor
              value={value ?? ""}
              onChange={emptyMethod}
              name={"code"}
              updatable={false}
              width="100%"
              mode={"json"}
              zIndex={zIndex}
            />
          </Suspense>
        </pre>
      </Drawer>
    </>
  );
};
 
export default StacktraceCell;