this commit adds ssh_key to users step
This commit is contained in:
parent
6a5871bf14
commit
4af4b56332
6 changed files with 62 additions and 1 deletions
|
|
@ -1,13 +1,17 @@
|
|||
import React from 'react';
|
||||
|
||||
import { FormGroup } from '@patternfly/react-core';
|
||||
import { Button, FormGroup } from '@patternfly/react-core';
|
||||
import { ExternalLinkAltIcon } from '@patternfly/react-icons';
|
||||
|
||||
import { GENERATING_SSH_KEY_PAIRS_URL } from '../../../../../constants';
|
||||
import { useAppDispatch, useAppSelector } from '../../../../../store/hooks';
|
||||
import {
|
||||
selectUserNameByIndex,
|
||||
selectUserPasswordByIndex,
|
||||
selectUserSshKeyByIndex,
|
||||
setUserNameByIndex,
|
||||
setUserPasswordByIndex,
|
||||
setUserSshKeyByIndex,
|
||||
} from '../../../../../store/wizardSlice';
|
||||
import { HookValidatedInput } from '../../../ValidatedTextInput';
|
||||
const UserInfo = () => {
|
||||
|
|
@ -17,6 +21,8 @@ const UserInfo = () => {
|
|||
const userName = useAppSelector(userNameSelector);
|
||||
const userPasswordSelector = selectUserPasswordByIndex(index);
|
||||
const userPassword = useAppSelector(userPasswordSelector);
|
||||
const userSshKeySelector = selectUserSshKeyByIndex(index);
|
||||
const userSshKey = useAppSelector(userSshKeySelector);
|
||||
|
||||
const handleNameChange = (
|
||||
_e: React.FormEvent<HTMLInputElement>,
|
||||
|
|
@ -32,6 +38,13 @@ const UserInfo = () => {
|
|||
dispatch(setUserPasswordByIndex({ index: index, password: value }));
|
||||
};
|
||||
|
||||
const handleSshKeyChange = (
|
||||
_event: React.FormEvent<HTMLInputElement>,
|
||||
value: string
|
||||
) => {
|
||||
dispatch(setUserSshKeyByIndex({ index: index, sshKey: value }));
|
||||
};
|
||||
|
||||
const stepValidation = {
|
||||
errors: {},
|
||||
disabledNext: false,
|
||||
|
|
@ -59,6 +72,28 @@ const UserInfo = () => {
|
|||
fieldName="userPassword"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup isRequired label="SSH key">
|
||||
<HookValidatedInput
|
||||
ariaLabel="public SSH key"
|
||||
value={userSshKey || ''}
|
||||
type={'text'}
|
||||
onChange={(_e, value) => handleSshKeyChange(_e, value)}
|
||||
placeholder="Paste your public SSH key"
|
||||
stepValidation={stepValidation}
|
||||
fieldName="userSshKey"
|
||||
/>
|
||||
<Button
|
||||
component="a"
|
||||
target="_blank"
|
||||
variant="link"
|
||||
icon={<ExternalLinkAltIcon />}
|
||||
iconPosition="right"
|
||||
href={GENERATING_SSH_KEY_PAIRS_URL}
|
||||
className="pf-v5-u-pl-0"
|
||||
>
|
||||
Learn more about SSH keys
|
||||
</Button>
|
||||
</FormGroup>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -583,6 +583,9 @@ const getUsers = (state: RootState): User[] | undefined => {
|
|||
if (user.password !== '') {
|
||||
result.password = user.password;
|
||||
}
|
||||
if (user.ssh_key !== '') {
|
||||
result.ssh_key = user.ssh_key;
|
||||
}
|
||||
return result as User;
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue