- Fix namespace drop down to save the namespace last selected (and validate)
- Add a "can_create_repo" entry to the organization and have orgs grayed out in the new repo view if the user cannot create a repo - Fix the multiple-orgs bug in the model - Have the "create new repository" button disappear on landing if the org is selected and the user does not have create permissions for that org
This commit is contained in:
parent
4b460be4dd
commit
0c4dec6de4
10 changed files with 89 additions and 14 deletions
|
@ -47,7 +47,7 @@ function getMarkedDown(string) {
|
|||
}
|
||||
|
||||
// Start the application code itself.
|
||||
quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics', 'angulartics.mixpanel', '$strap.directives'], function($provide) {
|
||||
quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics', 'angulartics.mixpanel', '$strap.directives', 'ngCookies'], function($provide) {
|
||||
$provide.factory('UserService', ['Restangular', 'PlanService', function(Restangular, PlanService) {
|
||||
var userResponse = {
|
||||
verified: false,
|
||||
|
@ -639,20 +639,42 @@ quayApp.directive('namespaceSelector', function () {
|
|||
restrict: 'C',
|
||||
scope: {
|
||||
'user': '=user',
|
||||
'namespace': '=namespace'
|
||||
'namespace': '=namespace',
|
||||
'requireCreate': '=requireCreate'
|
||||
},
|
||||
controller: function($scope, $element) {
|
||||
controller: function($scope, $element, $cookieStore) {
|
||||
$scope.namespaces = {};
|
||||
|
||||
$scope.initialize = function(user) {
|
||||
var namespaces = {};
|
||||
namespaces[user.username] = user;
|
||||
for (var i = 0; i < user.organizations.length; ++i) {
|
||||
namespaces[user.organizations[i].name] = user.organizations[i];
|
||||
}
|
||||
|
||||
var initialNamespace = $cookieStore.get('quay.currentnamespace') || $scope.user.username;
|
||||
$scope.namespaces = namespaces;
|
||||
$scope.setNamespace($scope.namespaces[initialNamespace]);
|
||||
};
|
||||
|
||||
$scope.setNamespace = function(namespaceObj) {
|
||||
if (!namespaceObj) {
|
||||
namespaceObj = {'name': '', 'gravatar': ''};
|
||||
namespaceObj = $scope.namespaces[$scope.user.username];
|
||||
}
|
||||
|
||||
if ($scope.requireCreate && !namespaceObj.can_create_repo) {
|
||||
namespaceObj = $scope.namespaces[$scope.user.username];
|
||||
}
|
||||
|
||||
var newNamespace = namespaceObj.name || namespaceObj.username;
|
||||
$scope.namespaceObj = namespaceObj;
|
||||
$scope.namespace = namespaceObj.name || namespaceObj.username;
|
||||
$scope.namespace = newNamespace;
|
||||
$cookieStore.put('quay.currentnamespace', newNamespace);
|
||||
};
|
||||
$scope.setNamespace($scope.user);
|
||||
|
||||
$scope.$watch('user', function(user) {
|
||||
$scope.setNamespace(user);
|
||||
$scope.user = user;
|
||||
$scope.initialize(user);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Reference in a new issue