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 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | 117x 117x 117x 117x 117x 117x 117x 117x 117x 117x 117x 117x 117x 117x 117x 117x 117x 117x 117x 288x 117x 18x 117x 98x 91x 91x 91x 91x 91x 22x 91x 30x 91x 60x 91x 30x 91x 14x 91x | /* * 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 { isEmpty, startCase } from 'lodash-es' import cx from 'classnames' import { Container, Layout, MultiTypeInputType, Text } from '@wings-software/uicore' import { Color } from '@harness/design-system' import { useStrings } from 'framework/strings' import type { StringsMap } from 'stringTypes' import { FormMultiTypeCheckboxField } from '@common/components/MultiTypeCheckbox/MultiTypeCheckbox' import { MultiTypeTextField, MultiTypeTextProps } from '@common/components/MultiTypeText/MultiTypeText' import MultiTypeMap from '@common/components/MultiTypeMap/MultiTypeMap' import { MultiTypeMapInputSet } from '@common/components/MultiTypeMapInputSet/MultiTypeMapInputSet' import MultiTypeList from '@common/components/MultiTypeList/MultiTypeList' import { MultiTypeListInputSet } from '@common/components/MultiTypeListInputSet/MultiTypeListInputSet' import { useVariablesExpression } from '@pipeline/components/PipelineStudio/PiplineHooks/useVariablesExpression' import { StepViewType } from '@pipeline/components/AbstractSteps/Step' import { MultiTypeSelectField } from '@common/components/MultiTypeSelect/MultiTypeSelect' import { ArchiveFormatOptions } from '../../../constants/Constants' import { AllMultiTypeInputTypesForInputSet, AllMultiTypeInputTypesForStep } from './StepUtils' import css from '@pipeline/components/PipelineSteps/Steps/Steps.module.scss' interface CIStepOptionalConfigProps { readonly?: boolean enableFields: { [key: string]: { [key: string]: any } } stepViewType: StepViewType path?: string formik?: any isInputSetView?: boolean allowableTypes?: MultiTypeInputType[] } export const getOptionalSubLabel = ( getString: (key: keyof StringsMap, vars?: Record<string, any> | undefined) => string, tooltip?: string ) => ( <Text tooltipProps={tooltip ? { dataTooltipId: tooltip } : {}} className={css.inpLabel} color={Color.GREY_400} font={{ size: 'small', weight: 'semi-bold' }} style={{ textTransform: 'capitalize' }} > {getString?.('common.optionalLabel')} </Text> ) export const renderMultiTypeListInputSet = ({ name, tooltipId, labelKey, placeholderKey, withObjectStructure, keyName, allowedTypes, expressions, getString, readonly, formik }: { name: string tooltipId: string labelKey: keyof StringsMap placeholderKey?: keyof StringsMap withObjectStructure?: boolean keyName?: string allowedTypes: MultiTypeInputType[] expressions: string[] getString: (key: keyof StringsMap, vars?: Record<string, any> | undefined) => string readonly?: boolean formik?: any }) => ( <MultiTypeListInputSet name={name} multiTextInputProps={{ allowableTypes: allowedTypes, expressions }} multiTypeFieldSelectorProps={{ label: ( <Layout.Horizontal flex={{ justifyContent: 'flex-start', alignItems: 'baseline' }}> <Text style={{ display: 'flex', alignItems: 'center' }} className={css.inpLabel} color={Color.GREY_800} font={{ size: 'small', weight: 'semi-bold' }} > {getString(labelKey)} </Text> {getOptionalSubLabel(getString, tooltipId)} </Layout.Horizontal> ), allowedTypes: allowedTypes }} placeholder={placeholderKey ? getString(placeholderKey) : ''} disabled={readonly} formik={formik} withObjectStructure={withObjectStructure} keyName={keyName} /> ) export const CIStepOptionalConfig: React.FC<CIStepOptionalConfigProps> = props => { const { readonly, enableFields, stepViewType, path, formik, isInputSetView } = props const { getString } = useStrings() const { expressions } = useVariablesExpression() const prefix = isEmpty(path) ? '' : `${path}.` const stepCss = stepViewType === StepViewType.DeploymentForm ? css.sm : css.lg const renderMultiTypeMap = React.useCallback( ({ fieldName, stringKey, tooltipId, allowableTypes, keyLabel, valueLabel, restrictToSingleEntry }: { fieldName: string stringKey: keyof StringsMap tooltipId?: string allowableTypes: MultiTypeInputType[] keyLabel?: keyof StringsMap valueLabel?: keyof StringsMap restrictToSingleEntry?: boolean }): React.ReactElement => ( <Container className={cx(css.formGroup, css.bottomMargin5, css.lg)}> <MultiTypeMap name={fieldName} valueMultiTextInputProps={{ expressions, allowableTypes }} multiTypeFieldSelectorProps={{ label: ( <Layout.Horizontal flex={{ justifyContent: 'flex-start', alignItems: 'baseline' }}> <Text style={{ display: 'flex', alignItems: 'center' }} className={css.inpLabel} color={Color.GREY_800} font={{ size: 'small', weight: 'semi-bold' }} > {getString(stringKey)} </Text> {getOptionalSubLabel(getString, tooltipId)} </Layout.Horizontal> ) }} disabled={readonly} keyLabel={keyLabel ? getString(keyLabel) : ''} valueLabel={valueLabel ? getString(valueLabel) : ''} restrictToSingleEntry={restrictToSingleEntry} /> </Container> ), [expressions] ) const renderMultiTypeMapInputSet = React.useCallback( ( fieldName: string, stringKey: keyof StringsMap, tooltipId: string, keyLabel?: keyof StringsMap, valueLabel?: keyof StringsMap, restrictToSingleEntry?: boolean ): React.ReactElement => ( <Container className={cx(css.formGroup, css.bottomMargin5)}> <MultiTypeMapInputSet name={fieldName} valueMultiTextInputProps={{ allowableTypes: [MultiTypeInputType.EXPRESSION, MultiTypeInputType.FIXED], expressions }} multiTypeFieldSelectorProps={{ label: ( <Layout.Horizontal flex={{ justifyContent: 'flex-start', alignItems: 'baseline' }}> <Text className={css.inpLabel} color={Color.GREY_600} font={{ size: 'small', weight: 'semi-bold' }}> {getString(stringKey)} </Text> {getOptionalSubLabel(getString, tooltipId)} </Layout.Horizontal> ), allowedTypes: [MultiTypeInputType.FIXED] }} disabled={readonly} formik={formik} keyLabel={keyLabel ? getString(keyLabel) : ''} valueLabel={valueLabel ? getString(valueLabel) : ''} restrictToSingleEntry={restrictToSingleEntry} /> </Container> ), [expressions] ) const renderMultiTypeTextField = React.useCallback( ({ name, tooltipId, labelKey, inputProps }: { name: string tooltipId: string labelKey: keyof StringsMap inputProps: MultiTypeTextProps['multiTextInputProps'] }) => ( <MultiTypeTextField name={name} label={ <Layout.Horizontal flex={{ justifyContent: 'flex-start', alignItems: 'baseline' }}> <Text margin={{ top: 'small' }} className={css.inpLabel} color={Color.GREY_600} font={{ size: 'small', weight: 'semi-bold' }} > {getString(labelKey)} </Text> {getOptionalSubLabel(getString, tooltipId)} </Layout.Horizontal> } multiTextInputProps={inputProps} /> ), [] ) const renderMultiTypeCheckboxField = React.useCallback( ({ name, tooltipId, labelKey, allowableTypes }: { name: string tooltipId: string labelKey: keyof StringsMap allowableTypes: MultiTypeInputType[] }) => ( <FormMultiTypeCheckboxField name={name} label={getString(labelKey).concat(` (${startCase(getString('common.optionalLabel'))})`)} multiTypeTextbox={{ expressions, allowableTypes, disabled: readonly }} tooltipProps={{ dataTooltipId: tooltipId }} disabled={readonly} /> ), [expressions] ) const renderMultiTypeList = React.useCallback( ({ name, tooltipId, labelKey, placeholderKey, allowedTypes }: { name: string tooltipId?: string labelKey: keyof StringsMap placeholderKey?: keyof StringsMap allowedTypes?: MultiTypeInputType[] }) => ( <MultiTypeList name={name} placeholder={placeholderKey ? getString(placeholderKey) : ''} multiTextInputProps={{ expressions }} multiTypeFieldSelectorProps={{ label: ( <Layout.Horizontal flex={{ justifyContent: 'flex-start', alignItems: 'baseline' }}> <Text style={{ display: 'flex', alignItems: 'center' }} className={css.inpLabel} color={Color.GREY_800} font={{ size: 'small', weight: 'semi-bold' }} > {getString(labelKey)} </Text> {getOptionalSubLabel(getString, tooltipId)} </Layout.Horizontal> ), allowedTypes: allowedTypes }} disabled={readonly} /> ), [expressions] ) return ( <> {/* Tag is not an optional configuration but due to some weird error, it's being placed here for time being till real reason is figured out.*/} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.tags') ? ( <Container className={cx(css.formGroup, css.bottomMargin5, css.md)}> <MultiTypeListInputSet name={`${prefix}spec.tags`} multiTextInputProps={{ allowableTypes: [MultiTypeInputType.EXPRESSION, MultiTypeInputType.FIXED], expressions }} multiTypeFieldSelectorProps={{ label: ( <Text className={css.inpLabel} color={Color.GREY_600} font={{ size: 'small', weight: 'semi-bold' }} tooltipProps={{ dataTooltipId: 'tags' }} > {getString('tagsLabel')} </Text> ), allowedTypes: [MultiTypeInputType.FIXED] }} disabled={readonly} formik={formik} /> </Container> ) : null} {!enableFields['spec.privileged']?.shouldHide && Object.prototype.hasOwnProperty.call(enableFields, 'spec.privileged') ? ( <div className={cx(css.formGroup, css.sm)}> {renderMultiTypeCheckboxField({ name: `${prefix}spec.privileged`, tooltipId: 'privileged', labelKey: 'pipeline.buildInfra.privileged', allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep })} </div> ) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.settings') ? isInputSetView ? renderMultiTypeMapInputSet(`${prefix}spec.settings`, 'settingsLabel', 'pluginSettings') : renderMultiTypeMap({ fieldName: `${prefix}spec.settings`, stringKey: 'settingsLabel', allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep }) : null} {/* Input Set render for Report Paths is handled in respective steps itself and not handled here due to a technical limitation */} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.reportPaths') && (!isInputSetView ? ( <Container className={cx(css.formGroup, stepCss, css.bottomMargin5)}> {renderMultiTypeList({ name: `${prefix}spec.reportPaths`, placeholderKey: 'pipelineSteps.reportPathsPlaceholder', labelKey: 'pipelineSteps.reportPathsLabel', allowedTypes: AllMultiTypeInputTypesForStep })} </Container> ) : null)} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.envVariables') ? isInputSetView ? renderMultiTypeMapInputSet(`${prefix}spec.envVariables`, 'environmentVariables', '') : renderMultiTypeMap({ fieldName: `${prefix}spec.envVariables`, stringKey: 'environmentVariables', allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep }) : null} {/* Input Set render for Report Paths is handled in respective steps itself and not handled here due to a technical limitation */} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.outputVariables') && (!isInputSetView ? ( <Container className={cx(css.formGroup, stepCss, css.bottomMargin5)}> {renderMultiTypeList({ name: `${prefix}spec.outputVariables`, labelKey: 'pipelineSteps.outputVariablesLabel', allowedTypes: AllMultiTypeInputTypesForStep })} </Container> ) : null)} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.entrypoint') ? ( <Container className={cx(css.formGroup, stepCss, css.bottomMargin5)}> {renderMultiTypeList({ name: `${prefix}spec.entrypoint`, labelKey: 'entryPointLabel', tooltipId: 'dependencyEntryPoint', allowedTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep })} </Container> ) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.args') ? ( <Container className={cx(css.formGroup, stepCss, css.bottomMargin5)}> {renderMultiTypeList({ name: `${prefix}spec.args`, labelKey: 'argsLabel', tooltipId: 'dependencyArgs', allowedTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep })} </Container> ) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.portBindings') ? isInputSetView ? renderMultiTypeMapInputSet( `${prefix}spec.portBindings`, 'ci.portBindings', 'portBindings', 'ci.hostPort', 'ci.containerPort', true ) : renderMultiTypeMap({ fieldName: `${prefix}spec.portBindings`, stringKey: 'ci.portBindings', tooltipId: 'portBindings', allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep, keyLabel: 'ci.hostPort', valueLabel: 'ci.containerPort', restrictToSingleEntry: true }) : null} {!enableFields['spec.optimize']?.shouldHide && Object.prototype.hasOwnProperty.call(enableFields, 'spec.optimize') ? ( <div className={cx(css.formGroup, css.sm, css.bottomMargin5)}> {renderMultiTypeCheckboxField({ name: `${prefix}spec.optimize`, tooltipId: 'optimize', labelKey: 'ci.optimize', allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep })} </div> ) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.dockerfile') ? ( <Container className={cx(css.formGroup, stepCss, css.bottomMargin5)}> {renderMultiTypeTextField({ name: `${prefix}spec.dockerfile`, tooltipId: 'dockerfile', labelKey: 'pipelineSteps.dockerfileLabel', inputProps: { multiTextInputProps: { expressions, allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep }, disabled: readonly } })} </Container> ) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.context') ? ( <Container className={cx(css.formGroup, stepCss, css.bottomMargin5)}> {renderMultiTypeTextField({ name: `${prefix}spec.context`, tooltipId: 'context', labelKey: 'pipelineSteps.contextLabel', inputProps: { multiTextInputProps: { expressions, allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep }, disabled: readonly } })} </Container> ) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.labels') ? isInputSetView ? renderMultiTypeMapInputSet(`${prefix}spec.labels`, 'pipelineSteps.labelsLabel', '') : renderMultiTypeMap({ fieldName: `${prefix}spec.labels`, stringKey: 'pipelineSteps.labelsLabel', allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep }) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.buildArgs') ? isInputSetView ? renderMultiTypeMapInputSet(`${prefix}spec.buildArgs`, 'pipelineSteps.buildArgsLabel', '') : renderMultiTypeMap({ fieldName: `${prefix}spec.buildArgs`, stringKey: 'pipelineSteps.buildArgsLabel', allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep }) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.endpoint') ? ( <Container className={cx(css.formGroup, stepCss, css.bottomMargin5)}> {renderMultiTypeTextField({ name: `${prefix}spec.endpoint`, tooltipId: 'endpoint', labelKey: 'pipelineSteps.endpointLabel', inputProps: { placeholder: getString('pipelineSteps.endpointPlaceholder'), multiTextInputProps: { expressions, allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep }, disabled: readonly } })} </Container> ) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.target') ? ( <Container className={cx(css.formGroup, stepCss, css.bottomMargin5)}> {renderMultiTypeTextField({ name: `${prefix}spec.target`, tooltipId: enableFields['spec.target'].tooltipId, labelKey: 'pipelineSteps.targetLabel', inputProps: { placeholder: getString('pipelineSteps.artifactsTargetPlaceholder'), multiTextInputProps: { expressions, allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep }, disabled: readonly } })} </Container> ) : null} {!enableFields['spec.remoteCacheImage']?.shouldHide && Object.prototype.hasOwnProperty.call(enableFields, 'spec.remoteCacheImage') ? ( <Container className={cx(css.formGroup, stepCss, css.bottomMargin5)}> {renderMultiTypeTextField({ name: `${prefix}spec.remoteCacheImage`, tooltipId: 'gcrRemoteCache', labelKey: 'ci.remoteCacheImage.label', inputProps: { multiTextInputProps: { expressions, allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep }, disabled: readonly } })} </Container> ) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.archiveFormat') ? ( <Container className={cx(css.formGroup, stepCss, css.bottomMargin5)}> <MultiTypeSelectField name={`${prefix}spec.archiveFormat`} label={ <Layout.Horizontal flex={{ justifyContent: 'flex-start', alignItems: 'baseline' }}> <Text margin={{ top: 'small' }} className={css.inpLabel} color={Color.GREY_600} font={{ size: 'small', weight: 'semi-bold' }} > {getString('archiveFormat')} </Text> {getOptionalSubLabel(getString, 'archiveFormat')} </Layout.Horizontal> } multiTypeInputProps={{ selectItems: ArchiveFormatOptions, multiTypeInputProps: { expressions, allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : [MultiTypeInputType.FIXED, MultiTypeInputType.EXPRESSION] }, disabled: readonly }} disabled={readonly} /> </Container> ) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.override') ? ( <div className={cx(css.formGroup, css.sm, css.bottomMargin5)}> {renderMultiTypeCheckboxField({ name: `${prefix}spec.override`, tooltipId: 'saveCacheOverride', labelKey: 'override', allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep })} </div> ) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.pathStyle') ? ( <div className={cx(css.formGroup, css.sm)}> {renderMultiTypeCheckboxField({ name: `${prefix}spec.pathStyle`, tooltipId: 'pathStyle', labelKey: 'pathStyle', allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep })} </div> ) : null} {Object.prototype.hasOwnProperty.call(enableFields, 'spec.failIfKeyNotFound') ? ( <div className={cx(css.formGroup, css.sm, css.bottomMargin5)}> {renderMultiTypeCheckboxField({ name: `${prefix}spec.failIfKeyNotFound`, tooltipId: 'failIfKeyNotFound', labelKey: 'failIfKeyNotFound', allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep })} </div> ) : null} {!enableFields['spec.remoteCacheRepo']?.shouldHide && Object.prototype.hasOwnProperty.call(enableFields, 'spec.remoteCacheRepo') ? ( <Container className={cx(css.formGroup, stepCss, css.bottomMargin5)}> {renderMultiTypeTextField({ name: `${prefix}spec.remoteCacheRepo`, tooltipId: 'dockerHubRemoteCache', labelKey: 'ci.remoteCacheRepository.label', inputProps: { multiTextInputProps: { expressions, allowableTypes: isInputSetView ? AllMultiTypeInputTypesForInputSet : AllMultiTypeInputTypesForStep }, disabled: readonly } })} </Container> ) : null} </> ) } |