Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 18x 16x 16x 16x 15x 16x 21x 5x | /*
* Copyright 2021 Harness Inc. All rights reserved.
* Use of this source code is governed by the PolyForm Shield 1.0.0 license
* that can be found in the licenses directory at the root of this repository, also available at
* https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
*/
import React, { useMemo } from 'react'
import { Heading, Layout, Formik, FormikForm } from '@wings-software/uicore'
import * as Yup from 'yup'
import { isEmpty as _isEmpty, defaultTo as _defaultTo } from 'lodash-es'
import type { DNSLinkSetupFormVal } from '@ce/types'
import { useStrings } from 'framework/strings'
import type { ConnectionMetadata, CustomDomainDetails, GatewayDetails } from '../COCreateGateway/models'
import { Utils } from '../../common/Utils'
import LBAdvancedConfiguration from './LBAdvancedConfiguration'
import ResourceAccessUrlSelector from './ResourceAccessUrlSelector'
import LoadBalancerSelection from './LoadBalancerSelection'
interface DNSLinkSetupProps {
gatewayDetails: GatewayDetails
setHelpTextSections: (s: string[]) => void
setGatewayDetails: (gw: GatewayDetails) => void
onInfoIconClick?: () => void
activeStepDetails?: { count?: number; tabId?: string } | null
serverNames: string[]
setServerNames: (val: string[]) => void
}
const DNSLinkSetup: React.FC<DNSLinkSetupProps> = props => {
const { getString } = useStrings()
const accessDetails = props.gatewayDetails.opts.access_details as ConnectionMetadata // eslint-disable-line
const customDomainProviderDetails = props.gatewayDetails.routing.custom_domain_providers as CustomDomainDetails // eslint-disable-line
const allCustomDomains = useMemo(
() => Utils.getAllCustomDomains(props.serverNames, props.gatewayDetails.customDomains),
[props.serverNames, props.gatewayDetails.customDomains]
)
return (
<Layout.Vertical spacing="medium" padding="medium">
<Heading level={3}>{getString('ce.co.gatewayAccess.dnsLinkHeader')}</Heading>
<Formik<DNSLinkSetupFormVal>
initialValues={{
usingCustomDomain: Utils.getConditionalResult(!_isEmpty(allCustomDomains), 'yes', 'no'),
customURL: allCustomDomains.join(','),
publicallyAccessible: _defaultTo(accessDetails.dnsLink.public as string, 'yes'),
dnsProvider: customDomainProviderDetails
? customDomainProviderDetails.route53
? 'route53'
: 'others'
: 'route53',
route53Account: Utils.getConditionalResult(
!_isEmpty(customDomainProviderDetails?.route53),
customDomainProviderDetails?.route53?.hosted_zone_id,
''
)
// accessPoint: props.gatewayDetails.accessPointID
}}
formName="dnsLinkSetup"
enableReinitialize={true}
onSubmit={values => alert(JSON.stringify(values))}
validationSchema={Yup.object().shape({
customURL: Yup.string()
.trim()
.matches(
/((https?):\/\/)?(www.)?[a-z0-9-]+(\.[a-z]{2,}){1,3}(#?\/?[a-zA-Z0-9#-]+)*\/?(\?[a-zA-Z0-9-_]+=[a-zA-Z0-9-%]+&?)?$/,
'Enter a valid URL'
)
.required()
})}
render={formik => (
<FormikForm>
<Layout.Vertical spacing="large">
<LoadBalancerSelection
gatewayDetails={props.gatewayDetails}
setGatewayDetails={props.setGatewayDetails}
/>
{_isEmpty(props.gatewayDetails.routing.container_svc) && (
<LBAdvancedConfiguration
gatewayDetails={props.gatewayDetails}
setGatewayDetails={props.setGatewayDetails}
activeStepDetails={props.activeStepDetails}
setServerNames={props.setServerNames}
/>
)}
<ResourceAccessUrlSelector
formikProps={formik}
gatewayDetails={props.gatewayDetails}
setGatewayDetails={props.setGatewayDetails}
setHelpTextSections={props.setHelpTextSections}
serverNames={props.serverNames}
/>
</Layout.Vertical>
</FormikForm>
)}
></Formik>
</Layout.Vertical>
)
}
export default DNSLinkSetup
|