Skip to content

Commit 998521b

Browse files
author
OpenShift Bot
authored
Merge pull request #1026 from jwforres/rollback-template
Merged by openshift-bot
2 parents 617df3f + 34b8dc9 commit 998521b

File tree

4 files changed

+120
-113
lines changed

4 files changed

+120
-113
lines changed

Diff for: app/scripts/controllers/replicaSet.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ angular.module('openshiftConsole')
1212
$filter,
1313
$routeParams,
1414
AlertMessageService,
15+
AuthorizationService,
1516
BreadcrumbsService,
1617
DataService,
1718
DeploymentsService,
@@ -78,8 +79,10 @@ angular.module('openshiftConsole')
7879
$scope.metricsAvailable = available;
7980
});
8081

82+
var deploymentStatus = $filter('deploymentStatus');
83+
8184
var setLogVars = function(replicaSet) {
82-
$scope.logCanRun = !(_.includes(['New', 'Pending'], $filter('deploymentStatus')(replicaSet)));
85+
$scope.logCanRun = !(_.includes(['New', 'Pending'], deploymentStatus(replicaSet)));
8386
};
8487

8588
var altTextForValueFrom = $filter('altTextForValueFrom');
@@ -436,16 +439,13 @@ angular.module('openshiftConsole')
436439
if (!action) {
437440
// Loading of the page that will create deploymentConfigDeploymentsInProgress structure, which will associate running deployment to his deploymentConfig.
438441
$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))) {
440443
// When new deployment id instantiated/cloned, or in case of a retry, associate him to his deploymentConfig and add him into deploymentConfigDeploymentsInProgress structure.
441444
$scope.deploymentConfigDeploymentsInProgress[deploymentConfigName] = $scope.deploymentConfigDeploymentsInProgress[deploymentConfigName] || {};
442445
$scope.deploymentConfigDeploymentsInProgress[deploymentConfigName][rsName] = replicaSet;
443446
} else if (action === 'MODIFIED') {
444447
// 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];
449449
}
450450

451451
// Extract the causes from the encoded deployment config
@@ -490,6 +490,15 @@ angular.module('openshiftConsole')
490490
updateHPAWarnings();
491491
});
492492

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+
493502
$scope.retryFailedDeployment = function(replicaSet) {
494503
DeploymentsService.retryFailedDeployment(replicaSet, context, $scope);
495504
};

Diff for: app/views/browse/_replica-set-details.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<status-icon status="replicaSet | deploymentStatus"></status-icon>
1818
{{replicaSet | deploymentStatus}}
1919
<span style="margin-left: 7px;">
20-
<button ng-show="!rollBackCollapsed && (replicaSet | deploymentStatus) == 'Complete' && !(replicaSet | deploymentIsLatest : deploymentConfig) && !replicaSet.metadata.deletionTimestamp && ('deploymentconfigrollbacks' | canI : 'create')" ng-disabled="(deploymentConfigDeploymentsInProgress[deploymentConfigName] | hashSize) > 0" type="button" class="btn btn-default btn-xs" ng-click="rollBackCollapsed = !rollBackCollapsed">Roll Back</button>
20+
<button ng-show="!rollBackCollapsed && showRollbackAction()" ng-disabled="(deploymentConfigDeploymentsInProgress[deploymentConfigName] | hashSize) > 0" type="button" class="btn btn-default btn-xs" ng-click="rollBackCollapsed = !rollBackCollapsed">Roll Back</button>
2121
<div ng-show="rollBackCollapsed" class="well well-sm">
2222
Use the following settings from {{replicaSet.metadata.name}} when rolling back:
2323
<div class="checkbox">

0 commit comments

Comments
 (0)