import React, { useState } from 'react'; import cn from 'classnames'; import { Icon } from 'UI'; import JumpButton from 'Shared/DevTools/JumpButton'; import { useModal } from 'App/components/Modal'; import ErrorDetailsModal from 'App/components/Dashboard/components/Errors/ErrorDetailsModal'; interface Props { log: any; iconProps: any; jump?: any; renderWithNL?: any; style?: any; recalcHeight?: () => void; } function ConsoleRow(props: Props) { const { log, iconProps, jump, renderWithNL, style, recalcHeight } = props; const { showModal } = useModal(); const [expanded, setExpanded] = useState(false); const lines = log.value.split('\n').filter((l: any) => !!l); const canExpand = lines.length > 1; const clickable = canExpand || !!log.errorId; const onErrorClick = () => { showModal(, { right: true }); }; const toggleExpand = () => { setExpanded(!expanded) setTimeout(() => recalcHeight(), 0) } return (
(!!log.errorId ? onErrorClick() : toggleExpand()) : () => {} } >
{canExpand && ( )} {renderWithNL(lines.pop())}
{canExpand && expanded && lines.map((l: string, i: number) =>
{l}
)}
jump(log.time)} />
); } export default ConsoleRow;