diff --git a/packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json b/packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json index 7d3ecf339..b301f5a6a 100644 --- a/packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json +++ b/packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json @@ -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.", @@ -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", @@ -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://:6443 for OpenShift. Empty may be used for the host provider.": "Specify OpenShift cluster API endpoint, for example, https://: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:///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:///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.", @@ -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.", diff --git a/packages/forklift-console-plugin/src/modules/Providers/modals/EditProviderURL/OvirtEditURLModal.tsx b/packages/forklift-console-plugin/src/modules/Providers/modals/EditProviderURL/OvirtEditURLModal.tsx index 705398a9c..ad7a5afb3 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/modals/EditProviderURL/OvirtEditURLModal.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/modals/EditProviderURL/OvirtEditURLModal.tsx @@ -13,20 +13,41 @@ import { EditProviderURLModalProps } from './EditProviderURLModal'; export const OvirtEditURLModal: React.FC = (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 ( @@ -37,11 +58,8 @@ export const OvirtEditURLModal: React.FC = (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:///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} />