Better messaging in create repo

This commit is contained in:
Joseph Schorr 2014-01-15 19:15:38 -05:00
parent 74feb4216a
commit 9d26c79db0
4 changed files with 25 additions and 4 deletions

View file

@ -146,7 +146,8 @@ def user_view(user):
'name': o.username,
'gravatar': compute_hash(o.email),
'is_org_admin': admin_org.can(),
'can_create_repo': admin_org.can() or CreateRepositoryPermission(o.username).can()
'can_create_repo': admin_org.can() or CreateRepositoryPermission(o.username).can(),
'preferred_namespace': not (o.stripe_id is None)
}
organizations = model.get_user_organizations(user.username)
@ -169,7 +170,8 @@ def user_view(user):
'organizations': [org_view(o) for o in organizations],
'logins': [login_view(login) for login in logins],
'can_create_repo': True,
'invoice_email': user.invoice_email
'invoice_email': user.invoice_email,
'preferred_namespace': not (user.stripe_id is None)
}

View file

@ -2167,15 +2167,20 @@ quayApp.directive('namespaceSelector', function () {
$scope.namespaces = {};
$scope.initialize = function(user) {
var preferredNamespace = user.username;
var namespaces = {};
namespaces[user.username] = user;
if (user.organizations) {
for (var i = 0; i < user.organizations.length; ++i) {
namespaces[user.organizations[i].name] = user.organizations[i];
if (user.organizations[i].preferred_namespace) {
preferredNamespace = user.organizations[i].name;
}
}
}
var initialNamespace = $routeParams['namespace'] || CookieService.get('quay.namespace') || $scope.user.username;
var initialNamespace = $routeParams['namespace'] || CookieService.get('quay.namespace') ||
preferredNamespace || $scope.user.username;
$scope.namespaces = namespaces;
$scope.setNamespace($scope.namespaces[initialNamespace]);
};
@ -2198,6 +2203,12 @@ quayApp.directive('namespaceSelector', function () {
}
};
$scope.$watch('namespace', function(namespace) {
if ($scope.namespaceObj && namespace && namespace != $scope.namespaceObj.username) {
$scope.setNamespace($scope.namespaces[namespace]);
}
});
$scope.$watch('user', function(user) {
$scope.user = user;
$scope.initialize(user);

View file

@ -878,7 +878,8 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
fetchRepository();
}
function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, UserService, KeyService, $routeParams, $http) {
function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, UserService, CookieService, KeyService,
$routeParams, $http) {
if ($routeParams['migrate']) {
$('#migrateTab').tab('show')
}
@ -956,6 +957,7 @@ function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, Use
};
ApiService.convertUserToOrganization(data).then(function(resp) {
CookieService.putPermanent('quay.namespace', $scope.cuser.username);
UserService.load();
$location.path('/');
}, function(resp) {
@ -1168,6 +1170,10 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService
}
});
$scope.changeNamespace = function(namespace) {
$scope.repo.namespace = namespace;
};
$scope.createNewRepo = function() {
$('#repoName').popover('hide');

View file

@ -81,6 +81,8 @@
This will cost $<span>{{ planRequired.price / 100 }}</span>/month.
</div>
<a class="btn btn-primary" ng-click="upgradePlan()" ng-show="!planChanging">Upgrade now</a>
<span ng-show="user.organizations.length == 1">or did you mean to create this repository
under <a href="javascript:void(0)" ng-click="changeNamespace(user.organizations[0].name)"><b>{{ user.organizations[0].name }}</b></a>?</span>
<div class="quay-spinner" ng-show="planChanging"></div>
</div>