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 | 206x 206x 206x 206x 206x 206x 206x 206x 206x 650x 513x 513x 206x 4993x 4993x 4993x 14826x 449x 8x 5024x 14x 5x 4954x 4943x 4942x 102x | /*
* 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 type { IconName, MultiTypeInputType } from '@wings-software/uicore'
import type { FormikErrors, FormikProps } from 'formik'
import type { CompletionItemInterface } from '@common/interfaces/YAMLBuilderProps'
import type { UseStringsReturn } from 'framework/strings'
import type { StringsMap } from 'stringTypes'
import type { AbstractStepFactory } from './AbstractStepFactory'
import type { StepType } from '../PipelineSteps/PipelineStepInterface'
export enum StepViewType {
InputSet = 'InputSet',
InputVariable = 'InputVariable',
DeploymentForm = 'DeploymentForm',
TriggerForm = 'TriggerForm',
StageVariable = 'StageVariable',
Edit = 'Edit',
Template = 'Template'
}
export interface InputSetData<T> {
template?: T
allValues?: T
path: string
readonly?: boolean
}
export interface ValidateInputSetProps<T> {
data: T
template?: T
getString?: UseStringsReturn['getString']
viewType: StepViewType
}
export type StepFormikRef<T> = Pick<FormikProps<T>, 'submitForm' | 'errors'>
export type StepFormikFowardRef<T = unknown> =
| ((instance: StepFormikRef<T> | null) => void)
| React.MutableRefObject<StepFormikRef<T> | null>
| null
export interface StepProps<T, U = unknown> {
initialValues: T
onUpdate?: (data: T) => void
onChange?: (data: T) => void
isNewStep?: boolean
stepViewType?: StepViewType
inputSetData?: InputSetData<T>
factory: AbstractStepFactory
path: string
readonly?: boolean
formikRef?: StepFormikFowardRef<T>
customStepProps?: U
allowableTypes: MultiTypeInputType[]
}
export function setFormikRef<T = unknown, U = unknown>(ref: StepFormikFowardRef<T>, formik: FormikProps<U>): void {
if (!ref) return
Iif (typeof ref === 'function') {
return
}
ref.current = formik as unknown as FormikProps<T>
}
export abstract class Step<T> {
protected abstract type: StepType
protected abstract defaultValues: T
protected abstract stepIcon: IconName
protected stepIconColor?: string
protected abstract stepName: string
protected stepDescription: keyof StringsMap | undefined
protected _hasStepVariables = false
protected _hasDelegateSelectionVisible = false
protected isHarnessSpecific = false
protected invocationMap?: Map<
RegExp,
(path: string, yaml: string, params: Record<string, unknown>) => Promise<CompletionItemInterface[]>
>
abstract validateInputSet(args: ValidateInputSetProps<T>): FormikErrors<T>
protected stepPaletteVisible?: boolean // default to true
getType(): string {
return this.type
}
getDefaultValues(initialValues: T, _stepViewType: StepViewType): T {
return { ...this.defaultValues, ...initialValues }
}
getIsHarnessSpecific(): boolean {
return this.isHarnessSpecific
}
getIconName(): IconName {
return this.stepIcon
}
getIconColor(): string | undefined {
return this.stepIconColor
}
getDescription(): keyof StringsMap | undefined {
return this.stepDescription
}
getStepName(): string {
return this.stepName
}
getInvocationMap():
| Map<RegExp, (path: string, yaml: string, params: Record<string, unknown>) => Promise<CompletionItemInterface[]>>
| undefined {
return this.invocationMap
}
getStepPaletteVisibility(): boolean {
return this.stepPaletteVisible ?? true
}
get hasDelegateSelectionVisible(): boolean {
return this._hasDelegateSelectionVisible
}
get hasStepVariables(): boolean {
return this._hasStepVariables
}
abstract renderStep(props: StepProps<T>): JSX.Element
}
|