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 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | /*
* 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 { useHistory, useParams } from 'react-router-dom'
import factory from '@pipeline/components/PipelineSteps/PipelineStepFactory'
import { stagesCollection } from '@pipeline/components/PipelineStudio/Stages/StagesCollection'
import routes from '@common/RouteDefinitions'
import { useFeatureFlag } from '@common/hooks/useFeatureFlag'
import type {
AccountPathProps,
GitQueryParams,
PipelinePathProps,
PipelineType
} from '@common/interfaces/RouteInterfaces'
import { getCDPipelineStages } from '@cd/components/PipelineStudio/CDPipelineStagesUtils'
import { useStrings } from 'framework/strings'
import { PipelineProvider } from '@pipeline/components/PipelineStudio/PipelineContext/PipelineContext'
import { PipelineStudio } from '@pipeline/components/PipelineStudio/PipelineStudio'
import { TemplateDrawer } from '@templates-library/components/TemplateDrawer/TemplateDrawer'
import { getCDTrialDialog } from '@cd/modals/CDTrial/useCDTrialModal'
import { TrialType } from '@pipeline/components/TrialModalTemplate/trialModalUtils'
import type { PipelineInfoConfig } from 'services/cd-ng'
import { useQueryParams } from '@common/hooks'
import { useLicenseStore } from 'framework/LicenseStore/LicenseStoreContext'
import { FeatureFlag } from '@common/featureFlags'
import type { ModuleLicenseType } from '@common/constants/SubscriptionTypes'
import css from './CDPipelineStudio.module.scss'
const CDPipelineStudio: React.FC = (): JSX.Element => {
const { accountId, projectIdentifier, orgIdentifier, pipelineIdentifier, module } =
useParams<PipelineType<PipelinePathProps & AccountPathProps>>()
const { branch, repoIdentifier } = useQueryParams<GitQueryParams>()
const history = useHistory()
const getTrialPipelineCreateForm = (
onSubmit: (values: PipelineInfoConfig) => void,
onClose: () => void
): React.ReactElement => {
return getCDTrialDialog({
actionProps: { onSuccess: onSubmit },
trialType: TrialType.SET_UP_PIPELINE,
onCloseModal: onClose
})
}
const { modal } = useQueryParams<{ modal?: ModuleLicenseType }>()
const getOtherModal = modal ? getTrialPipelineCreateForm : undefined
const handleRunPipeline = (): void => {
history.push(
routes.toPipelineStudio({
accountId,
orgIdentifier,
projectIdentifier,
pipelineIdentifier,
module,
branch,
repoIdentifier,
runPipeline: true
})
)
}
const { licenseInformation } = useLicenseStore()
const isCFEnabled = useFeatureFlag(FeatureFlag.CFNG_ENABLED)
const isCIEnabled = useFeatureFlag(FeatureFlag.CING_ENABLED)
const isCDEnabled = useFeatureFlag(FeatureFlag.CDNG_ENABLED)
const isSTOEnabled = useFeatureFlag(FeatureFlag.SECURITY_STAGE)
const { getString } = useStrings()
return (
<PipelineProvider
stagesMap={stagesCollection.getAllStagesAttributes(getString)}
queryParams={{ accountIdentifier: accountId, orgIdentifier, projectIdentifier, repoIdentifier, branch }}
pipelineIdentifier={pipelineIdentifier}
renderPipelineStage={args =>
getCDPipelineStages({
args,
getString,
isCIEnabled: licenseInformation['CI'] && isCIEnabled,
isCDEnabled: licenseInformation['CD'] && isCDEnabled,
isCFEnabled: licenseInformation['CF'] && isCFEnabled,
isSTOEnabled,
isApprovalStageEnabled: true
})
}
stepsFactory={factory}
runPipeline={handleRunPipeline}
>
<PipelineStudio
className={css.container}
routePipelineStudio={routes.toPipelineStudio}
routePipelineProject={routes.toDeployments}
routePipelineDetail={routes.toPipelineDetail}
routePipelineList={routes.toPipelines}
getOtherModal={getOtherModal}
/>
<TemplateDrawer />
</PipelineProvider>
)
}
export default CDPipelineStudio
|