Merge branch 'orgs' of https://bitbucket.org/yackob03/quay into orgs

This commit is contained in:
Joseph Schorr 2013-11-05 14:47:56 -05:00
commit 6e2b2126a6
7 changed files with 148 additions and 49 deletions

View file

@ -119,15 +119,19 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
var getPlans = Restangular.one('plans');
getPlans.get().then(function(data) {
for(var i = 0; i < data.plans.length; i++) {
planDict[data.plans[i].stripeId] = data.plans[i];
var i = 0;
for(i = 0; i < data.user.length; i++) {
planDict[data.user[i].stripeId] = data.user[i];
}
plans = data.plans;
for(i = 0; i < data.business.length; i++) {
planDict[data.business[i].stripeId] = data.business[i];
}
plans = data;
callback(plans);
}, function() { callback([]); });
};
planService.getPlanList = function(callback) {
planService.getPlans = function(callback) {
planService.verifyLoaded(callback);
};
@ -137,10 +141,15 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
});
};
planService.getMinimumPlan = function(privateCount, callback) {
planService.getMinimumPlan = function(privateCount, isBusiness, callback) {
planService.verifyLoaded(function() {
for (var i = 0; i < plans.length; i++) {
var plan = plans[i];
var planSource = plans.user;
if (isBusiness) {
planSource = plans.business;
}
for (var i = 0; i < planSource.length; i++) {
var plan = planSource[i];
if (plan.privateRepos >= privateCount) {
callback(plan);
return;

View file

@ -131,7 +131,7 @@ function SigninCtrl($scope, $location, $timeout, Restangular, KeyService, UserSe
function PlansCtrl($scope, UserService, PlanService) {
// Load the list of plans.
PlanService.getPlanList(function(plans) {
PlanService.getPlans(function(plans) {
$scope.plans = plans;
$scope.status = 'ready';
});
@ -679,8 +679,8 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
function UserAdminCtrl($scope, $timeout, Restangular, PlanService, UserService, KeyService, $routeParams) {
// Load the list of plans.
PlanService.getPlanList(function(plans) {
$scope.plans = plans;
PlanService.getPlans(function(plans) {
$scope.plans = plans.user;
});
$scope.$watch(function () { return UserService.currentUser(); }, function (currentUser) {
@ -987,7 +987,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
var privateAllowed = $scope.subscription.usedPrivateRepos < $scope.subscribedPlan.privateRepos;
if (!privateAllowed) {
// If not, find the minimum repository that does.
PlanService.getMinimumPlan($scope.subscription.usedPrivateRepos + 1, function(minimum) {
PlanService.getMinimumPlan($scope.subscription.usedPrivateRepos + 1, !$scope.isUserNamespace, function(minimum) {
$scope.planRequired = minimum;
});
}
@ -1051,6 +1051,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
// Watch the namespace on the repo. If it changes, we update the plan and the public/private
// accordingly.
$scope.isUserNamespace = true;
$scope.$watch('repo.namespace', function(namespace) {
// Note: Can initially be undefined.
if (!namespace) { return; }
@ -1064,7 +1065,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
// Load the user's subscription information in case they want to create a private
// repository.
UserService.getCurrentSubscription(subscribedToPlan, function() {
PlanService.getMinimumPlan(1, function(minimum) { $scope.planRequired = minimum; });
PlanService.getMinimumPlan(1, false, function(minimum) { $scope.planRequired = minimum; });
});
} else {
$scope.planRequired = null;