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 | 26x 26x 26x 26x 26x 26x 26x 26x 26x 41x 41x 41x 41x 26x 41x 41x 41x 41x 41x 41x 41x | /* * 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 from 'react' import { MultiTypeInputType, NestedAccordionPanel, Text } from '@wings-software/uicore' import { Color, FontVariation } from '@harness/design-system' import { get } from 'lodash-es' import type { DeploymentStageConfig, ExecutionElementConfig, Infrastructure, StageElementConfig } from 'services/cd-ng' import { useStrings } from 'framework/strings' import { VariablesListTable } from '@pipeline/components/VariablesListTable/VariablesListTable' import { InfrastructureCardPanel } from '@pipeline/components/PipelineStudio/PipelineVariables/Cards/InfrastructureCard' import type { AbstractStepFactory } from '@pipeline/components/AbstractSteps/AbstractStepFactory' import VariableAccordionSummary from '../VariableAccordionSummary' import type { PipelineVariablesData } from '../types' import css from '../PipelineVariables.module.scss' export interface EnvironmentCardProps { stage: StageElementConfig originalStage: StageElementConfig metadataMap: PipelineVariablesData['metadataMap'] path?: string readonly?: boolean allowableTypes: MultiTypeInputType[] stepsFactory: AbstractStepFactory onUpdateInfrastructure: (data: Infrastructure) => void onUpdateInfrastructureProvisioner: (data: ExecutionElementConfig) => void } function EnvironmentCard(props: EnvironmentCardProps) { const { stage, originalStage, metadataMap, readonly, path, allowableTypes, stepsFactory, onUpdateInfrastructure, onUpdateInfrastructureProvisioner } = props const stageSpec = stage.spec as DeploymentStageConfig const originalSpec = originalStage.spec as DeploymentStageConfig return ( <> {stageSpec?.infrastructure?.environmentRef && originalSpec?.infrastructure?.environmentRef ? ( <VariablesListTable data={get(stageSpec, 'infrastructure')} className={css.variablePaddingL0} originalData={get(originalSpec, 'infrastructure')} metadataMap={metadataMap} /> ) : null} {stageSpec.infrastructure && originalSpec.infrastructure ? ( <InfrastructureCardPanel infrastructure={stageSpec.infrastructure} originalInfrastructure={originalSpec.infrastructure} metadataMap={metadataMap} stageIdentifier={originalStage.identifier} readonly={readonly} allowableTypes={allowableTypes} path={`${path}.${originalStage.identifier}.Infrastructure`} onUpdateInfrastructure={onUpdateInfrastructure} onUpdateInfrastructureProvisioner={onUpdateInfrastructureProvisioner} stepsFactory={stepsFactory} /> ) : /* istanbul ignore next */ null} </> ) } export function EnvironmentCardPanel(props: EnvironmentCardProps) { const { getString } = useStrings() const { stage, originalStage } = props const stageSpec = stage.spec as DeploymentStageConfig const originalSpec = originalStage.spec as DeploymentStageConfig const renderEnvironmentCardPanel = (stageSpec?.infrastructure?.environmentRef && originalSpec?.infrastructure?.environmentRef) || (stageSpec.infrastructure && originalSpec.infrastructure) Iif (!renderEnvironmentCardPanel) { return null } return ( <NestedAccordionPanel noAutoScroll isDefaultOpen addDomId id={`${props.path}.${originalStage.identifier}.Environment`} summary={ <VariableAccordionSummary> <Text font={{ variation: FontVariation.SMALL_SEMI }} color={Color.BLACK}> {getString('environment')} </Text> </VariableAccordionSummary> } panelClassName={css.panel} summaryClassName={css.accordianSummaryL1} details={<EnvironmentCard {...props} />} collapseProps={{ keepChildrenMounted: true }} /> ) } |