diff --git a/static/js/app.js b/static/js/app.js index a00b286dd..828792760 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -146,7 +146,9 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics', planService.getPlan = function(planId, callback) { planService.verifyLoaded(function() { - callback(planDict[planId]); + if (planDict[planId]) { + callback(planDict[planId]); + } }); }; @@ -517,7 +519,8 @@ quayApp.directive('planManager', function () { restrict: 'C', scope: { 'user': '=user', - 'organization': '=organization' + 'organization': '=organization', + 'readyForPlan': '&readyForPlan' }, controller: function($scope, $element, PlanService, Restangular) { var hasSubscription = false; @@ -598,10 +601,19 @@ quayApp.directive('planManager', function () { }; var loadPlans = function() { + if ($scope.plans) { return; } if (!$scope.user && !$scope.organization) { return; } + PlanService.getPlans(function(plans) { $scope.plans = plans[$scope.organization ? 'business' : 'user']; update(); + + if ($scope.readyForPlan) { + var planRequested = $scope.readyForPlan(); + if (planRequested) { + $scope.changeSubscription(planRequested); + } + } }); }; @@ -609,12 +621,16 @@ quayApp.directive('planManager', function () { $scope.planLoading = true; loadPlans(); - $scope.$watch('organization', function() { - loadPlans(); + $scope.$watch('organization', function(organization) { + if ($scope.organization != organization && !$scope.user) { + loadPlans(); + } }); - $scope.$watch('user', function() { - loadPlans(); + $scope.$watch('user', function(user) { + if ($scope.user != user && !$scope.organization) { + loadPlans(); + } }); } }; diff --git a/static/js/controllers.js b/static/js/controllers.js index 304139652..ada86a872 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -675,11 +675,10 @@ function UserAdminCtrl($scope, $timeout, Restangular, PlanService, UserService, $scope.loading = false; }, true); - // Show the subscribe dialog if a plan was requested. - var requested = $routeParams['plan'] - if (requested !== undefined && requested !== 'free') { - // TODO: this. - } + $scope.readyForPlan = function() { + // Show the subscribe dialog if a plan was requested. + return $routeParams['plan']; + }; $scope.loading = true; $scope.updatingUser = false; diff --git a/static/partials/user-admin.html b/static/partials/user-admin.html index ee8b343fb..f3371e001 100644 --- a/static/partials/user-admin.html +++ b/static/partials/user-admin.html @@ -36,7 +36,7 @@
-
+