From 02a150d135d962bf84b5aea60a913240ad955c64 Mon Sep 17 00:00:00 2001 From: Rohit Date: Wed, 30 Apr 2025 21:02:38 +0530 Subject: [PATCH] feat: paginate capture screenshots --- src/components/run/RunContent.tsx | 103 +++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 3 deletions(-) diff --git a/src/components/run/RunContent.tsx b/src/components/run/RunContent.tsx index c3166720..f0074adb 100644 --- a/src/components/run/RunContent.tsx +++ b/src/components/run/RunContent.tsx @@ -57,6 +57,9 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe const [listColumns, setListColumns] = useState([]); const [currentListIndex, setCurrentListIndex] = useState(0); + const [screenshotKeys, setScreenshotKeys] = useState([]); + const [currentScreenshotIndex, setCurrentScreenshotIndex] = useState(0); + const [expandedView, setExpandedView] = useState(null); const [legacyData, setLegacyData] = useState([]); @@ -90,6 +93,13 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe } }, [row.serializableOutput]); + useEffect(() => { + if (row.binaryOutput && Object.keys(row.binaryOutput).length > 0) { + setScreenshotKeys(Object.keys(row.binaryOutput)); + setCurrentScreenshotIndex(0); + } + }, [row.binaryOutput]); + const processLegacyData = (legacyOutput: Record) => { let allData: any[] = []; @@ -240,6 +250,14 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe } }; + const navigateScreenshots = (direction: 'next' | 'prev') => { + if (direction === 'next' && currentScreenshotIndex < screenshotKeys.length - 1) { + setCurrentScreenshotIndex(currentScreenshotIndex + 1); + } else if (direction === 'prev' && currentScreenshotIndex > 0) { + setCurrentScreenshotIndex(currentScreenshotIndex - 1); + } + }; + const renderDataTable = ( data: any[], columns: string[], @@ -789,11 +807,90 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe )} - {/* {hasScreenshots && ( + {hasScreenshots && ( <> - {renderPaginatedScreenshots()} + + } + aria-controls="screenshot-content" + id="screenshot-header" + > + + + + {t('run_content.captured_screenshot.title', 'Screenshots')} + + + + + + + + {screenshotKeys.length > 1 && ( + + + + + )} + + + + {screenshotKeys.length > 1 && ( + + )} + + {`Screenshot + + + + - )} */} + )}