import { useState } from 'react'; import { Popup, Icon, Label } from 'UI'; import typeToIcon from './typeToIcon'; import cn from 'classnames'; import styles from './timelineTab.css'; import ImageViewer from '../ImageViewer/ImageViewer'; const formatExecutionTime = ({ milliseconds }) => (milliseconds >= 1000 ? `${ Math.round(milliseconds / 1000) } s` : `${ milliseconds } ms`); const formatStartTime = (time, firstStepTime) => time.diff(firstStepTime).toFormat('mm:ss'); const renderStep = (step, makeGotoLogHandler, startedAt, onThumbClick, index) => (
@ { formatStartTime(step.startedAt, startedAt) }
{ step.title }
{ step.info &&
{step.info}
} { step.input && ( )}
onThumbClick(index)} />
{ formatExecutionTime(step.duration) }
); const TimelineTab = ({ steps, startedAt, makeGotoLogHandler, className, }) => { const [stepIndex, setStepIndex] = useState(null) const onThumbClick = (index) => { setStepIndex(index); } return ( <> { stepIndex != null && ( i.screenshotUrl).toJS()} activeIndex={stepIndex} onClose={() => setStepIndex(null)} /> )}
User Events
Duration
{ steps.map((step, index) => (
{ renderStep(step, makeGotoLogHandler, startedAt, onThumbClick, index) } { step.steps && step.steps.size > 0 &&
{ step.steps.map((subStep, j) => (
{ renderStep(subStep, j, makeGotoLogHandler, startedAt, null, index) }
)) }
}
))}
); } export default TimelineTab;