Skip to content

Commit

Permalink
Remove error helper duplicated in SecurityFields in Networking Page (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ammont82 authored Mar 8, 2024
1 parent cf07898 commit d4833e4
Showing 1 changed file with 2 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import * as React from 'react';
import { useFormikContext } from 'formik';
import {
Checkbox,
FormGroup,
FormHelperText,
HelperText,
HelperTextItem,
} from '@patternfly/react-core';
import { Checkbox, FormGroup, HelperText, HelperTextItem } from '@patternfly/react-core';

import { RenderIf } from '../ui/RenderIf';
import { getFieldId, TextAreaField, trimSshPublicKey, ExternalLink } from '../ui';
Expand Down Expand Up @@ -46,11 +40,9 @@ const SecurityFields = ({
//clusterSshKey updating causes the textarea to disappear when the user clears it to edit it
const defaultShareSshKey = !!imageSshKey && (clusterSshKey === imageSshKey || !clusterSshKey);
const [shareSshKey, setShareSshKey] = React.useState(defaultShareSshKey);
const { values, setFieldValue, errors, touched } =
const { values, setFieldValue } =
useFormikContext<Pick<NetworkConfigurationValues, 'sshPublicKey'>>();

const errorMsg = errors.sshPublicKey;

const handleSshKeyBlur = () => {
if (values.sshPublicKey) {
setFieldValue('sshPublicKey', trimSshPublicKey(values.sshPublicKey));
Expand Down Expand Up @@ -90,18 +82,6 @@ const SecurityFields = ({
isDisabled={isDisabled}
/>
</RenderIf>
{errorMsg && (
<FormHelperText>
<HelperText>
<HelperTextItem
variant={touched && errorMsg ? 'error' : 'default'}
id={errorMsg ? `${fieldId}-helper-error` : `${fieldId}-helper`}
>
{errorMsg ? errorMsg : ''}
</HelperTextItem>
</HelperText>
</FormHelperText>
)}
</FormGroup>
</>
);
Expand Down

0 comments on commit d4833e4

Please sign in to comment.