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 | 219x 219x 219x 219x 219x 219x 219x 219x 219x 219x 219x 4x 4x 4x 4x 2x 1x 1x 1x 4x 2x 219x | /* * 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, useEffect } from 'react' import * as Yup from 'yup' import { StepProps, Container, Text, Formik, FormikForm, FormInput, Layout, Button } from '@wings-software/uicore' import type { ConnectorDetailsProps, StepDetailsProps, GcpKmsConfigFormData } from '@connectors/interfaces/ConnectorInterface' import SecretInput from '@secrets/components/SecretInput/SecretInput' import { PageSpinner } from '@common/components' import { useStrings } from 'framework/strings' import { setupGcpKmsFormData } from '@connectors/pages/connectors/utils/ConnectorUtils' import { Connectors } from '@connectors/constants' import css from '../CreateGcpKmsConnector.module.scss' const defaultInitialFormData: GcpKmsConfigFormData = { projectId: '', region: '', keyRing: '', keyName: '', default: false } const GcpKmsConfig: React.FC<StepProps<StepDetailsProps> & ConnectorDetailsProps> = ({ isEditMode, prevStepData, nextStep, connectorInfo, previousStep, accountId }) => { const { getString } = useStrings() const [loadingFormData, setLoadingFormData] = useState(isEditMode) const [initialValues, setInitialValues] = useState(defaultInitialFormData) useEffect(() => { if (isEditMode && connectorInfo && accountId) { setupGcpKmsFormData(connectorInfo, accountId).then(data => { setInitialValues(data as GcpKmsConfigFormData) setLoadingFormData(false) }) } }, [isEditMode, connectorInfo, accountId]) return loadingFormData ? ( <PageSpinner /> ) : ( <Container padding={{ top: 'medium' }} width="64%"> <Text font={{ size: 'medium' }} padding={{ bottom: 'xlarge' }}> {getString('details')} </Text> <Formik formName="gcpKmsConfig" enableReinitialize initialValues={{ ...initialValues, ...prevStepData }} validationSchema={Yup.object().shape({ projectId: Yup.string().trim().required(getString('validation.projectIDRequired')), region: Yup.string().trim().required(getString('validation.regionRequired')), keyRing: Yup.string().trim().required(getString('connectors.gcpKms.keyRingRequired')), keyName: Yup.string().trim().required(getString('connectors.gcpKms.keyNameRequired')), credentials: Yup.object().required(getString('connectors.gcpKms.credentialsFileRequired')) })} onSubmit={formData => { nextStep?.({ ...connectorInfo, ...prevStepData, ...formData } as StepDetailsProps) }} > <FormikForm> <Container margin={{ top: 'medium', bottom: 'xxlarge' }} className={css.container}> <FormInput.Text name="projectId" label={getString('pipelineSteps.projectIDLabel')} /> <FormInput.Text name="region" label={getString('regionLabel')} /> <FormInput.Text name="keyRing" label={getString('connectors.gcpKms.keyRing')} /> <FormInput.Text name="keyName" label={getString('connectors.gcpKms.keyName')} /> <SecretInput name="credentials" label={getString('connectors.gcpKms.credentialsFile')} type="SecretFile" connectorTypeContext={Connectors.GCP_KMS} /> <FormInput.CheckBox name="default" label={getString('connectors.hashiCorpVault.defaultVault')} padding={{ left: 'xxlarge' }} /> </Container> <Layout.Horizontal spacing="medium"> <Button text={getString('back')} onClick={() => previousStep?.(prevStepData)} /> <Button type="submit" intent="primary" rightIcon="chevron-right" text={getString('continue')} /> </Layout.Horizontal> </FormikForm> </Formik> </Container> ) } export default GcpKmsConfig |