Fix plans manager display to be less confusing when we show deprecated plans

This commit is contained in:
Joseph Schorr 2017-12-15 14:28:49 -05:00
parent e06a83faf9
commit 0a176d0abe
3 changed files with 15 additions and 27 deletions

View file

@ -29,14 +29,8 @@ angular.module('quay').directive('planManager', function () {
return false;
}
// A plan is visible if it is not deprecated, or if it is both not superseded
// by another plan, and also the active plan for the user.
// A plan is visible if it is not deprecated, or if it is the namespace's current plan.
if (plan['deprecated']) {
var superseded = PlanService.getPlanImmediately(plan['superseded_by']);
if (superseded) {
return !$scope.isPlanVisible(superseded, subscribedPlan);
}
return subscribedPlan && plan.stripeId === subscribedPlan.stripeId;
}
@ -44,16 +38,10 @@ angular.module('quay').directive('planManager', function () {
};
$scope.isPlanActive = function(plan, subscribedPlan) {
// A plan is active if it is either the plan directly subscribed to by the user
// or the plan which supersedes the plan to which the user is subscribed.
if (!subscribedPlan) {
return false;
}
if (subscribedPlan['deprecated'] && subscribedPlan['superseded_by']) {
return $scope.isPlanActive(plan, PlanService.getPlanImmediately(subscribedPlan['superseded_by']));
}
return plan.stripeId === subscribedPlan.stripeId;
};