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 | 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 24x 24x 24x 24x | /* * 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 { SelectOption, FormInput, getMultiTypeFromValue, MultiTypeInputType } from '@wings-software/uicore' import type { FormikProps } from 'formik' import cx from 'classnames' import { FormMultiTypeTextAreaField } from '@common/components/MultiTypeTextArea/MultiTypeTextArea' import { FormMultiTypeDurationField } from '@common/components/MultiTypeDuration/MultiTypeDuration' import { useStrings } from 'framework/strings' import { ConfigureOptions } from '@common/components/ConfigureOptions/ConfigureOptions' import { useVariablesExpression } from '@pipeline/components/PipelineStudio/PiplineHooks/useVariablesExpression' import { StepViewType } from '@pipeline/components/AbstractSteps/Step' import type { HttpStepFormData } from './types' import css from './HttpStep.module.scss' import stepCss from '@pipeline/components/PipelineSteps/Steps/Steps.module.scss' export const httpStepType: SelectOption[] = [ { value: 'GET', label: 'GET' }, { value: 'POST', label: 'POST' }, { value: 'PUT', label: 'PUT' }, { value: 'DELETE', label: 'DELETE' }, { value: 'HEAD', label: 'HEAD' }, { value: 'OPTIONS', label: 'OPTIONS' } ] export default function HttpStepBase(props: { formik: FormikProps<HttpStepFormData> isNewStep?: boolean readonly?: boolean stepViewType?: StepViewType allowableTypes?: MultiTypeInputType[] }): React.ReactElement { const { getString } = useStrings() const { expressions } = useVariablesExpression() const { formik: { values: formValues, setFieldValue }, isNewStep = true, readonly, stepViewType, allowableTypes } = props return ( <div className={stepCss.stepPanel}> {stepViewType !== StepViewType.Template && ( <div className={cx(stepCss.formGroup, stepCss.lg)}> <FormInput.InputWithIdentifier inputLabel={getString('name')} isIdentifierEditable={isNewStep && !readonly} inputGroupProps={{ placeholder: getString('pipeline.stepNamePlaceholder'), disabled: readonly }} /> </div> )} <div className={cx(stepCss.formGroup, stepCss.sm)}> <FormMultiTypeDurationField name="timeout" label={getString('pipelineSteps.timeoutLabel')} multiTypeDurationProps={{ enableConfigureOptions: false, expressions, disabled: readonly, allowableTypes }} disabled={readonly} /> {getMultiTypeFromValue(formValues.timeout) === MultiTypeInputType.RUNTIME && ( <ConfigureOptions value={formValues.timeout || ''} type="String" variableName="timeout" showRequiredField={false} showDefaultField={false} showAdvanced={true} onChange={value => setFieldValue('timeout', value)} isReadonly={readonly} /> )} </div> <div className={stepCss.divider} /> <div className={stepCss.formGroup}> <FormInput.MultiTextInput name="spec.url" placeholder={getString('pipeline.utilitiesStep.url')} label={getString('UrlLabel')} disabled={readonly} multiTextInputProps={{ expressions, disabled: readonly, allowableTypes }} /> {getMultiTypeFromValue(formValues.spec.url) === MultiTypeInputType.RUNTIME && ( <ConfigureOptions value={formValues.spec.url} type="String" variableName="spec.url" showRequiredField={false} showDefaultField={false} showAdvanced={true} onChange={value => setFieldValue('spec.url', value)} isReadonly={readonly} /> )} </div> <div className={cx(stepCss.formGroup, stepCss.sm)}> <FormInput.MultiTypeInput selectItems={httpStepType} disabled={readonly} multiTypeInputProps={{ expressions, disabled: readonly, allowableTypes }} label={getString('methodLabel')} name="spec.method" /> {getMultiTypeFromValue(formValues.spec.method) === MultiTypeInputType.RUNTIME && ( <ConfigureOptions value={formValues.spec.method as string} type="String" variableName="spec.method" showRequiredField={false} showDefaultField={false} showAdvanced={true} onChange={value => setFieldValue('spec.method', value)} isReadonly={readonly} /> )} </div> <div className={stepCss.formGroup}> <FormMultiTypeTextAreaField placeholder={getString('pipeline.utilitiesStep.requestBody')} name="spec.requestBody" label={getString('requestBodyLabel')} className={css.requestBody} multiTypeTextArea={{ enableConfigureOptions: false, expressions, disabled: readonly, allowableTypes }} /> {getMultiTypeFromValue(formValues.spec.requestBody) === MultiTypeInputType.RUNTIME && ( <ConfigureOptions value={formValues.spec.requestBody} type="String" variableName="spec.requestBody" showRequiredField={false} showDefaultField={false} showAdvanced={true} onChange={value => setFieldValue('spec.requestBody', value)} isReadonly={readonly} /> )} </div> </div> ) } |