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 | 101x 101x 101x 101x 101x 101x 101x 13x 13x 3x 13x 13x 13x 9x 4x 13x 1x 101x | /*
* 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 { StepWizard, Icon, MultiTypeInputType } from '@wings-software/uicore'
import type { IconProps } from '@wings-software/uicore/dist/icons/Icon'
import { String, StringKeys, useStrings } from 'framework/strings'
import { ArtifactoryRepoType } from '../ArtifactRepository/ArtifactoryRepoType'
import { ArtifactConnector } from '../ArtifactRepository/ArtifactConnector'
import type { InitialArtifactDataType, ConnectorRefLabelType, ArtifactType } from '../ArtifactInterface'
import { ArtifactTitleIdByType } from '../ArtifactHelper'
import css from './ArtifactWizard.module.scss'
interface StepChangeData<SharedObject> {
prevStep?: number
nextStep?: number
prevStepData: SharedObject
}
interface ArtifactWizardProps {
handleViewChange: (isConnectorView: boolean) => void
artifactInitialValue: InitialArtifactDataType
types: Array<ArtifactType>
lastSteps: JSX.Element
newConnectorSteps?: any
expressions: string[]
labels: ConnectorRefLabelType
selectedArtifact: ArtifactType | null
changeArtifactType: (data: ArtifactType | null) => void
newConnectorView: boolean
iconsProps: IconProps | undefined
isReadonly: boolean
allowableTypes: MultiTypeInputType[]
showConnectorStep: boolean
}
function ArtifactWizard({
types,
labels,
expressions,
allowableTypes,
selectedArtifact,
changeArtifactType,
handleViewChange,
artifactInitialValue,
newConnectorView,
newConnectorSteps,
lastSteps,
iconsProps,
showConnectorStep,
isReadonly
}: ArtifactWizardProps): React.ReactElement {
const { getString } = useStrings()
const onStepChange = (arg: StepChangeData<any>): void => {
Iif (arg?.prevStep && arg?.nextStep && arg.prevStep > arg.nextStep && arg.nextStep <= 2) {
handleViewChange(false)
}
}
const renderSubtitle = (): JSX.Element | undefined => {
const stringId = selectedArtifact && ArtifactTitleIdByType[selectedArtifact]
if (selectedArtifact) {
return (
<div className={css.subtitle} style={{ display: 'flex' }}>
<Icon size={26} {...(iconsProps as IconProps)} />
<String
style={{ alignSelf: 'center', marginLeft: 'var(--spacing-small)' }}
stringID={stringId as StringKeys}
/>
</div>
)
}
return undefined
}
return (
<StepWizard className={css.existingDocker} subtitle={renderSubtitle()} onStepChange={onStepChange}>
<ArtifactoryRepoType
artifactTypes={types}
name={getString('connectors.artifactRepoType')}
stepName={labels.firstStepName}
selectedArtifact={selectedArtifact}
artifactInitialValue={artifactInitialValue}
changeArtifactType={changeArtifactType}
/>
{showConnectorStep && (
<ArtifactConnector
name={getString('connectors.artifactRepository')}
stepName={labels.secondStepName}
expressions={expressions}
isReadonly={isReadonly}
handleViewChange={() => handleViewChange(true)}
initialValues={artifactInitialValue}
selectedArtifact={selectedArtifact}
allowableTypes={allowableTypes}
/>
)}
{newConnectorView ? newConnectorSteps : null}
{lastSteps}
</StepWizard>
)
}
export default ArtifactWizard
|