diff --git a/locales/en/plugin__kuadrant-console-plugin.json b/locales/en/plugin__kuadrant-console-plugin.json index e66a35e..dfb915e 100644 --- a/locales/en/plugin__kuadrant-console-plugin.json +++ b/locales/en/plugin__kuadrant-console-plugin.json @@ -50,8 +50,8 @@ "Gateway API Target Reference": "Gateway API Target Reference", "Gateway: Reference to a Kubernetes resource that the policy attaches to. To create an additional gateway go to": "Gateway: Reference to a Kubernetes resource that the policy attaches to. To create an additional gateway go to", "Gateways": "Gateways", - "Geo": "Geo", - "Geography Label (e.g. 'eu')": "Geography Label (e.g. 'eu')", + "Geo value to apply to geo endpoints": "Geo value to apply to geo endpoints", + "Geography Label (e.g. 'EU')": "Geography Label (e.g. 'EU')", "Getting started resources": "Getting started resources", "Health Check": "Health Check", "Hide for session": "Hide for session", @@ -67,7 +67,9 @@ "Limit": "Limit", "Limit Name": "Limit Name", "Limit Name is required!": "Limit Name is required!", - "Load balancing options:.": "Load balancing options:.", + "Load balancing Geo": "Load balancing Geo", + "Load balancing Weight": "Load balancing Weight", + "LoadBalancing": "LoadBalancing", "Loading..": "Loading..", "Name": "Name", "Namespace": "Namespace", @@ -85,6 +87,7 @@ "RateLimit": "RateLimit", "RateLimitPolicy": "RateLimitPolicy", "Read about the latest information and key features in the Kuadrant highlights.": "Read about the latest information and key features in the Kuadrant highlights.", + "Reference to an existing secret resource containing DNS provider credentials and configuration": "Reference to an existing secret resource containing DNS provider credentials and configuration", "Release Notes": "Release Notes", "Save": "Save", "Select a gateway": "Select a gateway", @@ -109,7 +112,7 @@ "View all quick starts": "View all quick starts", "View Documentation": "View Documentation", "Visit the blog": "Visit the blog", - "Weight": "Weight", + "Weight value to apply to weighted endpoints default: 120": "Weight value to apply to weighted endpoints default: 120", "YAML View": "YAML View", "You can view and create HTTPRoutes": "You can view and create HTTPRoutes" } \ No newline at end of file diff --git a/src/components/KuadrantDNSPolicyCreatePage.tsx b/src/components/KuadrantDNSPolicyCreatePage.tsx index 8df526d..c063469 100644 --- a/src/components/KuadrantDNSPolicyCreatePage.tsx +++ b/src/components/KuadrantDNSPolicyCreatePage.tsx @@ -47,13 +47,13 @@ const KuadrantDNSPolicyCreatePage: React.FC = () => { const [loadBalancing, setLoadBalancing] = React.useState({ geo: '', weight: null, - defaultGeo: true, + defaultGeo: '', }); const [healthCheck, setHealthCheck] = React.useState({ endpoint: '', failureThreshold: null, port: null, - protocol: null, + protocol: '', }); const [providerRefs, setProviderRefs] = React.useState([]); const [creationTimestamp, setCreationTimestamp] = React.useState(''); @@ -64,6 +64,9 @@ const KuadrantDNSPolicyCreatePage: React.FC = () => { const namespaceEdit = pathSplit[3]; const [formDisabled, setFormDisabled] = React.useState(false); const [create, setCreate] = React.useState(true); + const [loadBalancingExpanded, setLoadBalancingExpanded] = React.useState(false); + const [healthExpanded, setHealthExpanded] = React.useState(false); + let isFormValid = false; const createDNSPolicy = () => { @@ -71,7 +74,11 @@ const KuadrantDNSPolicyCreatePage: React.FC = () => { healthCheck.endpoint || healthCheck.failureThreshold || healthCheck.port || - healthCheck.protocol; + healthCheck.protocol != ''; + + const hasLoadBalancing = + loadBalancing.geo || loadBalancing.defaultGeo != '' || loadBalancing.weight; + return { apiVersion: resourceGVKMapping['DNSPolicy'].group + '/' + resourceGVKMapping['DNSPolicy'].version, @@ -88,13 +95,18 @@ const KuadrantDNSPolicyCreatePage: React.FC = () => { kind: 'Gateway', name: selectedGateway.name, }, - loadBalancing: { - weight: loadBalancing.weight, - geo: loadBalancing.geo, - defaultGeo: loadBalancing.defaultGeo, - }, providerRefs: providerRefs.length > 0 ? [providerRefs[0]] : [], - + ...(hasLoadBalancing + ? { + loadBalancing: { + ...(loadBalancing?.weight ? { weight: loadBalancing.weight } : {}), + ...(loadBalancing?.geo ? { geo: loadBalancing.geo } : {}), + ...(loadBalancing.defaultGeo !== '' + ? { defaultGeo: loadBalancing.defaultGeo } + : {}), + }, + } + : {}), ...(hasHealthCheck ? { healthCheck: { @@ -256,17 +268,23 @@ const KuadrantDNSPolicyCreatePage: React.FC = () => { const handleCancelResource = () => { handleCancel(selectedNamespace, dnsPolicy, history); }; - - if ( - policyName && - selectedNamespace && - selectedGateway.name && - setProviderRefs && - loadBalancing.geo && - loadBalancing.weight - ) { - isFormValid = true; - } + const formValidation = () => { + if ( + policyName && + selectedGateway.name && + providerRefs.length > 0 && + (!loadBalancingExpanded || + (loadBalancing.geo && loadBalancing.weight && loadBalancing.defaultGeo !== '')) && + (!healthExpanded || + (healthCheck.endpoint && + healthCheck.failureThreshold > 0 && + healthCheck.port > 0 && + healthCheck.protocol !== '')) + ) { + isFormValid = true; + } + return isFormValid; + }; return ( <> @@ -313,48 +331,71 @@ const KuadrantDNSPolicyCreatePage: React.FC = () => { {createView === 'form' ? (
-
- - - - - {t('Unique name of the DNS Policy')} - - - - - - 0 ? providerRefs[0].name : ''} - onChange={handleProviderRefs} - placeholder={t('Provider Ref')} - /> - - - - - -
- + + + + + {t('Unique name of the DNS Policy')} + + + + + + 0 ? providerRefs[0].name : ''} + onChange={handleProviderRefs} + placeholder={t('Provider Ref')} + /> + + + + {t( + 'Reference to an existing secret resource containing DNS provider credentials and configuration', + )} + + + + + setLoadBalancingExpanded(!loadBalancingExpanded)} + > + + + setHealthExpanded(!healthExpanded)} + > + + +