Skip to content

Commit

Permalink
Merge pull request #1743 from ashrafchowdury/fix/1737-testset-columns…
Browse files Browse the repository at this point in the history
…-name-style

fix: fixed testset columns naming conventions
  • Loading branch information
mmabrouk authored Jun 4, 2024
2 parents 01a8952 + 42c75cc commit 8df17b2
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions agenta-web/src/components/TestSetTable/TestsetTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,14 @@ const TestsetTable: React.FC<testsetTableProps> = ({mode}) => {

useEffect(() => {
async function applyColData(colData: {field: string}[] = []) {
const newColDefs = [CHECKBOX_COL, ...colData, ADD_BUTTON_COL]
const newColDefs = [
CHECKBOX_COL,
...colData.map((col) => ({
...col,
headerName: col.field,
})),
ADD_BUTTON_COL,
]
setColumnDefs(newColDefs)
if (mode === "create") {
const initialRowData = Array(3).fill({})
Expand Down Expand Up @@ -241,7 +248,14 @@ const TestsetTable: React.FC<testsetTableProps> = ({mode}) => {
}
})

const newColumnDefs = [CHECKBOX_COL, ...newDataColumns, ADD_BUTTON_COL]
const newColumnDefs = [
CHECKBOX_COL,
...newDataColumns.map((col) => ({
...col,
headerName: col.field,
})),
ADD_BUTTON_COL,
]

const keyMap = dataColumns.reduce((acc: KeyValuePair, colDef, index) => {
acc[colDef.field] = newDataColumns[index].field
Expand Down Expand Up @@ -285,9 +299,7 @@ const TestsetTable: React.FC<testsetTableProps> = ({mode}) => {
}

if (
inputValues.some(
(input) => input.toLowerCase() === scopedInputValues[index].toLowerCase(),
) ||
inputValues.some((input) => input === scopedInputValues[index]) ||
scopedInputValues[index] == ""
) {
message.error(
Expand Down Expand Up @@ -320,7 +332,11 @@ const TestsetTable: React.FC<testsetTableProps> = ({mode}) => {
newColmnDef.pop()

setInputValues([...inputValues, newColumnName])
setColumnDefs([...columnDefs, {field: newColumnName}, ADD_BUTTON_COL])
setColumnDefs([
...columnDefs,
{field: newColumnName, headerName: newColumnName},
ADD_BUTTON_COL,
])
setRowData(updatedRowData)
setLoading(false)
}
Expand Down

0 comments on commit 8df17b2

Please sign in to comment.