diff --git a/static/js/app.js b/static/js/app.js index a4d65c357..fc8f25dc0 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -648,16 +648,17 @@ quayApp.directive('planManager', function () { }; var loadPlans = function() { - if ($scope.plans) { return; } + if ($scope.plans || $scope.loadingPlans) { return; } if (!$scope.user && !$scope.organization) { return; } + $scope.loadingPlans = true; PlanService.getPlans(function(plans) { $scope.plans = plans[$scope.organization ? 'business' : 'user']; update(); if ($scope.readyForPlan) { var planRequested = $scope.readyForPlan(); - if (planRequested) { + if (planRequested && planRequested != getFreePlan()) { $scope.changeSubscription(planRequested); } } diff --git a/static/js/controllers.js b/static/js/controllers.js index a4773fefe..34426d187 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -89,7 +89,7 @@ function SigninCtrl($scope, $location, $timeout, Restangular, KeyService, UserSe $scope.status = 'ready'; }; -function PlansCtrl($scope, UserService, PlanService) { +function PlansCtrl($scope, $location, UserService, PlanService) { // Load the list of plans. PlanService.getPlans(function(plans) { $scope.plans = plans; @@ -107,6 +107,14 @@ function PlansCtrl($scope, UserService, PlanService) { $('#signinModal').modal({}); } }; + + $scope.createOrg = function(plan) { + if ($scope.user && !$scope.user.anonymous) { + document.location = '/organizations/new/?plan=' + plan; + } else { + $('#signinModal').modal({}); + } + }; } function GuideCtrl($scope) { @@ -1253,7 +1261,7 @@ function OrgsCtrl($scope, UserService) { browserchrome.update(); } -function NewOrgCtrl($scope, $timeout, $location, UserService, PlanService, Restangular) { +function NewOrgCtrl($scope, $routeParams, $timeout, $location, UserService, PlanService, Restangular) { $scope.loading = true; $scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) { @@ -1261,10 +1269,17 @@ function NewOrgCtrl($scope, $timeout, $location, UserService, PlanService, Resta $scope.loading = false; }, true); + requested = $routeParams['plan']; + // Load the list of plans. PlanService.getPlans(function(plans) { $scope.plans = plans.business; $scope.currentPlan = null; + if (requested) { + PlanService.getPlan(requested, function(plan) { + $scope.currentPlan = plan; + }); + } }); $scope.setPlan = function(plan) { diff --git a/static/partials/plans.html b/static/partials/plans.html index 0f34fe018..24ac8b1e4 100644 --- a/static/partials/plans.html +++ b/static/partials/plans.html @@ -38,7 +38,7 @@
{{ plan.privateRepos }} private repositories
{{ plan.audience }}
SSL secured connections
- +