Fix it so the user admin page shows the plan pay dialog when loaded with the proper parameter
This commit is contained in:
parent
62d057d7aa
commit
fb1732d069
3 changed files with 27 additions and 12 deletions
|
@ -146,7 +146,9 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
|
||||||
|
|
||||||
planService.getPlan = function(planId, callback) {
|
planService.getPlan = function(planId, callback) {
|
||||||
planService.verifyLoaded(function() {
|
planService.verifyLoaded(function() {
|
||||||
callback(planDict[planId]);
|
if (planDict[planId]) {
|
||||||
|
callback(planDict[planId]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -517,7 +519,8 @@ quayApp.directive('planManager', function () {
|
||||||
restrict: 'C',
|
restrict: 'C',
|
||||||
scope: {
|
scope: {
|
||||||
'user': '=user',
|
'user': '=user',
|
||||||
'organization': '=organization'
|
'organization': '=organization',
|
||||||
|
'readyForPlan': '&readyForPlan'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, PlanService, Restangular) {
|
controller: function($scope, $element, PlanService, Restangular) {
|
||||||
var hasSubscription = false;
|
var hasSubscription = false;
|
||||||
|
@ -598,10 +601,19 @@ quayApp.directive('planManager', function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
var loadPlans = function() {
|
var loadPlans = function() {
|
||||||
|
if ($scope.plans) { return; }
|
||||||
if (!$scope.user && !$scope.organization) { return; }
|
if (!$scope.user && !$scope.organization) { return; }
|
||||||
|
|
||||||
PlanService.getPlans(function(plans) {
|
PlanService.getPlans(function(plans) {
|
||||||
$scope.plans = plans[$scope.organization ? 'business' : 'user'];
|
$scope.plans = plans[$scope.organization ? 'business' : 'user'];
|
||||||
update();
|
update();
|
||||||
|
|
||||||
|
if ($scope.readyForPlan) {
|
||||||
|
var planRequested = $scope.readyForPlan();
|
||||||
|
if (planRequested) {
|
||||||
|
$scope.changeSubscription(planRequested);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -609,12 +621,16 @@ quayApp.directive('planManager', function () {
|
||||||
$scope.planLoading = true;
|
$scope.planLoading = true;
|
||||||
loadPlans();
|
loadPlans();
|
||||||
|
|
||||||
$scope.$watch('organization', function() {
|
$scope.$watch('organization', function(organization) {
|
||||||
loadPlans();
|
if ($scope.organization != organization && !$scope.user) {
|
||||||
|
loadPlans();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.$watch('user', function() {
|
$scope.$watch('user', function(user) {
|
||||||
loadPlans();
|
if ($scope.user != user && !$scope.organization) {
|
||||||
|
loadPlans();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -675,11 +675,10 @@ function UserAdminCtrl($scope, $timeout, Restangular, PlanService, UserService,
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
// Show the subscribe dialog if a plan was requested.
|
$scope.readyForPlan = function() {
|
||||||
var requested = $routeParams['plan']
|
// Show the subscribe dialog if a plan was requested.
|
||||||
if (requested !== undefined && requested !== 'free') {
|
return $routeParams['plan'];
|
||||||
// TODO: this.
|
};
|
||||||
}
|
|
||||||
|
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
$scope.updatingUser = false;
|
$scope.updatingUser = false;
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<!-- Plans tab -->
|
<!-- Plans tab -->
|
||||||
<div id="plan" class="tab-pane active">
|
<div id="plan" class="tab-pane active">
|
||||||
<div class="plan-manager" user="user.username"></div>
|
<div class="plan-manager" user="user.username" ready-for-plan="readyForPlan()"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Change password tab -->
|
<!-- Change password tab -->
|
||||||
|
|
Reference in a new issue