Skip to content

Commit

Permalink
Merge pull request #773 from sgratch/fix-edit-ovirt-url-help-text
Browse files Browse the repository at this point in the history
Fix the Edit URL modal text for the oVirt provider
  • Loading branch information
yaacov authored Nov 9, 2023
2 parents 7f0df89 + fdb1180 commit e77a33b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"Edit VDDK init image": "Edit VDDK init image",
"Empty": "Empty",
"Endpoint": "Endpoint",
"Ensure the URL includes the \"/ovirt-engine/api\" path. For example: https://rhv-host-example.com/ovirt-engine/api": "Ensure the URL includes the \"/ovirt-engine/api\" path. For example: https://rhv-host-example.com/ovirt-engine/api",
"Ensure the URL includes the \"/sdk\" path. For example: https://vCenter-host-example.com/sdk": "Ensure the URL includes the \"/sdk\" path. For example: https://vCenter-host-example.com/sdk",
"Error": "Error",
"Error: CA Certificate must be valid.": "Error: CA Certificate must be valid.",
Expand Down Expand Up @@ -271,7 +272,6 @@
"Please enter the limit for memory usage by the controller in Mi, if empty default value will be used.": "Please enter the limit for memory usage by the controller in Mi, if empty default value will be used.",
"Please enter the maximum age in hours for must gather cleanup, if empty default value will be used.": "Please enter the maximum age in hours for must gather cleanup, if empty default value will be used.",
"Please enter the maximum number of concurrent VM migrations, if empty default value will be used.": "Please enter the maximum number of concurrent VM migrations, if empty default value will be used.",
"Please enter the URL for RHV engine server.": "Please enter the URL for RHV engine server.",
"Please enter URL for OpenStack services REST APIs.": "Please enter URL for OpenStack services REST APIs.",
"Please enter URL for the kubernetes API server, if empty URL default to this cluster.": "Please enter URL for the kubernetes API server, if empty URL default to this cluster.",
"Pod network": "Pod network",
Expand Down Expand Up @@ -329,7 +329,6 @@
"Specify NFS mount end point serving the OVA file[s].": "Specify NFS mount end point serving the OVA file[s].",
"Specify OpenShift cluster API endpoint, for example, https://<kubernetes API Endpoint>:6443 for OpenShift. Empty may be used for the host provider.": "Specify OpenShift cluster API endpoint, for example, https://<kubernetes API Endpoint>:6443 for OpenShift. Empty may be used for the host provider.",
"Specify OpenStack Identity (Keystone) endpoint, for example, http://controller:5000/v3.": "Specify OpenStack Identity (Keystone) endpoint, for example, http://controller:5000/v3.",
"Specify RHV Manager host name or IP address. If a certificate for FQDN is specified, the value of this field needs to match the FQDN in the certificate,\n for example, https://<engine_host>/ovirt-engine/api/ for RHV.": "Specify RHV Manager host name or IP address. If a certificate for FQDN is specified, the value of this field needs to match the FQDN in the certificate,\n for example, https://<engine_host>/ovirt-engine/api/ for RHV.",
"Specify the type of source provider. Allowed values are ova, ovirt, vsphere, and openstack. This label is needed to verify the credentials are correct when the remote system is accessible and, for RHV, to retrieve the Manager CA certificate when a third-party certificate is specified.": "Specify the type of source provider. Allowed values are ova, ovirt, vsphere, and openstack. This label is needed to verify the credentials are correct when the remote system is accessible and, for RHV, to retrieve the Manager CA certificate when a third-party certificate is specified.",
"Specify the VDDK image that you created.": "Specify the VDDK image that you created.",
"Specify the VDDK image that you created. VDDK accelerates migrations significantly.": "Specify the VDDK image that you created. VDDK accelerates migrations significantly.",
Expand Down Expand Up @@ -391,6 +390,7 @@
"URL of the API endpoint of the Red Hat Virtualization Manager (RHVM) on which the source VM is mounted. Ensure that the URL includes the path leading to the RHVM API server, usually /ovirt-engine/api. For example, https://rhv-host-example.com/ovirt-engine/api.": "URL of the API endpoint of the Red Hat Virtualization Manager (RHVM) on which the source VM is mounted. Ensure that the URL includes the path leading to the RHVM API server, usually /ovirt-engine/api. For example, https://rhv-host-example.com/ovirt-engine/api.",
"URL of the provider": "URL of the provider",
"URL of the provider, leave empty to use this providers URL": "URL of the provider, leave empty to use this providers URL",
"URL of the Red Hat Virtualization Manager (RHVM) API endpoint.": "URL of the Red Hat Virtualization Manager (RHVM) API endpoint.",
"URL of the Red Hat Virtualization Manager (RHVM) API endpoint. Ensure the URL includes the \"/ovirt-engine/api\" path. For example: https://rhv-host-example.com/ovirt-engine/api": "URL of the Red Hat Virtualization Manager (RHVM) API endpoint. Ensure the URL includes the \"/ovirt-engine/api\" path. For example: https://rhv-host-example.com/ovirt-engine/api",
"URL of the SDK endpoint of the vCenter on which the source VM is mounted. Ensure that the URL includes the sdk path, usually /sdk. For example, https://vCenter-host-example.com/sdk. If a certificate for FQDN is specified, the value of this field needs to match the FQDN in the certificate.": "URL of the SDK endpoint of the vCenter on which the source VM is mounted. Ensure that the URL includes the sdk path, usually /sdk. For example, https://vCenter-host-example.com/sdk. If a certificate for FQDN is specified, the value of this field needs to match the FQDN in the certificate.",
"URL of the vCenter SDK endpoint.": "URL of the vCenter SDK endpoint.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,41 @@ import { EditProviderURLModalProps } from './EditProviderURLModal';
export const OvirtEditURLModal: React.FC<EditProviderURLModalProps> = (props) => {
const { t } = useForkliftTranslation();

const helperTextMsgs = {
error: t(
'Error: The format of the provided URL is invalid. Ensure the URL includes a scheme, a domain name, and a path. For example: https://rhv-host-example.com/ovirt-engine/api',
),
warning: t(
'Warning: The provided URL does not end with the RHVM API endpoint path: "/ovirt-engine/api". Ensure the URL includes the correct path. For example: https://rhv-host-example.com/ovirt-engine/api',
),
success: t(
'Ensure the URL includes the "/ovirt-engine/api" path. For example: https://rhv-host-example.com/ovirt-engine/api',
),
};

const urlValidationHook: ValidationHookType = (value) => {
const isValidURL = validateURL(value.toString().trim());

return isValidURL
? {
validationHelpText: undefined,
validated: 'success',
}
: {
validationHelpText: t(
'URL must start with https:// or http:// and contain valid hostname and path',
),
validated: 'error',
};
const trimmedUrl: string = value.toString().trim();
const isValidURL = validateURL(trimmedUrl);

// error
if (!isValidURL)
return {
validationHelpText: helperTextMsgs.error,
validated: 'error',
};

// warning
if (!trimmedUrl.endsWith('ovirt-engine/api') && !trimmedUrl.endsWith('ovirt-engine/api/'))
return {
validationHelpText: helperTextMsgs.warning,
validated: 'warning',
};

// success
return {
validationHelpText: helperTextMsgs.success,
validated: 'success',
};
};

return (
Expand All @@ -37,11 +58,8 @@ export const OvirtEditURLModal: React.FC<EditProviderURLModalProps> = (props) =>
label={props?.label || t('URL')}
model={ProviderModel}
variant={ModalVariant.large}
body={t(
`Specify RHV Manager host name or IP address. If a certificate for FQDN is specified, the value of this field needs to match the FQDN in the certificate,
for example, https://<engine_host>/ovirt-engine/api/ for RHV.`,
)}
helperText={t('Please enter the URL for RHV engine server.')}
body={t(`URL of the Red Hat Virtualization Manager (RHVM) API endpoint.`)}
helperText={helperTextMsgs.success}
onConfirmHook={patchProviderURL}
validationHook={urlValidationHook}
/>
Expand Down

0 comments on commit e77a33b

Please sign in to comment.