Skip to content

Commit

Permalink
Merge pull request #13726 from rawagner/vsphere_help_txt
Browse files Browse the repository at this point in the history
OCPBUGS-29823, OCPBUGS-29616, OCPBUGS-31613: Add validation for vSphere fields
  • Loading branch information
openshift-merge-bot[bot] committed Apr 5, 2024
2 parents b39c4f3 + ad3a760 commit 1fc442c
Show file tree
Hide file tree
Showing 16 changed files with 549 additions and 462 deletions.
4 changes: 2 additions & 2 deletions frontend/packages/vsphere-plugin/__tests__/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import { ConnectionFormContextValues } from '../src/components/types';
import { ConnectionFormFormikValues } from '../src/components/types';
import { mergeCloudProviderConfig } from '../src/components/utils';

const config: ConnectionFormContextValues = {
const config: ConnectionFormFormikValues = {
username: 'my-username',
password: 'my-password',
vcenter: 'https://1.2.3.4/something',
Expand Down
25 changes: 14 additions & 11 deletions frontend/packages/vsphere-plugin/locales/en/vsphere-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,37 @@
"Failed to patch {{secret}}": "Failed to patch {{secret}}",
"Failed to create {{secret}} secret": "Failed to create {{secret}} secret",
"Failed to load kubecontrollermanager": "Failed to load kubecontrollermanager",
"Not found.": "Not found.",
"Failed to patch kubecontrollermanager": "Failed to patch kubecontrollermanager",
"Failed to patch {{cm}}": "Failed to patch {{cm}}",
"Failed to create {{cm}} ConfigMap": "Failed to create {{cm}} ConfigMap",
"Failed to add taint to node {{node}}": "Failed to add taint to node {{node}}",
"Failed to patch infrastructure spec": "Failed to patch infrastructure spec",
"Provide <1>datacenter</1> folder which contains VMs of the cluster, example: /<3>{{datacenter}}</3>/<5>vm</5>/<7>[MY_VMS_TOP_FOLDER]</7>.": "Provide <1>datacenter</1> folder which contains VMs of the cluster, example: /<3>{{datacenter}}</3>/<5>vm</5>/<7>[MY_VMS_TOP_FOLDER]</7>.",
"Enter the name of the vSphere data center that contains the virtual machines currently backing-up the cluster.": "Enter the name of the vSphere data center that contains the virtual machines currently backing-up the cluster.",
"Warning: Updating this value once the configuration has been saved will detach any existing PersistentVolumes.": "Warning: Updating this value once the configuration has been saved will detach any existing PersistentVolumes.",
"Select the data store in the vSphere data center that is to store the persistent data volumes.": "Select the data store in the vSphere data center that is to store the persistent data volumes.",
"Warning: Updating this value will break any existing PersistentVolumes.": "Warning: Updating this value will break any existing PersistentVolumes.",
"Unexpected error": "Unexpected error",
"vCenter": "vCenter",
"Enter the network address of the vCenter server. It can either be a domain name or IP address. It appears in the vSphere web client URL. Example: ": "Enter the network address of the vCenter server. It can either be a domain name or IP address. It appears in the vSphere web client URL. Example: ",
"Can be either domain name or IP address. See tooltip for details.": "Can be either domain name or IP address. See tooltip for details.",
"Enter the network address of the vCenter server. It can either be a domain name or IP address": "Enter the network address of the vCenter server. It can either be a domain name or IP address",
"vCenter cluster": "vCenter cluster",
"Enter the name of the vSphere vCenter cluster where OpenShift Container Platform is installed.": "Enter the name of the vSphere vCenter cluster where OpenShift Container Platform is installed.",
"Username": "Username",
"Enter the vSphere vCenter username. An incorrect username will render the cluster nodes unschedulable (known issue: OCPBUGS-2353).": "Enter the vSphere vCenter username. An incorrect username will render the cluster nodes unschedulable (known issue: OCPBUGS-2353).",
"Password": "Password",
"Enter the vSphere vCenter password. The password will be stored in a Secret in the kube-system namespace for this cluster. An incorrect password will render the cluster nodes unschedulable (known issue: OCPBUGS-2353).": "Enter the vSphere vCenter password. The password will be stored in a Secret in the kube-system namespace for this cluster. An incorrect password will render the cluster nodes unschedulable (known issue: OCPBUGS-2353).",
"Datacenter": "Datacenter",
"Enter the name of the vSphere data center that contains the virtual machines currently backing-up the cluster.": "Enter the name of the vSphere data center that contains the virtual machines currently backing-up the cluster.",
"Warning: Updating this value once the configuration has been saved will detach any existing PersistentVolumes.": "Warning: Updating this value once the configuration has been saved will detach any existing PersistentVolumes.",
"Default data store": "Default data store",
"Select the data store in the vSphere data center that is to store the persistent data volumes.": "Select the data store in the vSphere data center that is to store the persistent data volumes.",
"Warning: Updating this value will break any existing PersistentVolumes.": "Warning: Updating this value will break any existing PersistentVolumes.",
"Virtual Machine Folder": "Virtual Machine Folder",
"Provide <1>datacenter</1> folder which contains VMs of the cluster.": "Provide <1>datacenter</1> folder which contains VMs of the cluster.",
"Saving": "Saving",
"Save configuration": "Save configuration",
"Cancel": "Cancel",
"vSphere Problem Detector (can be outdated)": "vSphere Problem Detector (can be outdated)",
"Retry": "Retry",
"Delayed propagation of configuration": "Delayed propagation of configuration",
"The configuration process updates operator statuses and reboots nodes. This process typically takes about an hour. Existing resources such as previously bound Persistent Volume Claims might become disconnected.": "The configuration process updates operator statuses and reboots nodes. This process typically takes about an hour. Existing resources such as previously bound Persistent Volume Claims might become disconnected.",
"Note, that existing resources (like already bound PVCs) might get broken by these changes.": "Note, that existing resources (like already bound PVCs) might get broken by these changes.",
"Cancel": "Cancel",
"Saving": "Saving",
"Save configuration": "Save configuration",
"An error occured.": "An error occured.",
"vSphere connection configuration": "vSphere connection configuration",
"Pending": "Pending",
"Error": "Error",
Expand All @@ -55,5 +56,7 @@
"Kube API Server": "Kube API Server",
"Kube Controller Manager": "Kube Controller Manager",
"Storage": "Storage",
"Failed to fetch infrastructure resource": "Failed to fetch infrastructure resource",
"An error occured": "An error occured",
"Help": "Help"
}
4 changes: 3 additions & 1 deletion frontend/packages/vsphere-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
},
"dependencies": {
"@console/dynamic-plugin-sdk": "0.0.0-fixed",
"ini": "4.1.1"
"formik": "^2.4.5",
"ini": "4.1.1",
"yup": "^0.27.0"
},
"consolePlugin": {
"entry": "src/plugin.ts",
Expand Down
11 changes: 3 additions & 8 deletions frontend/packages/vsphere-plugin/src/PopoverHelpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons/dist/esm/ico
import { useTranslation } from 'react-i18next';

export const PopoverHelpButton: React.FC<{ content: React.ReactNode }> = ({ content }) => {
const { t } = useTranslation();
const { t } = useTranslation('vsphere-plugin');
return (
<Popover aria-label={t('vsphere-plugin~Help')} bodyContent={content}>
<Button
aria-label={t('vsphere-plugin~Help')}
variant="link"
isInline
className="co-field-level-help"
>
<Popover aria-label={t('Help')} bodyContent={content}>
<Button aria-label={t('Help')} variant="link" isInline className="co-field-level-help">
<OutlinedQuestionCircleIcon className="co-field-level-help__icon" />
</Button>
</Popover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@console/dynamic-plugin-sdk/dist/core/lib/lib-core';
import { ConfigMap } from '../../resources';
import { getVSphereHealth } from '../getVSphereHealth';
import { VSphereConnection } from '../VSphereConnection';
import { VSphereConnectionModal } from '../VSphereConnectionModal';
import { VSphereOperatorStatuses } from '../VSphereOperatorStatuses';
import './VSphereStatus.css';

Expand All @@ -25,7 +25,11 @@ const VSphereStatus: React.FC<PrometheusHealthPopupProps> = ({ hide, responses,
) {
const cloudProviderConfig = k8sResult.data as ConfigMap;
return (
<VSphereConnection hide={hide} cloudProviderConfig={cloudProviderConfig} health={health} />
<VSphereConnectionModal
hide={hide}
cloudProviderConfig={cloudProviderConfig}
health={health}
/>
);
}

Expand Down

This file was deleted.

69 changes: 69 additions & 0 deletions frontend/packages/vsphere-plugin/src/components/TextField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import * as React from 'react';
import {
FormGroup,
FormHelperText,
HelperText,
HelperTextItem,
TextInput,
TextInputProps,
} from '@patternfly/react-core';
import { ExclamationCircleIcon } from '@patternfly/react-icons';
import { useField } from 'formik';

interface TextFieldProps extends TextInputProps {
name: string;
helperText?: React.ReactNode;
}

const TextField = React.forwardRef(
(
{ helperText, onChange: onParentChange, ...props }: TextFieldProps,
ref: React.Ref<HTMLInputElement>,
) => {
const [field, meta, { setValue }] = useField({
name: props.name,
});

const onChange = (_ev, value: string) => {
setValue(value);
onParentChange?.(_ev, value);
};

const fieldId = `textfield-${props.name}`;
const hasError = meta.touched && !!meta.error;

return (
<FormGroup id={`form-control__${fieldId}`} fieldId={fieldId}>
<TextInput
{...field}
{...props}
ref={ref}
id={fieldId}
onChange={onChange}
validated={hasError ? 'error' : 'default'}
/>

{helperText && (
<FormHelperText>
<HelperText>
<HelperTextItem variant={'default'}>{helperText}</HelperTextItem>
</HelperText>
</FormHelperText>
)}
{hasError && (
<FormHelperText>
<HelperText>
<HelperTextItem icon={<ExclamationCircleIcon />} variant={'error'}>
{meta.error}
</HelperTextItem>
</HelperText>
</FormHelperText>
)}
</FormGroup>
);
},
);

TextField.displayName = 'TextField';

export default TextField;

0 comments on commit 1fc442c

Please sign in to comment.