diff --git a/app/cdap/components/Replicator/Create/Content/SelectColumnsWithTransforms/TransformAdd.tsx b/app/cdap/components/Replicator/Create/Content/SelectColumnsWithTransforms/TransformAdd.tsx index 91620bb7f49..78d50ca1d6f 100644 --- a/app/cdap/components/Replicator/Create/Content/SelectColumnsWithTransforms/TransformAdd.tsx +++ b/app/cdap/components/Replicator/Create/Content/SelectColumnsWithTransforms/TransformAdd.tsx @@ -32,7 +32,7 @@ export default function TransformAddButton({ // todo replace this with a useReducer const [anchorEl, setAnchorEl] = useState(null); const [subMenuAnchorEl, setSubMenuAnchorEl] = useState(null); - const [directive, setDirective] = useState(null); + const [directive, setDirective] = useState<'tink' | 'rename' | 'mask' | null>(null); const [directiveText, setDirectiveText] = useState(''); const [maskAnchorEl, setMaskAnchorEl] = useState(null); const maskOpen = !!maskAnchorEl; @@ -46,9 +46,9 @@ export default function TransformAddButton({ setAnchorEl(event.currentTarget); }; - const handleMenuClick = (event) => { - setDirective(event.currentTarget.innerText); - setSubMenuAnchorEl(event.currentTarget); + const handleMenuClick = (directiveType: 'tink' | 'rename' | 'mask') => { + // set the type of directive we're using so add to transforms knows the context + setDirective(directiveType); }; const handleClose = () => { @@ -88,7 +88,7 @@ export default function TransformAddButton({ if (directive === 'tink') { fullDirective = addTinkToTransforms(transformInfo); - } else if (directive === 'Rename') { + } else if (directive === 'rename') { fullDirective = addRenameToTransforms(transformInfo); } else { fullDirective = addMaskToTransforms(transformInfo); @@ -135,7 +135,10 @@ export default function TransformAddButton({ dense: true, }} > - + { + handleMenuClick('rename'); + setSubMenuAnchorEl(event.currentTarget); + }}> Rename @@ -163,11 +166,17 @@ export default function TransformAddButton({ handleSetMaskLast(4)}> Show last 4 - + { + handleMenuClick('mask'); + setSubMenuAnchorEl(event.currentTarget); + }}> Custom {tinkEnabled && ( - + { + handleMenuClick('tink'); + setSubMenuAnchorEl(event.currentTarget); + }}> TINK )} @@ -194,7 +203,7 @@ export default function TransformAddButton({