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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 13x 13x 13x 13x 13x 5x 5x 13x 5x 9x 5x 13x 8x 13x 8x 8x 105x | /* * Copyright 2022 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 { Layout, Button, FormInput, MultiTypeInputType, getMultiTypeFromValue, ButtonVariation, SelectOption } from '@wings-software/uicore' import cx from 'classnames' import { v4 as nameSpace, v5 as uuid } from 'uuid' import { FieldArray, FormikValues } from 'formik' import { String, useStrings } from 'framework/strings' import MultiTypeFieldSelector from '@common/components/MultiTypeFieldSelector/MultiTypeFieldSelector' import { FormMultiTypeCheckboxField } from '@common/components' import { ConfigureOptions } from '@common/components/ConfigureOptions/ConfigureOptions' import { useHelmCmdFlags } from 'services/cd-ng' import { useDeepCompareEffect } from '@common/hooks' import type { CommandFlags, HelmVersionOptions } from '../ManifestInterface' import helmcss from './HelmWithGIT/HelmWithGIT.module.scss' import css from './ManifestWizardSteps.module.scss' interface HelmAdvancedStepProps { expressions: string[] allowableTypes: MultiTypeInputType[] formik: FormikValues isReadonly?: boolean deploymentType: string helmVersion: HelmVersionOptions helmStore: string } function HelmAdvancedStepSection({ formik, expressions, allowableTypes, isReadonly, deploymentType, helmVersion, helmStore }: HelmAdvancedStepProps): React.ReactElement { const { getString } = useStrings() const defaultValueToReset = [{ commandType: '', flag: '', id: uuid('', nameSpace()) }] const [commandFlagOptions, setCommandFlagOptions] = useState<Record<string, SelectOption[]>>({ V2: [], V3: [] }) const { data: commandFlags, refetch: refetchCommandFlags } = useHelmCmdFlags({ queryParams: { serviceSpecType: deploymentType as string, version: helmVersion, storeType: helmStore }, lazy: true }) useEffect(() => { Eif (!commandFlagOptions[helmVersion]?.length) { refetchCommandFlags() } }, [helmVersion]) useDeepCompareEffect(() => { const commandFlagSelectOption = { ...commandFlagOptions, [helmVersion]: commandFlags?.data?.map(commandFlag => ({ label: commandFlag, value: commandFlag })) } setCommandFlagOptions(commandFlagSelectOption as Record<string, SelectOption[]>) }, [commandFlags?.data]) const commandFlagLabel = (): React.ReactElement => { return ( <Layout.Horizontal flex spacing="small"> <String tagName="div" stringID="pipeline.manifestType.helmCommandFlagLabel" /> </Layout.Horizontal> ) } return ( <div className={helmcss.helmAdvancedSteps}> <Layout.Horizontal width={'90%'} flex={{ justifyContent: 'flex-start', alignItems: 'center' }}> <FormMultiTypeCheckboxField name="skipResourceVersioning" label={getString('skipResourceVersion')} className={cx(helmcss.checkbox, helmcss.halfWidth)} multiTypeTextbox={{ expressions, allowableTypes }} /> {getMultiTypeFromValue(formik.values?.skipResourceVersioning) === MultiTypeInputType.RUNTIME && ( <ConfigureOptions value={(formik.values?.skipResourceVersioning || '') as string} type="String" variableName="skipResourceVersioning" showRequiredField={false} showDefaultField={false} showAdvanced={true} onChange={value => formik.setFieldValue('skipResourceVersioning', value)} style={{ alignSelf: 'center', marginTop: 11 }} className={cx(css.addmarginTop)} isReadonly={isReadonly} /> )} </Layout.Horizontal> {commandFlagOptions[helmVersion]?.length > 0 && ( <div className={helmcss.commandFlags}> <MultiTypeFieldSelector defaultValueToReset={defaultValueToReset} name={'commandFlags'} label={commandFlagLabel()} disableTypeSelection > <FieldArray name="commandFlags" render={({ push, remove }) => ( <Layout.Vertical> {formik.values?.commandFlags?.map((commandFlag: CommandFlags, index: number) => ( <Layout.Horizontal key={commandFlag.id} spacing="xxlarge" margin={{ top: 'small' }}> <div className={helmcss.halfWidth}> <FormInput.Select name={`commandFlags[${index}].commandType`} label={index === 0 ? getString('pipeline.manifestType.helmCommandType') : ''} items={commandFlagOptions[helmVersion]} placeholder={getString('pipeline.manifestType.helmCommandTypePlaceholder')} /> </div> <div className={helmcss.halfWidth}> <Layout.Horizontal flex={{ justifyContent: 'flex-start', alignItems: 'flex-start' }}> <FormInput.Text label={index === 0 ? getString('flag') : ''} name={`commandFlags[${index}].flag`} /> {getMultiTypeFromValue(formik.values?.commandFlags?.[index]?.flag) === MultiTypeInputType.RUNTIME && ( <div className={cx({ [css.addmarginTop]: index === 0 })} > <ConfigureOptions style={{ marginBottom: 3 }} value={(formik.values?.commandFlags?.[index].flag || '') as unknown as string} type="String" variableName={`CommandFlag-${index}`} showRequiredField={false} showDefaultField={false} showAdvanced={true} onChange={value => formik.setFieldValue(`formik.values?.commandFlags?.[${index}].flag`, value) } isReadonly={isReadonly} /> </div> )} {index !== 0 && ( <Button minimal icon="main-trash" className={cx({ [helmcss.delBtn]: index === 0 })} onClick={() => remove(index)} /> )} </Layout.Horizontal> </div> </Layout.Horizontal> ))} {!!(formik.values?.commandFlags?.length < commandFlagOptions[helmVersion].length) && ( <span> <Button minimal text={getString('add')} variation={ButtonVariation.PRIMARY} onClick={() => push({ commandType: '', flag: '', id: uuid('', nameSpace()) })} /> </span> )} </Layout.Vertical> )} /> </MultiTypeFieldSelector> </div> )} </div> ) } export default HelmAdvancedStepSection |