@@ -12,6 +12,7 @@ angular.module('openshiftConsole')
12
12
$filter ,
13
13
$routeParams ,
14
14
AlertMessageService ,
15
+ AuthorizationService ,
15
16
BreadcrumbsService ,
16
17
DataService ,
17
18
DeploymentsService ,
@@ -78,8 +79,10 @@ angular.module('openshiftConsole')
78
79
$scope . metricsAvailable = available ;
79
80
} ) ;
80
81
82
+ var deploymentStatus = $filter ( 'deploymentStatus' ) ;
83
+
81
84
var setLogVars = function ( replicaSet ) {
82
- $scope . logCanRun = ! ( _ . includes ( [ 'New' , 'Pending' ] , $filter ( ' deploymentStatus' ) ( replicaSet ) ) ) ;
85
+ $scope . logCanRun = ! ( _ . includes ( [ 'New' , 'Pending' ] , deploymentStatus ( replicaSet ) ) ) ;
83
86
} ;
84
87
85
88
var altTextForValueFrom = $filter ( 'altTextForValueFrom' ) ;
@@ -436,16 +439,13 @@ angular.module('openshiftConsole')
436
439
if ( ! action ) {
437
440
// Loading of the page that will create deploymentConfigDeploymentsInProgress structure, which will associate running deployment to his deploymentConfig.
438
441
$scope . deploymentConfigDeploymentsInProgress = DeploymentsService . associateRunningDeploymentToDeploymentConfig ( $scope . deploymentsByDeploymentConfig ) ;
439
- } else if ( action === 'ADDED' || ( action === 'MODIFIED' && [ 'New' , 'Pending' , 'Running' ] . indexOf ( $filter ( 'deploymentStatus ' ) ( replicaSet ) ) > - 1 ) ) {
442
+ } else if ( action === 'ADDED' || ( action === 'MODIFIED' && $filter ( 'deploymentIsInProgress ' ) ( replicaSet ) ) ) {
440
443
// When new deployment id instantiated/cloned, or in case of a retry, associate him to his deploymentConfig and add him into deploymentConfigDeploymentsInProgress structure.
441
444
$scope . deploymentConfigDeploymentsInProgress [ deploymentConfigName ] = $scope . deploymentConfigDeploymentsInProgress [ deploymentConfigName ] || { } ;
442
445
$scope . deploymentConfigDeploymentsInProgress [ deploymentConfigName ] [ rsName ] = replicaSet ;
443
446
} else if ( action === 'MODIFIED' ) {
444
447
// After the deployment ends remove him from the deploymentConfigDeploymentsInProgress structure.
445
- var status = $filter ( 'deploymentStatus' ) ( replicaSet ) ;
446
- if ( status === "Complete" || status === "Failed" ) {
447
- delete $scope . deploymentConfigDeploymentsInProgress [ deploymentConfigName ] [ rsName ] ;
448
- }
448
+ delete $scope . deploymentConfigDeploymentsInProgress [ deploymentConfigName ] [ rsName ] ;
449
449
}
450
450
451
451
// Extract the causes from the encoded deployment config
@@ -490,6 +490,15 @@ angular.module('openshiftConsole')
490
490
updateHPAWarnings ( ) ;
491
491
} ) ;
492
492
493
+ var deploymentIsLatest = $filter ( 'deploymentIsLatest' ) ;
494
+
495
+ $scope . showRollbackAction = function ( ) {
496
+ return deploymentStatus ( $scope . replicaSet ) === 'Complete' &&
497
+ ! deploymentIsLatest ( $scope . replicaSet , $scope . deploymentConfig ) &&
498
+ ! $scope . replicaSet . metadata . deletionTimestamp &&
499
+ AuthorizationService . canI ( 'deploymentconfigrollbacks' , 'create' ) ;
500
+ } ;
501
+
493
502
$scope . retryFailedDeployment = function ( replicaSet ) {
494
503
DeploymentsService . retryFailedDeployment ( replicaSet , context , $scope ) ;
495
504
} ;
0 commit comments