Merge pull request #384 from RohitR311/vis-fix

feat: hide input values in edit robot
This commit is contained in:
Karishma Shukla
2025-01-23 20:25:35 +05:30
committed by GitHub

View File

@@ -320,30 +320,37 @@ export const RobotEditModal = ({ isOpen, handleStart, handleClose, initialSettin
<Typography variant="h6" style={{ marginBottom: '20px'}}> <Typography variant="h6" style={{ marginBottom: '20px'}}>
{headerText} {headerText}
</Typography> </Typography>
{selectors.map((selector) => ( {selectors.map((selector) => {
const isVisible = showPasswords[selector];
return (
<TextField <TextField
key={selector} key={selector}
type={showPasswords[selector] ? 'text' : defaultType} // The type changes based on visibility state
type={isVisible ? 'text' : 'password'}
label={`Credential for ${selector}`} label={`Credential for ${selector}`}
value={credentials[selector]?.value || ''} value={credentials[selector]?.value || ''}
onChange={(e) => handleCredentialChange(selector, e.target.value)} onChange={(e) => handleCredentialChange(selector, e.target.value)}
style={{ marginBottom: '20px' }} style={{ marginBottom: '20px' }}
InputProps={{ InputProps={{
// Only show visibility toggle for password fields // Now showing visibility toggle for all fields
endAdornment: defaultType === 'password' ? ( endAdornment: (
<InputAdornment position="end"> <InputAdornment position="end">
<IconButton <IconButton
aria-label="toggle password visibility" aria-label="toggle credential visibility"
onClick={() => handleClickShowPassword(selector)} onClick={() => handleClickShowPassword(selector)}
edge="end" edge="end"
// Optional: disable if field is empty
disabled={!credentials[selector]?.value}
> >
{showPasswords[selector] ? <Visibility /> : <VisibilityOff />} {isVisible ? <Visibility /> : <VisibilityOff />}
</IconButton> </IconButton>
</InputAdornment> </InputAdornment>
) : undefined, ),
}} }}
/> />
))} );
})}
</> </>
); );
}; };