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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | 103x 103x 103x 103x 103x 103x 103x 103x 103x 103x 103x 8x 8x 8x 15x 103x | /* * 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 from 'react' import * as Yup from 'yup' import { Layout, Button, FormInput, Formik, MultiTypeInputType, getMultiTypeFromValue, FormikForm, ButtonVariation } from '@wings-software/uicore' import cx from 'classnames' import { Classes, Dialog } from '@blueprintjs/core' import { useStrings } from 'framework/strings' import { MultiTypeFieldSelector } from '@common/components/MultiTypeFieldSelector/MultiTypeFieldSelector' import { ConfigureOptions } from '@common/components/ConfigureOptions/ConfigureOptions' import type { InlineVar } from '../TerraformInterfaces' import { TFMonaco } from './TFMonacoEditor' import stepCss from '@pipeline/components/PipelineSteps/Steps/Steps.module.scss' interface InlineVarFileProps { arrayHelpers: any isEditMode: boolean selectedVarIndex: number showTfModal: boolean selectedVar: any onClose: () => void onSubmit: () => void isReadonly?: boolean allowableTypes: MultiTypeInputType[] } const InlineVarFile = (props: InlineVarFileProps) => { const { arrayHelpers, isEditMode, selectedVarIndex, onSubmit, selectedVar, onClose, isReadonly = false, allowableTypes } = props const { getString } = useStrings() return ( <Dialog isOpen={true} enforceFocus={false} title="Add Inline Terraform Var File" isCloseButtonShown onClose={onClose} className={Classes.DIALOG} > <Layout.Vertical padding="medium"> <Formik<InlineVar> formName="inlineVarFileForm" initialValues={selectedVar} onSubmit={(values: any) => { /* istanbul ignore next */ if (!isEditMode) { /* istanbul ignore next */ arrayHelpers && arrayHelpers.push(values) } else { /* istanbul ignore next */ arrayHelpers && arrayHelpers.replace(selectedVarIndex, values) } /* istanbul ignore next */ onSubmit() }} validationSchema={Yup.object().shape({ varFile: Yup.object().shape({ identifier: Yup.string().required(getString('common.validation.identifierIsRequired')), spec: Yup.object().shape({ content: Yup.string().required(getString('cd.contentRequired')) }) }) })} > {formikProps => { return ( <FormikForm> <div className={stepCss.formGroup}> <FormInput.Text name="varFile.identifier" label={getString('identifier')} /> </div> <div className={cx(stepCss.formGroup)}> <MultiTypeFieldSelector name="varFile.spec.content" label={getString('pipelineSteps.content')} defaultValueToReset="" allowedTypes={allowableTypes} formik={formikProps} expressionRender={() => { /* istanbul ignore next */ return ( <TFMonaco name="varFile.spec.content" formik={formikProps} title={getString('pipelineSteps.content')} /> ) }} skipRenderValueInExpressionLabel > <TFMonaco name="varFile.spec.content" formik={formikProps} title={getString('pipelineSteps.content')} /> </MultiTypeFieldSelector> {getMultiTypeFromValue(formikProps.values.varFile?.spec?.content) === MultiTypeInputType.RUNTIME && ( <ConfigureOptions style={{ marginTop: 7 }} value={formikProps.values.varFile?.spec?.content as string} type="String" variableName="varFile.spec.content" showRequiredField={false} showDefaultField={false} showAdvanced={true} onChange={value => formikProps.setFieldValue('varFile.spec.content', value)} isReadonly={isReadonly} /> )} </div> <Layout.Horizontal spacing={'medium'} margin={{ top: 'huge' }}> <Button type="submit" variation={ButtonVariation.PRIMARY} data-testid="submit-inlinevar"> {getString('submit')} </Button> </Layout.Horizontal> </FormikForm> ) }} </Formik> </Layout.Vertical> </Dialog> ) } export default InlineVarFile |