Skip to content

Commit

Permalink
Warning in Testset about "Unsaved changes" without even adding any ch…
Browse files Browse the repository at this point in the history
…anges (#548)

* Fix warning when creating test set from UI

* modifies state
  • Loading branch information
bekossy authored Sep 11, 2023
1 parent 57c504e commit d370200
Showing 1 changed file with 8 additions and 8 deletions.
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(() => {
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

0 comments on commit d370200

Please sign in to comment.