diff --git a/ell-studio/src/components/HierarchicalTable.js b/ell-studio/src/components/HierarchicalTable.js index 72bdf785..b66cbeb1 100644 --- a/ell-studio/src/components/HierarchicalTable.js +++ b/ell-studio/src/components/HierarchicalTable.js @@ -10,6 +10,7 @@ const TableRow = ({ item, schema, level = 0, onRowClick, columnWidths, updateWid const isExpanded = expandedRows[item.id]; const isSelected = isItemSelected(item); const [isNew, setIsNew] = useState(true); + const customRowClassName = rowClassName ? rowClassName(item) : ''; @@ -43,9 +44,9 @@ const TableRow = ({ item, schema, level = 0, onRowClick, columnWidths, updateWid { e.stopPropagation(); toggleRow(item.id); }}> {isExpanded ? : } - ) : ( + ) : ( - + )} @@ -189,7 +190,7 @@ const PaginationControls = ({ currentPage, totalPages, onPageChange, pageSize, t ); }; -const HierarchicalTable = ({ schema, data, onRowClick, onSelectionChange, initialSortConfig, rowClassName, currentPage, onPageChange, pageSize, totalItems, omitColumns }) => { +const HierarchicalTable = ({ schema, data, onRowClick, onSelectionChange, initialSortConfig, rowClassName, currentPage, onPageChange, pageSize, totalItems, omitColumns, expandAll }) => { const [columnWidths, setColumnWidths] = useState({}); const [isExpanded, setIsExpanded] = useState(false); @@ -230,6 +231,7 @@ const HierarchicalTable = ({ schema, data, onRowClick, onSelectionChange, initia onSelectionChange={onSelectionChange} initialSortConfig={initialSortConfig} setIsExpanded={setIsExpanded} + expandAll={expandAll} >
diff --git a/ell-studio/src/components/HierarchicalTableContext.js b/ell-studio/src/components/HierarchicalTableContext.js index 9e7ee816..ceb59610 100644 --- a/ell-studio/src/components/HierarchicalTableContext.js +++ b/ell-studio/src/components/HierarchicalTableContext.js @@ -4,7 +4,7 @@ const HierarchicalTableContext = createContext(); export const useHierarchicalTable = () => useContext(HierarchicalTableContext); -export const HierarchicalTableProvider = ({ children, data, onSelectionChange, initialSortConfig, setIsExpanded}) => { +export const HierarchicalTableProvider = ({ children, data, onSelectionChange, initialSortConfig, setIsExpanded, expandAll}) => { const [expandedRows, setExpandedRows] = useState({}); const [selectedRows, setSelectedRows] = useState({}); const [sortConfig, setSortConfig] = useState(initialSortConfig || { key: null, direction: 'asc' }); @@ -12,7 +12,19 @@ export const HierarchicalTableProvider = ({ children, data, onSelectionChange, i const allParentRowsCollapsed = data.every(item => !expandedRows[item.id]); setIsExpanded(!allParentRowsCollapsed); }, [expandedRows, setIsExpanded, data]); + // expandall specifies if the initial state of row is expanded. + // if a rows expansion state is not specified, it is set to expanded if expandAll is true. + useEffect(() => { + if (expandAll) { + data.forEach(item => { + if (!(item.id in expandedRows)) { + setExpandedRows(prev => ({ ...prev, [item.id]: true })); + } + }); + } + }, [data, expandAll, expandedRows]); + const toggleRow = useCallback((rowId) => { setExpandedRows(prev => ({ ...prev, diff --git a/ell-studio/src/components/invocations/InvocationsTable.js b/ell-studio/src/components/invocations/InvocationsTable.js index 5cc3d4b8..001ac31a 100644 --- a/ell-studio/src/components/invocations/InvocationsTable.js +++ b/ell-studio/src/components/invocations/InvocationsTable.js @@ -7,7 +7,7 @@ import VersionBadge from '../VersionBadge'; import { useNavigate } from 'react-router-dom'; import { lstrCleanStringify } from '../../utils/lstrCleanStringify'; -const InvocationsTable = ({ invocations, currentPage, setCurrentPage, pageSize, onSelectTrace, currentlySelectedTrace, omitColumns = [] }) => { +const InvocationsTable = ({ invocations, currentPage, setCurrentPage, pageSize, onSelectTrace, currentlySelectedTrace, omitColumns = [], expandAll = false }) => { const navigate = useNavigate(); @@ -74,7 +74,8 @@ const InvocationsTable = ({ invocations, currentPage, setCurrentPage, pageSize, /> ), - sortable: true + sortable: true, + }, { header: 'Version', @@ -127,6 +128,7 @@ const InvocationsTable = ({ invocations, currentPage, setCurrentPage, pageSize, schema={{ columns: defaultColumns }} + expandAll={expandAll} omitColumns={omitColumns} data={traces} onRowClick={onSelectTrace} diff --git a/ell-studio/src/pages/Traces.js b/ell-studio/src/pages/Traces.js index 05ce620a..6571dd54 100644 --- a/ell-studio/src/pages/Traces.js +++ b/ell-studio/src/pages/Traces.js @@ -121,6 +121,7 @@ const Traces = () => {