@@ -28,7 +28,6 @@ import {
28
28
SelectPicker ,
29
29
ToastVariantType ,
30
30
ToastManager ,
31
- ComponentSizeType ,
32
31
showError ,
33
32
TriggerType ,
34
33
InfoBlock ,
@@ -39,21 +38,17 @@ import { useParams, useHistory } from 'react-router-dom'
39
38
import yamlJsParser from 'yaml'
40
39
import { ReactComponent as ICArrowRight } from '@Icons/ic-arrow-right.svg'
41
40
import { ReactComponent as Add } from '@Icons/ic-add.svg'
42
- import { ReactComponent as AlertTriangle } from '@Icons/ic-alert-triangle.svg'
43
41
import { ReactComponent as Help } from '@Icons/ic-help.svg'
44
42
import { ReactComponent as ICInfo } from '@Icons/ic-info-filled.svg'
45
43
import { ReactComponent as ICHelpOutline } from '@Icons/ic-help-outline.svg'
46
44
import settings from '@Icons/ic-settings.svg'
47
45
import trash from '@Icons/misc/delete.svg'
48
- import error from '@Icons/misc/errorInfo.svg'
49
- import { Info } from '../common/icons/Icons'
50
46
import { ENV_ALREADY_EXIST_ERROR , RegistryPayloadWithSelectType , URLS , ViewType } from '../../config'
51
47
import { GeneratedHelmPush , MigrateToDevtronFormState , TriggerTypeRadioProps } from './cdPipeline.types'
52
48
import { createClusterEnvGroup , getDeploymentAppType , importComponentFromFELibrary , Select } from '../common'
53
49
import { pipelineContext } from '../workflowEditor/workflowEditor'
54
50
import { getNamespacePlaceholder } from './cdpipeline.util'
55
51
import { ValidationRules } from '../ciPipeline/validationRules'
56
- import { DeploymentAppRadioGroup } from '../v2/values/chartValuesDiff/ChartValuesView.component'
57
52
import CustomImageTags from '../CIPipelineN/CustomImageTags'
58
53
import { GITOPS_REPO_REQUIRED } from '../v2/values/chartValuesDiff/constant'
59
54
import { getGitOpsRepoConfig } from '../../services/service'
@@ -64,9 +59,8 @@ import { BuildCDProps } from './types'
64
59
import { MigrateToDevtron } from './MigrateToDevtron'
65
60
import TriggerTypeRadio from './TriggerTypeRadio'
66
61
import { MigrateToDevtronProps } from './MigrateToDevtron/types'
67
- import { CDPipelineDeploymentAppType } from '@Pages/App/Configurations'
62
+ import { CDPipelineDeploymentAppType , SourceMaterialsSelector } from '@Pages/App/Configurations'
68
63
69
- const VirtualEnvSelectionInfoText = importComponentFromFELibrary ( 'VirtualEnvSelectionInfoText' )
70
64
const HelmManifestPush = importComponentFromFELibrary ( 'HelmManifestPush' )
71
65
72
66
export default function BuildCD ( {
@@ -268,24 +262,6 @@ export default function BuildCD({
268
262
)
269
263
}
270
264
271
- const renderNamespaceInfo = ( namespaceEditable : boolean ) => {
272
- if ( namespaceEditable ) {
273
- return (
274
- < div className = "dc__info-container info__container--cd-pipeline" >
275
- < Info />
276
- < div className = "flex column left" >
277
- < div className = "dc__info-title" > Set Namespace</ div >
278
- < div className = "dc__info-subtitle" >
279
- The entered namespace will be applicable to selected environment across all the pipelines
280
- for this application.
281
- </ div >
282
- </ div >
283
- </ div >
284
- )
285
- }
286
- return null
287
- }
288
-
289
265
const checkGitOpsRepoConflict = ( ) => {
290
266
setGitopsConflictLoading ( true )
291
267
getGitOpsRepoConfig ( + appId )
@@ -382,21 +358,27 @@ export default function BuildCD({
382
358
setFormData ( _form )
383
359
}
384
360
385
- const renderEnvSelector = ( ) => {
361
+ const renderEnvNamespaceAndTriggerType = ( ) => {
386
362
const envId = formData . environmentId
387
363
const _environment = formData . environments . find ( ( env ) => env . id == envId )
388
364
const selectedEnv : EnvironmentWithSelectPickerType = _environment && {
389
365
..._environment ,
390
366
label : _environment . name ,
391
367
value : _environment . id . toString ( ) ,
392
368
}
393
- const envList = createClusterEnvGroup ( formData . environments as Environment [ ] , 'clusterName' )
394
369
395
- const renderVirtualEnvironmentInfo = ( ) => {
396
- if ( isVirtualEnvironment && VirtualEnvSelectionInfoText ) {
397
- return < VirtualEnvSelectionInfoText />
398
- }
399
- }
370
+ const isHelmEnforced =
371
+ formData . allowedDeploymentTypes . length === 1 &&
372
+ formData . allowedDeploymentTypes [ 0 ] === DeploymentAppTypes . HELM
373
+
374
+ const gitOpsRepoNotConfiguredAndOptionsHidden =
375
+ window . _env_ . HIDE_GITOPS_OR_HELM_OPTION &&
376
+ selectedEnv &&
377
+ ! noGitOpsModuleInstalledAndConfigured &&
378
+ ! isHelmEnforced &&
379
+ isGitOpsRepoNotConfigured
380
+
381
+ const envList = createClusterEnvGroup ( formData . environments as Environment [ ] , 'clusterName' )
400
382
401
383
const getEnvListOptions = ( ) =>
402
384
envList . map ( ( _elm ) => ( {
@@ -408,86 +390,53 @@ export default function BuildCD({
408
390
} ) ) ,
409
391
} ) )
410
392
411
- return (
412
- < >
413
- < SelectPicker
414
- label = "Environment"
415
- required
416
- inputId = "environment"
417
- menuPosition = { isAdvanced ? null : 'fixed' }
418
- isDisabled = { ! ! cdPipelineId }
419
- classNamePrefix = "cd-pipeline-environment-dropdown"
420
- placeholder = "Select Environment"
421
- autoFocus
422
- options = {
423
- releaseMode === ReleaseMode . MIGRATE_EXTERNAL_APPS
424
- ? getEnvListOptions ( ) . filter ( ( env ) =>
425
- env . options . filter ( ( _env ) => ! _env . isVirtualEnvironment ) ,
426
- )
427
- : getEnvListOptions ( )
428
- }
429
- value = { selectedEnv }
430
- getOptionValue = { ( option ) => option . value as unknown as string }
431
- onChange = { selectEnvironment }
432
- size = { ComponentSizeType . large }
433
- />
434
- { isEnvUsedState && (
435
- < span className = "form__error" >
436
- < img src = { error } className = "form__icon" />
437
- { ENV_ALREADY_EXIST_ERROR }
438
- </ span >
439
- ) }
440
- { ! formDataErrorObj . envNameError . isValid ? (
441
- < span className = "form__error" >
442
- < AlertTriangle className = "icon-dim-14 mr-5 ml-5 mt-2" />
443
- { formDataErrorObj . envNameError . message }
444
- </ span >
445
- ) : null }
446
- { renderVirtualEnvironmentInfo ( ) }
447
- </ >
448
- )
449
- }
450
-
451
- const renderEnvNamespaceAndTriggerType = ( ) => {
452
- const envId = formData . environmentId
453
- const selectedEnv : Environment = formData . environments . find ( ( env ) => env . id == envId )
454
- const namespaceEditable = false
455
-
456
- const isHelmEnforced =
457
- formData . allowedDeploymentTypes . length === 1 &&
458
- formData . allowedDeploymentTypes [ 0 ] === DeploymentAppTypes . HELM
393
+ const getEnvError = ( ) => {
394
+ if ( isEnvUsedState ) {
395
+ return ENV_ALREADY_EXIST_ERROR
396
+ }
459
397
460
- const gitOpsRepoNotConfiguredAndOptionsHidden =
461
- window . _env_ . HIDE_GITOPS_OR_HELM_OPTION &&
462
- selectedEnv &&
463
- ! noGitOpsModuleInstalledAndConfigured &&
464
- ! isHelmEnforced &&
465
- isGitOpsRepoNotConfigured
398
+ return ! formDataErrorObj . envNameError . isValid ? formDataErrorObj . envNameError . message : null
399
+ }
466
400
467
401
return (
468
402
< >
469
- < div className = "form__row form__row--flex mt-12" >
470
- < div className = "w-50 mr-8" > { renderEnvSelector ( ) } </ div >
471
- < div className = "flex-1 ml-8" >
472
- < CustomInput
473
- name = "namespace"
474
- label = "Namespace"
475
- placeholder = { getNamespacePlaceholder ( isVirtualEnvironment , formData . namespace ) }
476
- disabled = { ! namespaceEditable }
477
- value = { selectedEnv ?. namespace ? selectedEnv . namespace : formData . namespace }
478
- onChange = { handleNamespaceChange }
479
- error = {
480
- ! formDataErrorObj . nameSpaceError . isValid &&
481
- ! isVirtualEnvironment &&
482
- formDataErrorObj . nameSpaceError . message
483
- }
484
- />
485
- </ div >
486
- </ div >
403
+ < SourceMaterialsSelector
404
+ branchInputProps = { {
405
+ name : 'cd-pipeline-namespace' ,
406
+ onChange : handleNamespaceChange ,
407
+ placeholder : getNamespacePlaceholder ( isVirtualEnvironment , formData . namespace ) ,
408
+ label : 'Namespace' ,
409
+ value : selectedEnv ?. namespace ? selectedEnv . namespace : formData . namespace ,
410
+ disabled : true ,
411
+ error :
412
+ ! formDataErrorObj . nameSpaceError . isValid &&
413
+ ! isVirtualEnvironment &&
414
+ formDataErrorObj . nameSpaceError . message ,
415
+ } }
416
+ sourceTypePickerProps = { {
417
+ inputId : 'cd-pipeline-environment' ,
418
+ classNamePrefix : 'cd-pipeline-environment' ,
419
+ label : 'Environment' ,
420
+ placeholder : 'Select environment' ,
421
+ isDisabled : ! ! cdPipelineId ,
422
+ menuPosition : isAdvanced ? null : 'fixed' ,
423
+ options :
424
+ releaseMode === ReleaseMode . MIGRATE_EXTERNAL_APPS
425
+ ? getEnvListOptions ( ) . filter ( ( env ) =>
426
+ env . options . filter ( ( _env ) => ! _env . isVirtualEnvironment ) ,
427
+ )
428
+ : getEnvListOptions ( ) ,
429
+ value : selectedEnv ,
430
+ getOptionValue : ( option ) => option . value as string ,
431
+ helperText : isVirtualEnvironment ? 'Isolated environment' : null ,
432
+ error : getEnvError ( ) ,
433
+ onChange : selectEnvironment ,
434
+ autoFocus : true ,
435
+ } }
436
+ />
487
437
< div className = "mb-16" >
488
438
{ gitOpsRepoNotConfiguredAndOptionsHidden && gitOpsRepoConfigInfoBar ( GITOPS_REPO_REQUIRED ) }
489
439
</ div >
490
- { renderNamespaceInfo ( namespaceEditable ) }
491
440
{ isVirtualEnvironment
492
441
? HelmManifestPush && (
493
442
< HelmManifestPush
0 commit comments