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 dfc3c4e66..86413edba 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 \"/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.", "Error: Fingerprint is required and must be valid.": "Error: Fingerprint is required and must be valid.", @@ -273,7 +274,6 @@ "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.", - "Please enter URL for vSphere REST APIs server.": "Please enter URL for vSphere REST APIs server.", "Pod network": "Pod network", "Power state": "Power state", "Powered off": "Powered off", @@ -334,7 +334,6 @@ "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.", - "Specify vCenter 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.": "Specify vCenter 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.", "SSHA-1 fingerprint": "SSHA-1 fingerprint", "Staging": "Staging", "Status": "Status", @@ -393,6 +392,7 @@ "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. 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 vCenter SDK endpoint.": "URL of the vCenter SDK endpoint.", "URL of the vCenter SDK endpoint. Ensure the URL includes the \"/sdk\" path. For example: https://vCenter-host-example.com/sdk": "URL of the vCenter SDK endpoint. Ensure the URL includes the \"/sdk\" path. For example: https://vCenter-host-example.com/sdk", "User ID": "User ID", "User or service account bearer token for service accounts or user authentication.": "User or service account bearer token for service accounts or user authentication.", diff --git a/packages/forklift-console-plugin/src/modules/Providers/modals/EditProviderURL/VSphereEditURLModal.tsx b/packages/forklift-console-plugin/src/modules/Providers/modals/EditProviderURL/VSphereEditURLModal.tsx index 2bd54fed8..7f360e431 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/modals/EditProviderURL/VSphereEditURLModal.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/modals/EditProviderURL/VSphereEditURLModal.tsx @@ -13,20 +13,41 @@ import { EditProviderURLModalProps } from './EditProviderURLModal'; export const VSphereEditURLModal: 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://vCenter-host-example.com/sdk', + ), + warning: t( + 'Warning: The provided URL does not end with the SDK endpoint path: "/sdk". Ensure the URL includes the correct path. For example: https://vCenter-host-example.com/sdk', + ), + success: t( + 'Ensure the URL includes the "/sdk" path. For example: https://vCenter-host-example.com/sdk', + ), + }; + 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('sdk') && !trimmedUrl.endsWith('sdk/')) + return { + validationHelpText: helperTextMsgs.warning, + validated: 'warning', + }; + + // success + return { + validationHelpText: helperTextMsgs.success, + validated: 'success', + }; }; return ( @@ -37,10 +58,8 @@ export const VSphereEditURLModal: React.FC = (props) label={props?.label || t('URL')} model={ProviderModel} variant={ModalVariant.large} - body={t( - 'Specify vCenter 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.', - )} - helperText={t('Please enter URL for vSphere REST APIs server.')} + body={t('URL of the vCenter SDK endpoint.')} + helperText={helperTextMsgs.success} onConfirmHook={patchProviderURL} validationHook={urlValidationHook} />