Skip to content

Commit

Permalink
Merge pull request #1120 from cdapio/cp/6.7/1109
Browse files Browse the repository at this point in the history
Cherry pick #1109 to 6.7
  • Loading branch information
seanfeld authored Oct 12, 2023
2 parents 0117c5d + 34cc592 commit 79aaa25
Showing 1 changed file with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = () => {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -135,7 +135,10 @@ export default function TransformAddButton({
dense: true,
}}
>
<MenuItem onClick={handleMenuClick}>
<MenuItem onClick={(event) => {
handleMenuClick('rename');
setSubMenuAnchorEl(event.currentTarget);
}}>
Rename <ArrowRight />
</MenuItem>
<MenuItem disabled={!isString} onClick={handleMaskOpen}>
Expand Down Expand Up @@ -163,11 +166,17 @@ export default function TransformAddButton({
<MenuItem disabled={!isString} onClick={() => handleSetMaskLast(4)}>
Show last 4
</MenuItem>
<MenuItem disabled={!isString} onClick={handleMenuClick}>
<MenuItem disabled={!isString} onClick={(event) => {
handleMenuClick('mask');
setSubMenuAnchorEl(event.currentTarget);
}}>
Custom <ArrowRight />
</MenuItem>
{tinkEnabled && (
<MenuItem onClick={handleMenuClick}>
<MenuItem onClick={(event) => {
handleMenuClick('tink');
setSubMenuAnchorEl(event.currentTarget);
}}>
TINK <ArrowRight />
</MenuItem>
)}
Expand All @@ -194,7 +203,7 @@ export default function TransformAddButton({
<TextField
size="small"
id={`${row.name}-outlined-multiline-flexible-directive-text`}
label={directive === 'Custom' ? 'Mask (ie: right * 4)' : directive}
label={directive === 'mask' ? 'Mask (ie: right * 4)' : directive}
variant="outlined"
value={directiveText}
onChange={handleDirectiveChange}
Expand Down Expand Up @@ -228,4 +237,4 @@ export default function TransformAddButton({
</Popover>
</>
);
}
}

0 comments on commit 79aaa25

Please sign in to comment.