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 111 112 113 | 219x 219x 219x 219x 219x 219x 219x 219x 1x 1x 1x 1x 1x 1x 1x | /* * 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, { useEffect, useState } from 'react' import cx from 'classnames' import { StepProps, Formik, FormikForm, FormInput, Layout, Text, Button, Container, ButtonVariation } from '@wings-software/uicore' import * as Yup from 'yup' import { FontVariation } from '@harness/design-system' import type { ConnectorConfigDTO, ConnectorInfoDTO } from 'services/cd-ng' import { useStrings } from 'framework/strings' import css from '../commonSteps/ConnectorCommonStyles.module.scss' export interface AWSCCDetailsStepProps extends StepProps<ConnectorConfigDTO> { isEditMode: boolean connectorInfo?: ConnectorInfoDTO } export default function AWSCCDetailsStep(props: AWSCCDetailsStepProps) { const { getString } = useStrings() const [initialValues, setInitialValues] = useState<ConnectorConfigDTO>({ urlType: 'Region', url: undefined }) const handleSubmit = (formData: ConnectorConfigDTO) => { props.nextStep?.({ ...props.prevStepData, ...formData }) } useEffect(() => { Iif (props.isEditMode) { setInitialValues({ urlType: props?.connectorInfo?.spec?.type, url: props?.connectorInfo?.spec?.url }) } }, []) return ( <Layout.Vertical width="60%" style={{ minHeight: 460 }} className={css.stepContainer}> <Text font={{ variation: FontVariation.H3 }} tooltipProps={{ dataTooltipId: 'awsCCDetailsTooltip' }}> {getString('details')} </Text> <Formik enableReinitialize initialValues={{ ...initialValues, ...props.prevStepData }} formName="awsCCDetailsForm" validationSchema={Yup.object().shape({ urlType: Yup.string().required(), url: Yup.string().required() })} onSubmit={handleSubmit} > <FormikForm className={cx(css.fullHeight, css.fullHeightDivsWithFlex)}> <Container className={css.paddingTop8}> <FormInput.RadioGroup name="urlType" label={<Text font={{ variation: FontVariation.FORM_LABEL }}>{getString('common.git.urlType')}</Text>} items={[ { value: 'Region', label: getString('regionLabel') }, { value: 'Repo', label: getString('repository') } ]} radioGroup={{ inline: true }} /> <FormInput.Text name="url" label={ <Text font={{ variation: FontVariation.FORM_LABEL }}> {getString('connectors.awsCodeCommit.repoUrl')} </Text> } placeholder={getString('UrlLabel')} /> </Container> <Layout.Horizontal spacing="medium"> <Button icon="chevron-left" onClick={() => props.previousStep?.({ ...props.prevStepData })} text={getString('back')} variation={ButtonVariation.SECONDARY} /> <Button type="submit" intent="primary" rightIcon="chevron-right" text={getString('saveAndContinue')} variation={ButtonVariation.PRIMARY} /> </Layout.Horizontal> </FormikForm> </Formik> </Layout.Vertical> ) } |