- Add API for returning the user’s used private repos and available private repos
- Fix the same API for orgs - Change the chosen plan in the create repo view to use the API - Add an account indicator if the user is over their plan
This commit is contained in:
parent
95a8915546
commit
ed82d65dd1
5 changed files with 74 additions and 14 deletions
|
@ -810,23 +810,34 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
|||
|
||||
var isUserNamespace = (namespace == $scope.user.username);
|
||||
|
||||
$scope.checkingPlan = true;
|
||||
$scope.planRequired = null;
|
||||
$scope.isUserNamespace = isUserNamespace;
|
||||
|
||||
if (isUserNamespace) {
|
||||
// Load the user's subscription information in case they want to create a private
|
||||
// repository.
|
||||
PlanService.getSubscription(null, subscribedToPlan, function() {
|
||||
PlanService.getMinimumPlan(1, false, function(minimum) { $scope.planRequired = minimum; });
|
||||
var checkPrivateAllowed = Restangular.one('user/private');
|
||||
checkPrivateAllowed.get().then(function(resp) {
|
||||
if (resp.privateCount + 1 > resp.reposAllowed) {
|
||||
PlanService.getMinimumPlan(resp.privateCount + 1, false, function(minimum) {
|
||||
$scope.planRequired = minimum;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.checkingPlan = false;
|
||||
}, function() {
|
||||
$scope.planRequired = {};
|
||||
$scope.checkingPlan = false;
|
||||
});
|
||||
} else {
|
||||
$scope.planRequired = null;
|
||||
|
||||
var checkPrivateAllowed = Restangular.one('organization/' + namespace + '/private');
|
||||
checkPrivateAllowed.get().then(function(resp) {
|
||||
$scope.planRequired = resp.privateAllowed ? null : {};
|
||||
$scope.checkingPlan = false;
|
||||
}, function() {
|
||||
$scope.planRequired = {};
|
||||
$scope.checkingPlan = false;
|
||||
});
|
||||
|
||||
// Auto-set to private repo.
|
||||
|
|
Reference in a new issue