14
14
* limitations under the License.
15
15
*/
16
16
17
- import { SyntheticEvent , useContext , useState } from 'react'
17
+ import { useContext , useState } from 'react'
18
18
import {
19
19
CustomInput ,
20
20
DeploymentAppTypes ,
21
21
InfoColourBar ,
22
22
Progressing ,
23
- RadioGroup ,
24
- RadioGroupItem ,
25
23
TippyCustomized ,
26
24
TippyTheme ,
27
25
YAMLStringify ,
@@ -34,44 +32,45 @@ import {
34
32
ComponentSizeType ,
35
33
showError ,
36
34
TriggerType ,
35
+ InfoBlock ,
36
+ ButtonVariantType ,
37
37
useMainContext ,
38
- ErrorScreenNotAuthorized ,
39
38
Tooltip ,
40
39
MODES ,
41
40
useGetUserRoles ,
42
41
} from '@devtron-labs/devtron-fe-common-lib'
43
42
import { useParams , useHistory } from 'react-router-dom'
44
43
import yamlJsParser from 'yaml'
45
- import error from '../../assets/icons/misc/errorInfo.svg'
46
- import { ReactComponent as AlertTriangle } from '../../assets/icons/ic-alert-triangle.svg'
44
+ import { ReactComponent as ICArrowRight } from '@Icons/ic-arrow-right.svg'
45
+ import { ReactComponent as Add } from '@Icons/ic-add.svg'
46
+ import { ReactComponent as AlertTriangle } from '@Icons/ic-alert-triangle.svg'
47
+ import { ReactComponent as Help } from '@Icons/ic-help.svg'
48
+ import { ReactComponent as ICInfo } from '@Icons/ic-info-filled.svg'
49
+ import { ReactComponent as ICHelpOutline } from '@Icons/ic-help-outline.svg'
50
+ import settings from '@Icons/ic-settings.svg'
51
+ import trash from '@Icons/misc/delete.svg'
52
+ import error from '@Icons/misc/errorInfo.svg'
53
+ import { Info } from '../common/icons/Icons'
47
54
import { ENV_ALREADY_EXIST_ERROR , RegistryPayloadWithSelectType , URLS , ViewType } from '../../config'
48
55
import { GeneratedHelmPush , MigrateToDevtronFormState , TriggerTypeRadioProps } from './cdPipeline.types'
49
56
import { createClusterEnvGroup , getDeploymentAppType , importComponentFromFELibrary , Select } from '../common'
50
- import { Info } from '../common/icons/Icons'
51
- import { ReactComponent as Help } from '../../assets/icons/ic-help.svg'
52
- import { ReactComponent as ICHelpOutline } from '../../assets/icons/ic-help-outline.svg'
53
- import settings from '../../assets/icons/ic-settings.svg'
54
- import trash from '../../assets/icons/misc/delete.svg'
55
57
import { pipelineContext } from '../workflowEditor/workflowEditor'
56
- import { ReactComponent as Add } from '../../assets/icons/ic-add.svg'
57
58
import { getNamespacePlaceholder } from './cdpipeline.util'
58
59
import { ValidationRules } from '../ciPipeline/validationRules'
59
60
import { DeploymentAppRadioGroup } from '../v2/values/chartValuesDiff/ChartValuesView.component'
60
61
import CustomImageTags from '../CIPipelineN/CustomImageTags'
61
- import { ReactComponent as Warn } from '../../assets/icons/ic-warning.svg'
62
62
import { GITOPS_REPO_REQUIRED } from '../v2/values/chartValuesDiff/constant'
63
63
import { getGitOpsRepoConfig } from '../../services/service'
64
- import { ReactComponent as ICInfo } from '../../assets/icons/ic-info-filled.svg'
65
64
66
65
import PullImageDigestToggle from './PullImageDigestToggle'
67
66
import { EnvironmentWithSelectPickerType } from '@Components/CIPipelineN/types'
68
67
import { BuildCDProps } from './types'
69
- import { MigrateFromArgo } from './MigrateToDevtron'
68
+ import { MigrateToDevtron } from './MigrateToDevtron'
70
69
import TriggerTypeRadio from './TriggerTypeRadio'
70
+ import { MigrateToDevtronProps } from './MigrateToDevtron/types'
71
71
72
72
const VirtualEnvSelectionInfoText = importComponentFromFELibrary ( 'VirtualEnvSelectionInfoText' )
73
73
const HelmManifestPush = importComponentFromFELibrary ( 'HelmManifestPush' )
74
- const MigrateHelmReleaseBody = importComponentFromFELibrary ( 'MigrateHelmReleaseBody' , null , 'function' )
75
74
const ApprovalPolicyRedirectCard = importComponentFromFELibrary ( 'ApprovalPolicyRedirectCard' , null , 'function' )
76
75
77
76
export default function BuildCD ( {
@@ -89,6 +88,7 @@ export default function BuildCD({
89
88
getMandatoryPluginData,
90
89
migrateToDevtronFormState,
91
90
setMigrateToDevtronFormState,
91
+ isGitOpsInstalledButNotConfigured,
92
92
} : BuildCDProps ) {
93
93
const {
94
94
formData,
@@ -145,13 +145,11 @@ export default function BuildCD({
145
145
146
146
const handleTriggerTypeChange = ( event ) => {
147
147
const _form = { ...formData }
148
- const triggerType = event . target . value as MigrateToDevtronFormState [ 'triggerType' ]
149
-
150
- _form . triggerType = triggerType
148
+ _form . triggerType = event . target . value as MigrateToDevtronFormState [ 'triggerType' ]
151
149
setFormData ( _form )
152
150
}
153
151
154
- const handleMigrateFromAppTypeChange = ( event : SyntheticEvent ) => {
152
+ const handleMigrateFromAppTypeChange : MigrateToDevtronProps [ 'handleMigrateFromAppTypeChange' ] = ( event ) => {
155
153
const { value } = event . target as HTMLInputElement
156
154
setMigrateToDevtronFormState ( ( prevState ) => ( {
157
155
...prevState ,
@@ -304,27 +302,29 @@ export default function BuildCD({
304
302
. catch ( ( err ) => {
305
303
if ( err . code === 409 ) {
306
304
setReloadNoGitOpsRepoConfiguredModal ( true )
305
+ } else {
306
+ showError ( err )
307
307
}
308
308
} )
309
309
. finally ( ( ) => {
310
310
setGitopsConflictLoading ( false )
311
311
} )
312
312
}
313
313
314
- const gitOpsRepoConfigInfoBar = ( content : string ) => {
315
- return (
316
- < InfoColourBar
317
- message = { content }
318
- classname = "warn mb-16"
319
- Icon = { Warn }
320
- iconClass = "warning-icon"
321
- linkClass = { `flex ${ gitopsConflictLoading ? 'loading-dots-cb5 cursor-not-allowed' : '' } ` }
322
- linkText = "Configure GitOps Repository"
323
- internalLink
324
- linkOnClick = { checkGitOpsRepoConflict }
325
- />
326
- )
327
- }
314
+ const gitOpsRepoConfigInfoBar = ( content : string ) => (
315
+ < InfoBlock
316
+ description = { content }
317
+ variant = "warning"
318
+ buttonProps = { {
319
+ dataTestId : 'configure-gitops-repo-button' ,
320
+ variant : ButtonVariantType . text ,
321
+ text : 'Configure' ,
322
+ endIcon : < ICArrowRight /> ,
323
+ onClick : checkGitOpsRepoConflict ,
324
+ isLoading : gitopsConflictLoading ,
325
+ } }
326
+ />
327
+ )
328
328
329
329
const renderTriggerType = ( ) => (
330
330
< TriggerTypeRadio
@@ -490,7 +490,9 @@ export default function BuildCD({
490
490
/>
491
491
</ div >
492
492
</ div >
493
- { gitOpsRepoNotConfiguredAndOptionsHidden && gitOpsRepoConfigInfoBar ( GITOPS_REPO_REQUIRED ) }
493
+ < div className = "mb-16" >
494
+ { gitOpsRepoNotConfiguredAndOptionsHidden && gitOpsRepoConfigInfoBar ( GITOPS_REPO_REQUIRED ) }
495
+ </ div >
494
496
{ renderNamespaceInfo ( namespaceEditable ) }
495
497
{ isVirtualEnvironment
496
498
? HelmManifestPush && (
@@ -604,23 +606,22 @@ export default function BuildCD({
604
606
setFormData ( _form )
605
607
}
606
608
607
- const renderDeploymentAppType = ( ) => {
608
- return (
609
- < div className = "cd-pipeline__deployment-type mt-16" >
610
- < label className = "form__label form__label--sentence dc__bold" > How do you want to deploy?</ label >
611
- < DeploymentAppRadioGroup
612
- isDisabled = { ! ! cdPipelineId }
613
- deploymentAppType = { formData . deploymentAppType ?? DeploymentAppTypes . HELM }
614
- handleOnChange = { handleDeploymentAppTypeChange }
615
- allowedDeploymentTypes = { formData . allowedDeploymentTypes }
616
- rootClassName = { `chartrepo-type__radio-group ${ ! cdPipelineId ? 'bcb-5' : '' } ` }
617
- isFromCDPipeline
618
- isGitOpsRepoNotConfigured = { isGitOpsRepoNotConfigured }
619
- gitOpsRepoConfigInfoBar = { gitOpsRepoConfigInfoBar }
620
- />
621
- </ div >
622
- )
623
- }
609
+ const renderDeploymentAppType = ( ) => (
610
+ < div className = "cd-pipeline__deployment-type mt-16" >
611
+ < label className = "form__label form__label--sentence dc__bold" > How do you want to deploy?</ label >
612
+ < DeploymentAppRadioGroup
613
+ isDisabled = { ! ! cdPipelineId }
614
+ deploymentAppType = { formData . deploymentAppType ?? DeploymentAppTypes . HELM }
615
+ handleOnChange = { handleDeploymentAppTypeChange }
616
+ allowedDeploymentTypes = { formData . allowedDeploymentTypes }
617
+ rootClassName = { `chartrepo-type__radio-group ${ ! cdPipelineId ? 'bcb-5' : '' } ` }
618
+ isFromCDPipeline
619
+ isGitOpsRepoNotConfigured = { isGitOpsRepoNotConfigured }
620
+ gitOpsRepoConfigInfoBar = { gitOpsRepoConfigInfoBar }
621
+ areGitopsCredentialsConfigured = { ! isGitOpsInstalledButNotConfigured }
622
+ />
623
+ </ div >
624
+ )
624
625
625
626
const renderStrategyOptions = ( ) => {
626
627
return (
@@ -777,80 +778,14 @@ export default function BuildCD({
777
778
)
778
779
}
779
780
780
- const renderSelectMigrateFromRadioGroup = ( deploymentAppType : MigrateToDevtronFormState [ 'deploymentAppType' ] ) => (
781
- < RadioGroupItem dataTestId = { `${ deploymentAppType } -radio-item` } value = { deploymentAppType } >
782
- < Tooltip
783
- alwaysShowTippyOnHover
784
- content = {
785
- < div className = "flexbox-col dc__gap-2" >
786
- < h6 className = "m-0 fs-12 fw-6 lh-18" >
787
- { deploymentAppType === DeploymentAppTypes . HELM
788
- ? 'Migrate helm release'
789
- : 'Migrate Argo CD Application' }
790
- </ h6 >
791
-
792
- < p className = "m-0 fs-12 fw-4 lh-18" >
793
- { deploymentAppType === DeploymentAppTypes . HELM
794
- ? 'Migrate an existing Helm Release to manage deployments via CD pipeline'
795
- : 'Migrate an existing Argo CD Application to manage deployments via CD pipeline' }
796
- </ p >
797
- </ div >
798
- }
799
- >
800
- < span className = "cn-9 fs-13 fw-4 lh-20 dc__underline-dotted" >
801
- { deploymentAppType === DeploymentAppTypes . HELM ? 'Helm Release' : 'Argo CD Application' }
802
- </ span >
803
- </ Tooltip >
804
- </ RadioGroupItem >
805
- )
806
-
807
781
const renderBuild = ( ) => {
808
- if ( releaseMode === ReleaseMode . MIGRATE_EXTERNAL_APPS && ! isAdvanced && MigrateHelmReleaseBody ) {
809
- if ( ! isSuperAdmin ) {
810
- return < ErrorScreenNotAuthorized />
811
- }
812
-
813
- if ( ! isFeatureArgoCdMigrationEnabled ) {
814
- return (
815
- < MigrateHelmReleaseBody
816
- renderTriggerType = { renderTriggerType }
817
- formData = { formData }
818
- setFormData = { setFormData }
819
- renderEnvSelector = { renderEnvSelector }
820
- />
821
- )
822
- }
823
-
782
+ if ( ! isAdvanced && releaseMode === ReleaseMode . MIGRATE_EXTERNAL_APPS ) {
824
783
return (
825
- < div className = "flexbox-col dc__gap-16" >
826
- < div className = "flexbox-col dc__gap-8" >
827
- < span className = "cn-7 fs-13 fw-4 lh-20" > Select type of application to migrate</ span >
828
-
829
- < RadioGroup
830
- className = "radio-group-no-border migrate-to-devtron__deployment-app-type-radio-group"
831
- value = { migrateToDevtronFormState . deploymentAppType }
832
- name = "migrate-from-app-type"
833
- onChange = { handleMigrateFromAppTypeChange }
834
- >
835
- { renderSelectMigrateFromRadioGroup ( DeploymentAppTypes . HELM ) }
836
- { renderSelectMigrateFromRadioGroup ( DeploymentAppTypes . GITOPS ) }
837
- </ RadioGroup >
838
- </ div >
839
-
840
- { migrateToDevtronFormState . deploymentAppType === DeploymentAppTypes . HELM ? (
841
- < MigrateHelmReleaseBody
842
- renderTriggerType = { renderTriggerType }
843
- formData = { formData }
844
- setFormData = { setFormData }
845
- renderEnvSelector = { renderEnvSelector }
846
- />
847
- ) : (
848
- < MigrateFromArgo
849
- migrateToDevtronFormState = { migrateToDevtronFormState }
850
- setMigrateToDevtronFormState = { setMigrateToDevtronFormState }
851
- />
852
- ) }
853
- </ div >
784
+ < MigrateToDevtron
785
+ migrateToDevtronFormState = { migrateToDevtronFormState }
786
+ setMigrateToDevtronFormState = { setMigrateToDevtronFormState }
787
+ handleMigrateFromAppTypeChange = { handleMigrateFromAppTypeChange }
788
+ />
854
789
)
855
790
}
856
791
@@ -881,15 +816,14 @@ export default function BuildCD({
881
816
{ ! window . _env_ . HIDE_GITOPS_OR_HELM_OPTION &&
882
817
! isVirtualEnvironment &&
883
818
formData . allowedDeploymentTypes . length > 0 &&
884
- ! noGitOpsModuleInstalledAndConfigured &&
819
+ // Want to show this when gitops module is installed, does not matter if it is configured or not
820
+ ( ! noGitOpsModuleInstalledAndConfigured || isGitOpsInstalledButNotConfigured ) &&
885
821
renderDeploymentAppType ( ) }
886
822
887
823
{ isAdvanced ? renderAdvancedDeploymentStrategy ( ) : renderBasicDeploymentStrategy ( ) }
888
-
889
- { isAdvanced && ApprovalPolicyRedirectCard && < ApprovalPolicyRedirectCard /> }
890
-
891
824
{ isAdvanced && (
892
825
< >
826
+ { ApprovalPolicyRedirectCard && < ApprovalPolicyRedirectCard /> }
893
827
< CustomImageTags
894
828
formData = { formData }
895
829
setFormData = { setFormData }
0 commit comments