Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning in Testset about "Unsaved changes" without even adding any changes #548

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions agenta-web/src/components/TestSetTable/TestsetTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,7 @@ const TestsetTable: React.FC<testsetTableProps> = ({mode}) => {

setRowData(separateRowData)
}
setInputValues(
newColDefs.filter((col) => !!col.field).map((col) => col.field),
() => {
setTimeout(() => {
aakrem marked this conversation as resolved.
Show resolved Hide resolved
setLoading(false)
}, 100)
},
)
setInputValues(newColDefs.filter((col) => !!col.field).map((col) => col.field))
}

if (mode === "edit" && testset_id) {
Expand Down Expand Up @@ -317,6 +310,7 @@ const TestsetTable: React.FC<testsetTableProps> = ({mode}) => {
const values = [...inputValues]
values[index] = event.target.value
setScopedInputValues(values)
setLoading(false)
}

const onAddColumn = () => {
Expand All @@ -332,6 +326,7 @@ const TestsetTable: React.FC<testsetTableProps> = ({mode}) => {
setInputValues([...inputValues, newColumnName])
setColumnDefs([...columnDefs, {field: newColumnName}, ADD_BUTTON_COL])
setRowData(updatedRowData)
setLoading(false)
}

useEffect(() => {
Expand Down Expand Up @@ -422,6 +417,7 @@ const TestsetTable: React.FC<testsetTableProps> = ({mode}) => {
}
})
setRowData([...rowData, newRow])
setLoading(false)
}

const onSaveData = async () => {
Expand Down Expand Up @@ -456,13 +452,15 @@ const TestsetTable: React.FC<testsetTableProps> = ({mode}) => {

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setTestsetName(e.target.value)
setLoading(false)
}

const onDeleteRow = () => {
const selectedNodes = gridRef.current.getSelectedNodes()
const selectedData = selectedNodes.map((node: GenericObject) => node.data)
const newrowData = rowData.filter((row) => !selectedData.includes(row))
setRowData(newrowData)
setLoading(false)
}

const onDeleteColumn = (indexToDelete: number) => {
Expand All @@ -484,6 +482,7 @@ const TestsetTable: React.FC<testsetTableProps> = ({mode}) => {
setInputValues(newInputValues)
setColumnDefs(newColumnDefs)
setRowData(newRowData)
setLoading(false)
if (gridRef.current) {
gridRef.current.setColumnDefs(newColumnDefs)
}
Expand All @@ -494,6 +493,7 @@ const TestsetTable: React.FC<testsetTableProps> = ({mode}) => {
params.data[params.colDef.field] = ""
}
setUnSavedChanges(true)
setLoading(false)
}

const {appTheme} = useAppTheme()
Expand Down