diff --git a/agenta-web/src/components/pages/observability/drawer/TestsetDrawer.tsx b/agenta-web/src/components/pages/observability/drawer/TestsetDrawer.tsx index cbcc74ffcc..43e23c6058 100644 --- a/agenta-web/src/components/pages/observability/drawer/TestsetDrawer.tsx +++ b/agenta-web/src/components/pages/observability/drawer/TestsetDrawer.tsx @@ -27,6 +27,7 @@ import { import {collectKeyPathsFromObject, getStringOrJson} from "@/lib/helpers/utils" import yaml from "js-yaml" import {useUpdateEffect} from "usehooks-ts" +import {ResizableTitle} from "@/components/ServerTable/components" const useStyles = createUseStyles((theme: JSSTheme) => ({ editor: { @@ -79,7 +80,10 @@ const TestsetDrawer = ({onClose, data, ...props}: Props) => { data: [], }) - const isMapColumnExist = mappingData.some((mapping) => Boolean(mapping.column)) + const isMapColumnExist = mappingData.some((mapping) => + mapping.column === "create" ? !!mapping?.newColumn : !!mapping.column, + ) + const isNewTestset = testset.id === "create" // predefind options const customSelectOptions = useMemo( @@ -165,6 +169,13 @@ const TestsetDrawer = ({onClose, data, ...props}: Props) => { } }, [mappingOptions]) + const filteredColumnOptions = useMemo(() => { + const selectedColumns = mappingData + .map((item) => item.column) + .filter((col) => col !== "create") + return tableColumns.filter((column) => !selectedColumns.includes(column)) + }, [mappingData, tableColumns]) + const onMappingOptionChange = ({ pathName, value, @@ -220,7 +231,7 @@ const TestsetDrawer = ({onClose, data, ...props}: Props) => { const newTestsetData = mapAndConvertDataInCsvFormat(traceData) - if (testset.id === "create") { + if (isNewTestset) { if (!testsetName) { message.error("Please add a Test set name before saving it") return @@ -245,273 +256,306 @@ const TestsetDrawer = ({onClose, data, ...props}: Props) => { } } - const Content = () => { - return ( -
- - Spans selected {traceData.length} - - - {/******* testset completed ✅ *******/} -
- Test set -
- + + + +
+ } + mainContent={ +
+ + Spans selected {traceData.length} + + + {/******* testset completed ✅ *******/} +
+ Test set +
+ setTestsetName(e.target.value)} + placeholder="Test set name" + /> + +
+ )}
- )} -
- - - {/******* data-preview completed ✅ *******/} -
- Data preview - -
- - onMappingOptionChange({pathName: "data", value, idx}) - } - options={mappingOptions} + value={dataPreview} + onChange={(value) => setDataPreview(value)} + options={traceData.map((trace, idx) => ({ + value: trace?.key, + label: `Span ${idx + 1}`, + }))} /> - -
- +
+
+ + +
+ + {/******* mapping almost completed ✔️ *******/} +
+ Mapping +
+ {mappingData.map((data, idx) => ( +
+ + value={data.column} + onChange={(value) => onMappingOptionChange({ - pathName: "newColumn", - value: e.target.value, + pathName: "column", + value, idx, }) } - placeholder="Test set name" - /> - ({ + value: column, + lable: column, + })), + ]} /> + {data.column === "create" && ( +
+ + onMappingOptionChange({ + pathName: "newColumn", + value: e.target.value, + idx, + }) + } + placeholder="Test set name" + /> + +
+ )}
- )} -
-
+ ))} - ))} - - - - -
- Preview - {isMapColumnExist ? ( - <> -
- ({ + value: trace?.key, + label: `Span ${idx + 1}`, + }))} + /> + + {!isNewTestset && ( + + setShowLastFiveRows(!showLastFiveRows) + } + checked={showLastFiveRows} + > + Show last 5 test set entries + + )} +
+ +
+ ({ + title: + data.column === "create" + ? data.newColumn + : data.column, + dataIndex: + data.column === "create" + ? data.newColumn + : data.column, + key: idx, + onHeaderCell: () => ({ + style: {minWidth: 160}, + }), + }))} + dataSource={[ + ...preview.data, + ...(showLastFiveRows ? tableRows.slice(-5) : []), + ]} + components={{ + header: { + cell: ResizableTitle, + }, + }} + scroll={{x: true}} + bordered + pagination={false} + /> + + + ) : ( + + Please select test set to view test set preview. + + )} + + } />