diff --git a/studio/frontend/src/features/studio/sections/dataset-preview-dialog-mapping.tsx b/studio/frontend/src/features/studio/sections/dataset-preview-dialog-mapping.tsx index 5f8833b742..d7ba18ff35 100644 --- a/studio/frontend/src/features/studio/sections/dataset-preview-dialog-mapping.tsx +++ b/studio/frontend/src/features/studio/sections/dataset-preview-dialog-mapping.tsx @@ -1,7 +1,7 @@ import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; -import { AlertCircleIcon } from "@hugeicons/core-free-icons"; +import { AlertCircleIcon, CheckmarkCircle02Icon } from "@hugeicons/core-free-icons"; import { HugeiconsIcon } from "@hugeicons/react"; import type { CheckFormatResponse } from "@/features/training/types/datasets"; @@ -40,21 +40,46 @@ export function DatasetMappingCard({ input: string | null; output: string | null; }) { + const tone = mappingOk ? "ok" : "warn"; return ( -
+
-
+
-

Map dataset columns

-

- We couldn't auto-detect the format. Pick the{" "} - {leftLabel.toLowerCase()} column and the {rightLabel.toLowerCase()}{" "} - column. We'll convert it to a supported format automatically. +

+ {mappingOk ? "Mapping ready" : "Map dataset columns"} +

+

+ {mappingOk + ? "Looks good. We'll convert this dataset automatically." + : `We couldn't auto-detect the format. Pick the ${leftLabel.toLowerCase()} column and the ${rightLabel.toLowerCase()} column. We'll convert it to a supported format automatically.`}

{ + if (!manualMapping.input || !manualMapping.output) return; + if (manualMapping.input !== manualMapping.output) return; + setManualMapping({ input: manualMapping.input, output: null }); + }, [manualMapping.input, manualMapping.output, setManualMapping]); + useEffect(() => { if (!open || !datasetName) { setData(null); @@ -153,30 +159,38 @@ export function DatasetPreviewDialog({ {mappingEnabled && (
- {(manualMapping.input == null || manualMapping.input === colName) && ( - { - setManualMapping({ - input: checked ? colName : null, - output: manualMapping.output, - }); - }} - /> - )} - {(manualMapping.output == null || manualMapping.output === colName) && ( - { - setManualMapping({ - input: manualMapping.input, - output: checked ? colName : null, - }); - }} - /> - )} + {(manualMapping.output == null || manualMapping.output !== colName) && + (manualMapping.input == null || manualMapping.input === colName) && ( + { + setManualMapping({ + input: checked ? colName : null, + output: + checked && manualMapping.output === colName + ? null + : manualMapping.output, + }); + }} + /> + )} + {(manualMapping.input == null || manualMapping.input !== colName) && + (manualMapping.output == null || manualMapping.output === colName) && ( + { + setManualMapping({ + input: + checked && manualMapping.input === colName + ? null + : manualMapping.input, + output: checked ? colName : null, + }); + }} + /> + )}
)}