Wizard: Add password placeholder for edit mode
This uses the `hasPassword` value to render a password placeholder in edit mode. The placeholder will indicate to the user that a password is present, but will not allow to show the password.
This commit is contained in:
parent
01d0eba70e
commit
319880fc0b
4 changed files with 7 additions and 1 deletions
|
|
@ -172,6 +172,7 @@ const UserInfo = () => {
|
|||
ariaLabel="blueprint user password"
|
||||
placeholder="Enter password"
|
||||
onChange={(_e, value) => handlePasswordChange(_e, value)}
|
||||
hasPassword={user.hasPassword}
|
||||
/>
|
||||
<FormGroup label="SSH key" className="pf-v5-u-pb-md">
|
||||
<ValidatedInputAndTextArea
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ type ValidatedPasswordInput = TextInputProps & {
|
|||
placeholder: string;
|
||||
ariaLabel: string;
|
||||
onChange: (event: React.FormEvent<HTMLInputElement>, value: string) => void;
|
||||
hasPassword: boolean;
|
||||
};
|
||||
|
||||
export const PasswordValidatedInput = ({
|
||||
|
|
@ -30,6 +31,7 @@ export const PasswordValidatedInput = ({
|
|||
placeholder,
|
||||
ariaLabel,
|
||||
onChange,
|
||||
hasPassword,
|
||||
}: ValidatedPasswordInput) => {
|
||||
const environments = useAppSelector(selectImageTypes);
|
||||
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
|
||||
|
|
@ -52,7 +54,7 @@ export const PasswordValidatedInput = ({
|
|||
<TextInput
|
||||
isRequired
|
||||
type={isPasswordVisible ? 'text' : 'password'}
|
||||
value={value}
|
||||
value={hasPassword ? '•'.repeat(8) : value}
|
||||
onChange={onChange}
|
||||
aria-label={ariaLabel}
|
||||
placeholder={placeholder}
|
||||
|
|
@ -63,6 +65,7 @@ export const PasswordValidatedInput = ({
|
|||
variant="control"
|
||||
onClick={togglePasswordVisibility}
|
||||
aria-label={isPasswordVisible ? 'Hide password' : 'Show password'}
|
||||
isDisabled={hasPassword}
|
||||
>
|
||||
{isPasswordVisible ? <EyeSlashIcon /> : <EyeIcon />}
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -235,6 +235,7 @@ function commonRequestToState(
|
|||
ssh_key: user.ssh_key || '',
|
||||
groups: user.groups || [],
|
||||
isAdministrator: user.groups?.includes('wheel') || false,
|
||||
hasPassword: user.hasPassword || false,
|
||||
})) || [],
|
||||
compliance:
|
||||
compliancePolicyID !== undefined
|
||||
|
|
|
|||
|
|
@ -1017,6 +1017,7 @@ export const wizardSlice = createSlice({
|
|||
ssh_key: '',
|
||||
groups: [],
|
||||
isAdministrator: false,
|
||||
hasPassword: false,
|
||||
};
|
||||
|
||||
state.users.push(newUser);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue