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 | 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 26x 22x 20x 20x 8x | /*
* 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 { Card, MultiTypeInputType, NestedAccordionPanel, Text } from '@wings-software/uicore'
import cx from 'classnames'
import { FontVariation, Color } from '@harness/design-system'
import { isEmpty, lowerCase } from 'lodash-es'
import type { PipelineInfoConfig } from 'services/cd-ng'
import { StepType } from '@pipeline/components/PipelineSteps/PipelineStepInterface'
import { StepWidget } from '@pipeline/components/AbstractSteps/StepWidget'
import { StepViewType } from '@pipeline/components/AbstractSteps/Step'
import type { AbstractStepFactory } from '@pipeline/components/AbstractSteps/AbstractStepFactory'
import type {
CustomVariableEditableExtraProps,
CustomVariablesData
} from '@pipeline/components/PipelineSteps/Steps/CustomVariables/CustomVariableEditable'
import { useStrings } from 'framework/strings'
import { VariablesListTable } from '@pipeline/components/VariablesListTable/VariablesListTable'
import type { AllNGVariables } from '@pipeline/utils/types'
import VariableListTagRow from '@pipeline/components/VariablesListTable/VariableListTagRow'
import VariableAccordionSummary from '../VariableAccordionSummary'
import type { PipelineVariablesData } from '../types'
import css from '../PipelineVariables.module.scss'
export interface PipelineCardProps {
variablePipeline: PipelineInfoConfig
pipeline: PipelineInfoConfig
stepsFactory: AbstractStepFactory
metadataMap: PipelineVariablesData['metadataMap']
updatePipeline(pipeline: PipelineInfoConfig): void
readonly?: boolean
allowableTypes: MultiTypeInputType[]
}
export default function PipelineCard(props: PipelineCardProps): React.ReactElement {
const { variablePipeline, pipeline, metadataMap, stepsFactory, updatePipeline, readonly, allowableTypes } = props
const { getString } = useStrings()
return (
<Card className={css.variableCard} id="Pipeline-panel">
<VariablesListTable
data={variablePipeline}
className={css.variablePaddingL0}
originalData={pipeline}
metadataMap={metadataMap}
/>
{!isEmpty(variablePipeline?.tags) && (
<VariableListTagRow
metadataMap={metadataMap}
name={lowerCase(getString('tagsLabel'))}
tags={variablePipeline.tags}
fqn="pipeline.tags"
className={css.variablePaddingTagL0}
/>
)}
<NestedAccordionPanel
noAutoScroll
isDefaultOpen
key={`pipeline.variables`}
id={`pipeline.variables`}
addDomId
collapseProps={{
keepChildrenMounted: true
}}
summary={
<VariableAccordionSummary>
<Text font={{ variation: FontVariation.SMALL_SEMI }} color={Color.BLACK}>
{getString('customVariables.title')}
</Text>
</VariableAccordionSummary>
}
summaryClassName={css.variableBorderBottom}
details={
<StepWidget<CustomVariablesData, CustomVariableEditableExtraProps>
factory={stepsFactory}
initialValues={{ variables: (pipeline.variables || []) as AllNGVariables[], canAddVariable: true }}
type={StepType.CustomVariable}
stepViewType={StepViewType.InputVariable}
readonly={readonly}
allowableTypes={allowableTypes}
onUpdate={({ variables }: CustomVariablesData) => {
updatePipeline({ ...pipeline, variables })
}}
customStepProps={{
formName: 'addEditPipelineCustomVariableForm',
variableNamePrefix: 'pipeline.variables.',
domId: 'Pipeline.Variables-panel',
className: cx(css.customVariables, css.customVarPadL1, css.addVariableL1),
// heading: <b>{getString('customVariables.title')}</b>,
path: 'pipeline.variables',
yamlProperties: (variablePipeline.variables as AllNGVariables[])?.map(
variable => metadataMap[variable.value || '']?.yamlProperties || {}
)
}}
/>
}
/>
</Card>
)
}
|