This commit Implement refactor of HookValidatedInput for hostname and blueprint name fields, addressing the following bugs: 1) Fixes a bug where the validation symbol persisted after a user deleted the value in the hostname field. 2) Fixes a bug where the validation symbol persisted after a user deleted the value in the blueprint name field. These changes improve code maintainability and provide a more consistent user experience.
37 lines
1,007 B
TypeScript
37 lines
1,007 B
TypeScript
import React from 'react';
|
|
|
|
import { FormGroup } from '@patternfly/react-core';
|
|
|
|
import { useAppDispatch, useAppSelector } from '../../../../../store/hooks';
|
|
import {
|
|
changeHostname,
|
|
selectHostname,
|
|
} from '../../../../../store/wizardSlice';
|
|
import { useHostnameValidation } from '../../../utilities/useValidation';
|
|
import { ValidatedInputAndTextArea } from '../../../ValidatedInput';
|
|
|
|
const HostnameInput = () => {
|
|
const dispatch = useAppDispatch();
|
|
const hostname = useAppSelector(selectHostname);
|
|
|
|
const stepValidation = useHostnameValidation();
|
|
|
|
const handleChange = (e: React.FormEvent, value: string) => {
|
|
dispatch(changeHostname(value));
|
|
};
|
|
|
|
return (
|
|
<FormGroup label="Hostname">
|
|
<ValidatedInputAndTextArea
|
|
ariaLabel="hostname input"
|
|
value={hostname}
|
|
onChange={handleChange}
|
|
placeholder="Add a hostname"
|
|
stepValidation={stepValidation}
|
|
fieldName="hostname"
|
|
/>
|
|
</FormGroup>
|
|
);
|
|
};
|
|
|
|
export default HostnameInput;
|