6
6
AnimatedDeployButton ,
7
7
API_STATUS_CODES ,
8
8
ArtifactInfo ,
9
- ButtonStyleType ,
10
9
CDMaterialSidebarType ,
11
10
ConditionalWrap ,
12
11
DEFAULT_ROUTE_PROMPT_MESSAGE ,
@@ -58,17 +57,19 @@ import DeployImageHeader from './DeployImageHeader'
58
57
import MaterialListSkeleton from './MaterialListSkeleton'
59
58
import RuntimeParamsSidebar from './RuntimeParamsSidebar'
60
59
import { getMaterialResponseList , loadOlderImages } from './service'
61
- import { DeployImageContentProps , DeployImageModalProps , DeployViewStateType } from './types'
60
+ import { DeployImageContentProps , DeployImageModalProps , DeployViewStateType , HandleDeploymentProps } from './types'
62
61
import {
63
62
getAllowWarningWithTippyNodeTypeProp ,
64
63
getCDArtifactId ,
65
64
getConfigToDeployValue ,
66
65
getDeployButtonIcon ,
66
+ getDeployButtonStyle ,
67
67
getInitialSelectedConfigToDeploy ,
68
68
getIsExceptionUser ,
69
69
getIsImageApprover ,
70
70
getTriggerArtifactInfoProps ,
71
71
handleTriggerErrorMessageForHelmManifestPush ,
72
+ renderDeployCTATippyData ,
72
73
showErrorIfNotAborted ,
73
74
} from './utils'
74
75
@@ -177,8 +178,8 @@ const DeployImageModal = ({
177
178
const canApproverDeploy = materialResponse ?. canApproverDeploy ?? false
178
179
const showConfigDiffView = searchParams . mode === URL_PARAM_MODE_TYPE . REVIEW_CONFIG && searchParams . deploy
179
180
const isSelectImageTrigger = materialType === MATERIAL_TYPE . inputMaterialList
180
- const areSomeMaterialsPassingFilters = materialList . some (
181
- ( materialDetails ) => materialDetails . filterState = == FilterStates . ALLOWED ,
181
+ const areAllImagesExcluded = materialList . every (
182
+ ( materialDetails ) => materialDetails . filterState ! == FilterStates . ALLOWED ,
182
183
)
183
184
const selectedConfigToDeploy = getInitialSelectedConfigToDeploy ( materialType , searchParams )
184
185
const showPluginWarningBeforeTrigger = _showPluginWarningBeforeTrigger && isPreOrPostCD
@@ -275,7 +276,9 @@ const DeployImageModal = ({
275
276
}
276
277
277
278
const handleClose = ( ) => {
278
- onClickSetInitialParams ( URL_PARAM_MODE_TYPE . LIST )
279
+ if ( isRedirectedFromAppDetails && showConfigDiffView ) {
280
+ onClickSetInitialParams ( URL_PARAM_MODE_TYPE . LIST )
281
+ }
279
282
handleCloseProp ?.( )
280
283
}
281
284
@@ -323,34 +326,32 @@ const DeployImageModal = ({
323
326
324
327
return (
325
328
! selectedImage ||
326
- ! areSomeMaterialsPassingFilters ||
329
+ areAllImagesExcluded ||
327
330
( isRollbackTrigger && ( pipelineDeploymentConfigLoading || ! canDeployWithConfig ( ) ) ) ||
328
331
( selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG && noLastDeploymentConfig )
329
332
)
330
333
}
331
334
332
335
const renderDeployCTATippyContent = ( ) => {
333
- if ( ! areSomeMaterialsPassingFilters ) {
334
- return (
335
- < >
336
- < h2 className = "fs-12 fw-6 lh-18 m-0" > No eligible images found!</ h2 >
337
- < p className = "fs-12 fw-4 lh-18 m-0" >
338
- Please select an image that passes the configured filters to deploy
339
- </ p >
340
- </ >
336
+ const isSelectedImagePresent = materialList . some ( ( artifact ) => artifact . isSelected )
337
+
338
+ if ( areAllImagesExcluded ) {
339
+ return renderDeployCTATippyData (
340
+ 'No eligible images found!' ,
341
+ 'Please select an image that passes the configured filters to deploy' ,
341
342
)
342
343
}
343
344
344
- return (
345
- < >
346
- < h2 className = "fs-12 fw-6 lh-18 m-0" > Selected Config not available! </ h2 >
347
- < p className = "fs-12 fw-4 lh-18 m-0" >
348
- { selectedConfigToDeploy . value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
349
- noSpecificDeploymentConfig
350
- ? 'Please select a different image or configuration to deploy'
351
- : 'Please select a different configuration to deploy' }
352
- </ p >
353
- </ >
345
+ if ( ! isSelectedImagePresent ) {
346
+ return renderDeployCTATippyData ( 'No image selected!' , 'Please select an image to deploy' )
347
+ }
348
+
349
+ return renderDeployCTATippyData (
350
+ 'Selected Config not available!' ,
351
+ selectedConfigToDeploy . value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
352
+ noSpecificDeploymentConfig
353
+ ? 'Please select a different image or configuration to deploy'
354
+ : 'Please select a different configuration to deploy' ,
354
355
)
355
356
}
356
357
@@ -361,16 +362,10 @@ const DeployImageModal = ({
361
362
)
362
363
363
364
const redirectToDeploymentStepsPage = ( ) => {
364
- history . push ( `/app/ ${ appId } /cd-details /${ envId } /${ pipelineId } ` )
365
+ history . push ( `${ URLS . APP } / ${ appId } /${ URLS . APP_CD_DETAILS } /${ envId } /${ pipelineId } ` )
365
366
}
366
367
367
- const handleDeployment = (
368
- nodeType : DeploymentNodeType ,
369
- _appId : number ,
370
- ciArtifactId : number ,
371
- deploymentWithConfig ?: string ,
372
- computedWfrId ?: number ,
373
- ) => {
368
+ const handleDeployment = ( { ciArtifactId, deploymentWithConfig, computedWfrId } : HandleDeploymentProps ) => {
374
369
const updatedRuntimeParamsErrorState = validateRuntimeParameters ( runtimeParamsList )
375
370
setDeployViewState ( ( prevState ) => ( {
376
371
...prevState ,
@@ -384,15 +379,15 @@ const DeployImageModal = ({
384
379
return
385
380
}
386
381
387
- handleAnalyticsEvent ( TRIGGER_VIEW_GA_EVENTS . CDTriggered ( nodeType ) )
382
+ handleAnalyticsEvent ( TRIGGER_VIEW_GA_EVENTS . CDTriggered ( stageType ) )
388
383
setIsDeploymentLoading ( true )
389
384
390
- if ( _appId && pipelineId && ciArtifactId ) {
385
+ if ( appId && pipelineId && ciArtifactId ) {
391
386
triggerCDNode ( {
392
387
pipelineId : Number ( pipelineId ) ,
393
388
ciArtifactId : Number ( ciArtifactId ) ,
394
- appId : Number ( _appId ) ,
395
- stageType : nodeType ,
389
+ appId : Number ( appId ) ,
390
+ stageType,
396
391
deploymentWithConfig,
397
392
wfrId : computedWfrId ,
398
393
abortControllerRef : null ,
@@ -408,10 +403,10 @@ const DeployImageModal = ({
408
403
if ( isVirtualEnvironment && deploymentAppType === DeploymentAppTypes . MANIFEST_DOWNLOAD ) {
409
404
const { helmPackageName } = response . result
410
405
downloadManifestForVirtualEnvironment ?.( {
411
- appId : _appId ,
406
+ appId,
412
407
envId,
413
408
helmPackageName,
414
- cdWorkflowType : nodeType ,
409
+ cdWorkflowType : stageType ,
415
410
handleDownload,
416
411
} )
417
412
}
@@ -444,7 +439,7 @@ const DeployImageModal = ({
444
439
setIsDeploymentLoading ( false )
445
440
} )
446
441
} else {
447
- let message = _appId ? '' : 'app id missing '
442
+ let message = appId ? '' : 'app id missing '
448
443
message += pipelineId ? '' : 'pipeline id missing '
449
444
message += ciArtifactId ? '' : 'Artifact id missing '
450
445
ToastManager . showToast ( {
@@ -456,7 +451,7 @@ const DeployImageModal = ({
456
451
}
457
452
458
453
const deployTrigger = ( e : SyntheticEvent ) => {
459
- e . stopPropagation ( )
454
+ stopPropagation ( e )
460
455
handleConfirmationClose ( e )
461
456
// Blocking the deploy action if already deploying or config is not available
462
457
if ( isDeployButtonDisabled ( ) ) {
@@ -467,15 +462,21 @@ const DeployImageModal = ({
467
462
468
463
if ( isRollbackTrigger || isSelectImageTrigger ) {
469
464
const computedWfrId = isRollbackTrigger ? wfrId : lastDeploymentWfrId
470
- handleDeployment ( stageType , appId , artifactId , selectedConfigToDeploy . value , computedWfrId )
465
+ handleDeployment ( {
466
+ ciArtifactId : artifactId ,
467
+ deploymentWithConfig : selectedConfigToDeploy . value ,
468
+ computedWfrId,
469
+ } )
471
470
return
472
471
}
473
472
474
- handleDeployment ( stageType , appId , artifactId )
473
+ // Not sure when this call will come into play, but keeping it for now for backward compatibility
474
+ handleDeployment ( { ciArtifactId : artifactId } )
475
475
}
476
476
477
- const onClickDeploy = ( e , disableDeployButton : boolean ) => {
478
- e . stopPropagation ( )
477
+ const onClickDeploy = ( e : SyntheticEvent , disableDeployButton : boolean ) => {
478
+ stopPropagation ( e )
479
+
479
480
if ( ! disableDeployButton ) {
480
481
if ( ! showPluginWarningOverlay && showPluginWarningBeforeTrigger ) {
481
482
setShowPluginWarningOverlay ( true )
@@ -494,19 +495,8 @@ const DeployImageModal = ({
494
495
}
495
496
}
496
497
497
- const getDeployButtonStyle = (
498
- userActionState : string ,
499
- canDeployWithoutApproval : boolean ,
500
- canImageApproverDeploy : boolean ,
501
- ) : ButtonStyleType => {
502
- if ( userActionState === ACTION_STATE . BLOCKED ) {
503
- return ButtonStyleType . negative
504
- }
505
- if ( userActionState === ACTION_STATE . PARTIAL || canDeployWithoutApproval || canImageApproverDeploy ) {
506
- return ButtonStyleType . warning
507
- }
508
- return ButtonStyleType . default
509
- }
498
+ const getOnClickDeploy = ( disableDeployButton : boolean ) => ( e : SyntheticEvent ) =>
499
+ onClickDeploy ( e , disableDeployButton )
510
500
511
501
const onSearchApply = ( newSearchText : string ) => {
512
502
const newParams = new URLSearchParams ( {
@@ -540,7 +530,7 @@ const DeployImageModal = ({
540
530
< AnimatedDeployButton
541
531
dataTestId = "cd-trigger-deploy-button"
542
532
isLoading = { isDeploymentLoading }
543
- onButtonClick = { ( e ) => onClickDeploy ( e , disableDeployButton ) }
533
+ onButtonClick = { getOnClickDeploy ( disableDeployButton ) }
544
534
startIcon = { getDeployButtonIcon ( deploymentWindowMetadata , stageType ) }
545
535
text = {
546
536
canDeployWithoutApproval
@@ -635,7 +625,7 @@ const DeployImageModal = ({
635
625
consequence = { consequence }
636
626
configurePluginURL = { configurePluginURL }
637
627
showTriggerButton
638
- onTrigger = { ( e ) => onClickDeploy ( e , disableDeployButton ) }
628
+ onTrigger = { getOnClickDeploy ( disableDeployButton ) }
639
629
nodeType = { allowWarningWithTippyNodeTypeProp }
640
630
visible = { showPluginWarningOverlay }
641
631
onClose = { handleClosePluginWarningOverlay }
0 commit comments