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 104 105 106 107 108 109 110 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 3x 3x 3x 3x 3x 6x 3x 1x 1x 6x 2x | /* * 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, { useState } from 'react' import { Button, CardBody, CardSelect, Container, Heading, IconName, Layout, Text } from '@wings-software/uicore' import { ConnectorReferenceField } from '@connectors/components/ConnectorReferenceField/ConnectorReferenceField' import { Connectors } from '@connectors/constants' import { useStrings } from 'framework/strings' import type { ConnectorInfoDTO } from 'services/cd-ng' import { Utils } from '@ce/common/Utils' import { useFeatureFlags } from '@common/hooks/useFeatureFlag' import { FeatureFlag } from '@common/featureFlags' import type { Provider, ProviderWithDependencies } from '../COCreateGateway/models' import css from './COAPProviderSelector.module.scss' interface COAPProviderSelectorProps { onSubmit: (data: { provider: string; connectorDetails?: string }) => void accountId: string } const data: ProviderWithDependencies[] = [ { name: 'AWS', value: 'aws', icon: 'service-aws' }, { name: 'Azure', value: 'azure', icon: 'service-azure' }, { name: 'GCP', value: 'gcp', icon: 'gcp', ffDependencies: [FeatureFlag.CE_AS_GCP_VM_SUPPORT] } ] const connectorType: Record<string, string> = { aws: Connectors.CEAWS, azure: Connectors.CE_AZURE, gcp: Connectors.CE_GCP } const COAPProviderSelector: React.FC<COAPProviderSelectorProps> = props => { const { getString } = useStrings() const featureFlags = useFeatureFlags() const [selectedCard, setSelectedCard] = useState<Provider | null>(null) const [connectorDetails, setConnectorDetails] = useState<string>() const providerData = React.useMemo( () => data.filter(p => Utils.isFFEnabledForResource(p.ffDependencies, featureFlags)), [featureFlags] ) return ( <Layout.Vertical> <Container className={css.mainContainer}> <Heading level={2}>Select Cloud Provider</Heading> <Layout.Horizontal spacing="small" style={{ paddingTop: '29px' }}> <CardSelect data={providerData} selected={selectedCard as Provider} className={css.providerCardsContainer} onChange={item => { Iif (connectorDetails) setConnectorDetails(undefined) setSelectedCard(item) }} renderItem={(item: Provider) => ( <Layout.Vertical spacing="small"> <CardBody.Icon icon={item.icon as IconName} iconSize={28}></CardBody.Icon> <Text style={{ textAlign: 'center' }}>{item.name}</Text> </Layout.Vertical> )} cornerSelected={true} ></CardSelect> </Layout.Horizontal> {selectedCard && ( <ConnectorReferenceField name="cloudConnector" placeholder={getString('ce.co.accessPoint.select.account')} selected={connectorDetails} onChange={record => { setConnectorDetails?.(record.identifier) }} accountIdentifier={props.accountId} label={getString('ce.co.accessPoint.select.connector')} type={selectedCard.value ? (connectorType[selectedCard.value] as ConnectorInfoDTO['type']) : undefined} /> )} </Container> <Button intent={'primary'} icon="chevron-right" className={css.continueCta} onClick={() => props.onSubmit({ provider: selectedCard?.value as string, connectorDetails })} > Continue </Button> </Layout.Vertical> ) } export default COAPProviderSelector |