@@ -42,19 +42,16 @@ import {
42
42
import TriggerTypeRadio from '../TriggerTypeRadio'
43
43
import ClusterSelect from './ClusterSelect'
44
44
import {
45
+ DEPLOYMENT_APP_TYPE_LABEL ,
45
46
GENERIC_SECTION_ERROR_STATE_COMMON_PROPS ,
46
47
MIGRATE_FROM_CLUSTER_APP_SELECT_CONFIG ,
47
48
MIGRATE_FROM_RADIO_GROUP_CONFIG ,
49
+ SELECTED_FORM_STATE_KEY ,
48
50
} from './constants'
49
51
import MigrateToDevtronValidationFactory from './MigrateToDevtronValidationFactory'
50
52
import { getMigrateAppOptions , validateMigrationSource } from './service'
51
53
import { ClusterSelectProps , MigrateToDevtronProps , SelectMigrateAppOptionType } from './types'
52
- import {
53
- generateMigrateAppOption ,
54
- getDeploymentAppTypeLabel ,
55
- getSelectedFormState ,
56
- sanitizeValidateMigrationSourceResponse ,
57
- } from './utils'
54
+ import { generateMigrateAppOption , sanitizeValidateMigrationSourceResponse } from './utils'
58
55
59
56
const SelectMigrateFromRadio = ( { deploymentAppType } : Pick < MigrateToDevtronFormState , 'deploymentAppType' > ) => {
60
57
const { title, tooltipContent } = MIGRATE_FROM_RADIO_GROUP_CONFIG [ deploymentAppType ]
@@ -83,6 +80,7 @@ const MigrateToDevtron = ({ migrateToDevtronFormState, setMigrateToDevtronFormSt
83
80
isSuperAdmin,
84
81
featureGitOpsFlags : { isFeatureArgoCdMigrationEnabled } ,
85
82
} = useMainContext ( )
83
+ const isFeatureFluxCdMigrationEnabled = window . _env_ . FEATURE_LINK_EXTERNAL_FLUX_ENABLE
86
84
const migrateAppOptionsControllerRef = useRef < AbortController > ( new AbortController ( ) )
87
85
const validateMigrationSourceControllerRef = useRef < AbortController > ( new AbortController ( ) )
88
86
@@ -92,7 +90,7 @@ const MigrateToDevtron = ({ migrateToDevtronFormState, setMigrateToDevtronFormSt
92
90
const isMigratingFromArgo = deploymentAppType === DeploymentAppTypes . ARGO
93
91
const isMigratingFromFlux = deploymentAppType === DeploymentAppTypes . FLUX
94
92
95
- const selectedFormState = getSelectedFormState ( migrateToDevtronFormState )
93
+ const selectedFormState = migrateToDevtronFormState [ SELECTED_FORM_STATE_KEY [ deploymentAppType ] ]
96
94
97
95
const { clusterId, clusterName, appName, namespace, validationResponse, appIcon } = selectedFormState
98
96
const { isLinkable } = validationResponse || { }
@@ -233,37 +231,25 @@ const MigrateToDevtron = ({ migrateToDevtronFormState, setMigrateToDevtronFormSt
233
231
return
234
232
}
235
233
234
+ const appInfo = {
235
+ appName : appOption . value . appName ,
236
+ namespace : appOption . value . namespace ,
237
+ appIcon : appOption . startIcon ,
238
+ }
239
+
236
240
setMigrateToDevtronFormState ( ( prevState ) => ( {
237
241
...prevState ,
238
242
migrateFromArgoFormState : {
239
243
...prevState . migrateFromArgoFormState ,
240
- ...( isMigratingFromArgo
241
- ? {
242
- appName : appOption . value . appName ,
243
- namespace : appOption . value . namespace ,
244
- appIcon : appOption . startIcon ,
245
- }
246
- : { } ) ,
244
+ ...( isMigratingFromArgo ? appInfo : { } ) ,
247
245
} ,
248
246
migrateFromHelmFormState : {
249
247
...prevState . migrateFromHelmFormState ,
250
- ...( isMigratingFromHelm
251
- ? {
252
- appName : appOption . value . appName ,
253
- namespace : appOption . value . namespace ,
254
- appIcon : appOption . startIcon ,
255
- }
256
- : { } ) ,
248
+ ...( isMigratingFromHelm ? appInfo : { } ) ,
257
249
} ,
258
250
migrateFromFluxFormState : {
259
251
...prevState . migrateFromFluxFormState ,
260
- ...( isMigratingFromFlux
261
- ? {
262
- appName : appOption . value . appName ,
263
- namespace : appOption . value . namespace ,
264
- appIcon : appOption . startIcon ,
265
- }
266
- : { } ) ,
252
+ ...( isMigratingFromFlux ? appInfo : { } ) ,
267
253
} ,
268
254
} ) )
269
255
}
@@ -298,22 +284,26 @@ const MigrateToDevtron = ({ migrateToDevtronFormState, setMigrateToDevtronFormSt
298
284
299
285
return (
300
286
< div className = "flexbox-col dc__gap-20" >
301
- < div className = "flexbox-col dc__gap-8" >
302
- < span className = "cn-7 fs-13 fw-4 lh-20" > Select type of application to migrate</ span >
303
-
304
- < RadioGroup
305
- className = "radio-group-no-border migrate-to-devtron__deployment-app-type-radio-group"
306
- value = { deploymentAppType }
307
- name = "migrate-from-app-type"
308
- onChange = { handleMigrateFromAppTypeChange }
309
- >
310
- < SelectMigrateFromRadio deploymentAppType = { DeploymentAppTypes . HELM } />
311
- { isFeatureArgoCdMigrationEnabled && (
312
- < SelectMigrateFromRadio deploymentAppType = { DeploymentAppTypes . ARGO } />
313
- ) }
314
- < SelectMigrateFromRadio deploymentAppType = { DeploymentAppTypes . FLUX } />
315
- </ RadioGroup >
316
- </ div >
287
+ { ( isFeatureArgoCdMigrationEnabled || isFeatureFluxCdMigrationEnabled ) && (
288
+ < div className = "flexbox-col dc__gap-8" >
289
+ < span className = "cn-7 fs-13 fw-4 lh-20" > Select type of application to migrate</ span >
290
+
291
+ < RadioGroup
292
+ className = "radio-group-no-border migrate-to-devtron__deployment-app-type-radio-group"
293
+ value = { deploymentAppType }
294
+ name = "migrate-from-app-type"
295
+ onChange = { handleMigrateFromAppTypeChange }
296
+ >
297
+ < SelectMigrateFromRadio deploymentAppType = { DeploymentAppTypes . HELM } />
298
+ { isFeatureArgoCdMigrationEnabled && (
299
+ < SelectMigrateFromRadio deploymentAppType = { DeploymentAppTypes . ARGO } />
300
+ ) }
301
+ { isFeatureFluxCdMigrationEnabled && (
302
+ < SelectMigrateFromRadio deploymentAppType = { DeploymentAppTypes . FLUX } />
303
+ ) }
304
+ </ RadioGroup >
305
+ </ div >
306
+ ) }
317
307
318
308
< div className = "flexbox dc__gap-8 dc__align-end" >
319
309
< ClusterSelect
@@ -331,7 +321,7 @@ const MigrateToDevtron = ({ migrateToDevtronFormState, setMigrateToDevtronFormSt
331
321
classNamePrefix = "migrate-from-source-app-select"
332
322
label = { appSelectLabel }
333
323
placeholder = { appSelectPlaceholder }
334
- disabledTippyContent = { `Select a cluster to view and select ${ getDeploymentAppTypeLabel ( deploymentAppType ) } in that cluster` }
324
+ disabledTippyContent = { `Select a cluster to view and select ${ DEPLOYMENT_APP_TYPE_LABEL [ deploymentAppType ] } in that cluster` }
335
325
icon = { icon }
336
326
isDisabled = { ! clusterId }
337
327
isLoading = { isLoadingAppListOptions }
@@ -368,13 +358,13 @@ const MigrateToDevtron = ({ migrateToDevtronFormState, setMigrateToDevtronFormSt
368
358
color : 'N700' ,
369
359
} }
370
360
title = "Checking compatibility"
371
- subTitle = { `Checking if ${ getDeploymentAppTypeLabel ( deploymentAppType ) } and its configurations are compatible for migration to deployment pipeline` }
361
+ subTitle = { `Checking if ${ DEPLOYMENT_APP_TYPE_LABEL [ deploymentAppType ] } and its configurations are compatible for migration to deployment pipeline` }
372
362
{ ...GENERIC_SECTION_ERROR_STATE_COMMON_PROPS }
373
363
/>
374
364
}
375
365
genericSectionErrorProps = { {
376
366
title : 'Error checking compatibility' ,
377
- subTitle : `An error occurred while checking if ${ getDeploymentAppTypeLabel ( deploymentAppType ) } and its configurations are compatible for migration to deployment pipeline` ,
367
+ subTitle : `An error occurred while checking if ${ DEPLOYMENT_APP_TYPE_LABEL [ deploymentAppType ] } and its configurations are compatible for migration to deployment pipeline` ,
378
368
reload : reloadValidationResponse ,
379
369
...GENERIC_SECTION_ERROR_STATE_COMMON_PROPS ,
380
370
} }
0 commit comments