Better upwell messaging for everyone and show the upsell for organization admins
This commit is contained in:
parent
d12a53186a
commit
dbb234c76c
5 changed files with 62 additions and 64 deletions
|
@ -1906,37 +1906,14 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService
|
|||
|
||||
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.
|
||||
ApiService.getUserPrivateCount().then(function(resp) {
|
||||
if (resp.privateCount + 1 > resp.reposAllowed) {
|
||||
PlanService.getMinimumPlan(resp.privateCount + 1, false, function(minimum) {
|
||||
$scope.planRequired = minimum;
|
||||
});
|
||||
}
|
||||
// Determine whether private repositories are allowed for the namespace.
|
||||
checkPrivateAllowed();
|
||||
|
||||
$scope.checkingPlan = false;
|
||||
}, function() {
|
||||
$scope.planRequired = {};
|
||||
$scope.checkingPlan = false;
|
||||
});
|
||||
} else {
|
||||
ApiService.getOrganizationPrivateAllowed(null, {'orgname': namespace}).then(function(resp) {
|
||||
$scope.planRequired = resp.privateAllowed ? null : {};
|
||||
$scope.checkingPlan = false;
|
||||
}, function() {
|
||||
$scope.planRequired = {};
|
||||
$scope.checkingPlan = false;
|
||||
});
|
||||
|
||||
// Auto-set to private repo.
|
||||
$scope.repo.is_public = '0';
|
||||
}
|
||||
// Default to private repos for organizations.
|
||||
$scope.repo.is_public = isUserNamespace ? '1' : '0';
|
||||
});
|
||||
|
||||
$scope.changeNamespace = function(namespace) {
|
||||
|
@ -2015,7 +1992,35 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService
|
|||
}
|
||||
};
|
||||
|
||||
PlanService.changePlan($scope, null, $scope.planRequired.stripeId, callbacks);
|
||||
var namespace = $scope.isUserNamespace ? null : $scope.repo.namespace;
|
||||
PlanService.changePlan($scope, namespace, $scope.planRequired.stripeId, callbacks);
|
||||
};
|
||||
|
||||
var checkPrivateAllowed = function() {
|
||||
if (!$scope.repo || !$scope.repo.namespace) { return; }
|
||||
|
||||
$scope.checkingPlan = true;
|
||||
|
||||
var isUserNamespace = $scope.isUserNamespace;
|
||||
ApiService.getPrivateAllowed(isUserNamespace ? null : $scope.repo.namespace).then(function(resp) {
|
||||
$scope.checkingPlan = false;
|
||||
|
||||
if (resp['privateAllowed']) {
|
||||
$scope.planRequired = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (resp['privateCount'] == null) {
|
||||
// Organization where we are not the admin.
|
||||
$scope.planRequired = {};
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, lookup the matching plan.
|
||||
PlanService.getMinimumPlan(resp['privateCount'] + 1, !isUserNamespace, function(minimum) {
|
||||
$scope.planRequired = minimum;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var subscribedToPlan = function(sub) {
|
||||
|
@ -2025,16 +2030,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService
|
|||
PlanService.getPlan(sub.plan, function(subscribedPlan) {
|
||||
$scope.subscribedPlan = subscribedPlan;
|
||||
$scope.planRequired = null;
|
||||
|
||||
// Check to see if the current plan allows for an additional private repository to
|
||||
// be created.
|
||||
var privateAllowed = $scope.subscription.usedPrivateRepos < $scope.subscribedPlan.privateRepos;
|
||||
if (!privateAllowed) {
|
||||
// If not, find the minimum repository that does.
|
||||
PlanService.getMinimumPlan($scope.subscription.usedPrivateRepos + 1, !$scope.isUserNamespace, function(minimum) {
|
||||
$scope.planRequired = minimum;
|
||||
});
|
||||
}
|
||||
checkPrivateAllowed();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
Reference in a new issue