import { useEffect, useRef, useState } from "react"; import * as React from "react"; import TableRow from "@mui/material/TableRow"; import TableCell from "@mui/material/TableCell"; import { Box, Collapse, IconButton, Typography } from "@mui/material"; import { DeleteForever, KeyboardArrowDown, KeyboardArrowUp } from "@mui/icons-material"; import { deleteRunFromStorage } from "../../api/storage"; import { columns, Data } from "./RunsTable"; import { RunContent } from "./RunContent"; interface CollapsibleRowProps { row: Data; handleDelete: () => void; isOpen: boolean; currentLog: string; abortRunHandler: () => void; runningRecordingName: string; } export const CollapsibleRow = ({ row, handleDelete, isOpen, currentLog, abortRunHandler,runningRecordingName }: CollapsibleRowProps) => { const [open, setOpen] = useState(isOpen); const logEndRef = useRef(null); const scrollToLogBottom = () => { if (logEndRef.current) { logEndRef.current.scrollIntoView({ behavior: "smooth" }); } } const handleAbort = () => { abortRunHandler(); } useEffect(() => { scrollToLogBottom(); }, [currentLog]) return ( *': { borderBottom: 'unset' } }} hover role="checkbox" tabIndex={-1} key={row.id}> { setOpen(!open); scrollToLogBottom(); }} > {open ? : } {columns.map((column) => { // @ts-ignore const value : any = row[column.id]; if (value !== undefined) { return ( {value} ); } else { switch (column.id) { case 'delete': return ( { deleteRunFromStorage(`${row.name}_${row.runId}`).then((result: boolean) => { if (result) { handleDelete(); } }) }} sx={{'&:hover': { color: '#1976d2', backgroundColor: 'transparent' }}}> ); default: return null; } } })} ); }