@@ -14,6 +14,7 @@ import {
14
14
DeploymentWithConfigType ,
15
15
ExcludedImageNode ,
16
16
FilterStates ,
17
+ getIsApprovalPolicyConfigured ,
17
18
getIsRequestAborted ,
18
19
getStageTitle ,
19
20
Icon ,
@@ -381,7 +382,11 @@ export const getDeployButtonStyle = (
381
382
export const getIsConsumedImageAvailable = ( materials : CDMaterialType [ ] ) =>
382
383
materials . some ( ( materialItem ) => materialItem . deployed && materialItem . latest ) ?? false
383
384
384
- const getTagWarningRelatedToMaterial = ( updatedMaterials : CDMaterialType [ ] , selectedImageTagName : string ) : string => {
385
+ const getTagWarningRelatedToMaterial = (
386
+ updatedMaterials : CDMaterialType [ ] ,
387
+ selectedImageTagName : string ,
388
+ canSelectNonApprovedImage : boolean ,
389
+ ) : string => {
385
390
const selectedImage = updatedMaterials . find ( ( material ) => material . isSelected )
386
391
387
392
const selectedTagParsedName =
@@ -399,11 +404,23 @@ const getTagWarningRelatedToMaterial = (updatedMaterials: CDMaterialType[], sele
399
404
return `Tag ${ selectedTagParsedName } is not eligible for deployment`
400
405
}
401
406
407
+ const isNonApprovedImage =
408
+ ! selectedImage . userApprovalMetadata ||
409
+ selectedImage . userApprovalMetadata . approvalRuntimeState !== ApprovalRuntimeStateType . approved
410
+
411
+ if ( isNonApprovedImage && ! canSelectNonApprovedImage ) {
412
+ return `Tag ${ selectedTagParsedName } is not approved`
413
+ }
414
+
402
415
return ''
403
416
}
404
417
405
418
// If tag is not present, and image is selected we will show mixed tag
406
- export const getUpdatedMaterialsForTagSelection = ( tagName : string , materials : CDMaterialType [ ] ) => {
419
+ export const getUpdatedMaterialsForTagSelection = (
420
+ tagName : string ,
421
+ materials : CDMaterialType [ ] ,
422
+ canSelectNonApprovedImage : boolean ,
423
+ ) => {
407
424
const sourceMaterials = structuredClone ( materials )
408
425
409
426
const updatedMaterials = sourceMaterials . map ( ( material , materialIndex ) => {
@@ -438,7 +455,7 @@ export const getUpdatedMaterialsForTagSelection = (tagName: string, materials: C
438
455
439
456
const selectedImage = updatedMaterials . find ( ( material ) => material . isSelected )
440
457
441
- const tagsWarning = getTagWarningRelatedToMaterial ( updatedMaterials , tagName )
458
+ const tagsWarning = getTagWarningRelatedToMaterial ( updatedMaterials , tagName , canSelectNonApprovedImage )
442
459
443
460
if ( selectedImage && tagsWarning ) {
444
461
selectedImage . isSelected = false
@@ -522,6 +539,8 @@ export const getBulkCDDetailsMapFromResponse: GetBulkCDDetailsMapFromResponseTyp
522
539
const { tagsWarning, updatedMaterials } = getUpdatedMaterialsForTagSelection (
523
540
selectedTagName ,
524
541
materialResponse . value . materials ,
542
+ ! getIsApprovalPolicyConfigured ( materialResponse ?. value . deploymentApprovalInfo ?. approvalConfigData ) ||
543
+ getIsExceptionUser ( materialResponse . value ) ,
525
544
)
526
545
527
546
const parsedTagsWarning = searchText ? '' : tagsWarning
0 commit comments