import React from 'react'; import { Button, FormGroup, Checkbox, Tooltip } from '@patternfly/react-core'; import { ExternalLinkAltIcon, TrashIcon } from '@patternfly/react-icons'; import { GENERATING_SSH_KEY_PAIRS_URL } from '../../../../../constants'; import { useAppDispatch, useAppSelector } from '../../../../../store/hooks'; import { selectUserAdministrator, selectUserNameByIndex, selectUserPasswordByIndex, selectUserSshKeyByIndex, setUserNameByIndex, setUserPasswordByIndex, setUserSshKeyByIndex, setUserAdministratorByIndex, removeUser, } from '../../../../../store/wizardSlice'; import { useUsersValidation } from '../../../utilities/useValidation'; import { HookPasswordValidatedInput, HookValidatedInput, ValidatedInputAndTextArea, } from '../../../ValidatedInput'; const UserInfo = () => { const dispatch = useAppDispatch(); const index = 0; const userNameSelector = selectUserNameByIndex(index); const userName = useAppSelector(userNameSelector); const userPasswordSelector = selectUserPasswordByIndex(index); const userPassword = useAppSelector(userPasswordSelector); const userSshKeySelector = selectUserSshKeyByIndex(index); const userSshKey = useAppSelector(userSshKeySelector); const userIsAdministratorSelector = selectUserAdministrator(index); const userIsAdministrator = useAppSelector(userIsAdministratorSelector); const handleNameChange = ( _e: React.FormEvent, value: string ) => { dispatch(setUserNameByIndex({ index: index, name: value })); }; const handlePasswordChange = ( _event: React.FormEvent, value: string ) => { dispatch(setUserPasswordByIndex({ index: index, password: value })); }; const handleSshKeyChange = ( _event: React.FormEvent, value: string ) => { dispatch(setUserSshKeyByIndex({ index: index, sshKey: value })); }; const stepValidation = useUsersValidation(); const handleCheckboxChange = ( _event: React.FormEvent, value: boolean ) => { dispatch( setUserAdministratorByIndex({ index: index, isAdministrator: value }) ); }; const onRemoveUserClick = () => { dispatch(removeUser(index)); }; return ( <> handleNameChange(_e, value)} stepValidation={stepValidation} fieldName="userName" /> handlePasswordChange(_e, value)} placeholder="Enter password" stepValidation={stepValidation} fieldName="userPassword" /> handleSshKeyChange(_e, value)} placeholder="Paste your public SSH key" stepValidation={stepValidation} fieldName="userSshKey" /> handleCheckboxChange(_e, value)} aria-label="Administrator" id="user Administrator" name="user Administrator" /> ); }; export default UserInfo;