diff --git a/endpoints/api.py b/endpoints/api.py index f167c3e5f..16583d4ed 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -1012,6 +1012,13 @@ def change_user_permissions(namespace, repository, username): except model.InvalidOrganizationException: # This repository is not part of an organization pass + except model.DataModelException as ex: + error_resp = jsonify({ + 'message': ex.message, + }) + error_resp.status_code = 400 + return error_resp + resp = jsonify(perm_view) if request.method == 'POST': @@ -1051,7 +1058,15 @@ def change_team_permissions(namespace, repository, teamname): def delete_user_permissions(namespace, repository, username): permission = AdministerRepositoryPermission(namespace, repository) if permission.can(): - model.delete_user_permission(username, namespace, repository) + try: + model.delete_user_permission(username, namespace, repository) + except model.DataModelException as ex: + error_resp = jsonify({ + 'message': ex.message, + }) + error_resp.status_code = 400 + return error_resp + return make_response('Deleted', 204) abort(403) # Permission denied diff --git a/static/css/quay.css b/static/css/quay.css index 753bd6e13..b0c2d1983 100644 --- a/static/css/quay.css +++ b/static/css/quay.css @@ -32,7 +32,7 @@ } .organization-header-element .team-name { - text-transform: capitalize; + text-transform: none; } .organization-header-element .header-buttons { @@ -1590,7 +1590,7 @@ p.editable:hover i { .org-view .team-title { font-size: 20px; - text-transform: capitalize; + text-transform: none; padding: 4px; } @@ -1608,7 +1608,7 @@ p.editable:hover i { .org-admin .team-link { display: inline-block; - text-transform: capitalize; + text-transform: none; margin-right: 20px; } diff --git a/static/js/app.js b/static/js/app.js index c73caee0e..b20117e6a 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -582,12 +582,11 @@ quayApp.directive('roleGroup', function () { }, controller: function($scope, $element) { $scope.setRole = function(role) { - $scope.currentRole = role; - if ($scope.roleChanged) { - if ($scope.changeParams) { - $scope.changeParams(); - } + if ($scope.currentRole == role) { return; } + if ($scope.roleChanged) { $scope.roleChanged({'role': role}); + } else { + $scope.currentRole = role; } }; } diff --git a/static/js/controllers.js b/static/js/controllers.js index a172c4f25..1c530738f 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -518,7 +518,7 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) { // Don't allow duplicates. if ($scope.permissions[entity.kind][entity.name]) { return; } - if (!entity.is_org_member) { + if (entity.is_org_member === false) { $scope.currentAddEntity = entity; $('#confirmaddoutsideModal').modal('show'); return; @@ -535,9 +535,10 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) { var permissionDelete = Restangular.one(getRestUrl('repository', namespace, name, 'permissions', kind, entityName)); permissionDelete.customDELETE().then(function() { delete $scope.permissions[kind][entityName]; - }, function(result) { - if (result.status == 409) { - $('#onlyadminModal').modal({}); + }, function(resp) { + if (resp.status == 409) { + $scope.changePermError = resp.data || ''; + $('#channgechangepermModal').modal({}); } else { $('#cannotchangeModal').modal({}); } @@ -570,10 +571,12 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) { permission.role = role; var permissionPut = Restangular.one(getRestUrl('repository', namespace, name, 'permissions', kind, entityName)); - permissionPut.customPUT(permission).then(function() {}, function(result) { - if (result.status == 409) { - $scope.permissions[kind][entityName] = currentRole; - $('#onlyadminModal').modal({}); + permissionPut.customPUT(permission).then(function() {}, function(resp) { + $scope.permissions[kind][entityName] = {'role': currentRole}; + $scope.changePermError = null; + if (resp.status == 409 || resp.data) { + $scope.changePermError = resp.data || ''; + $('#channgechangepermModal').modal({}); } else { $('#cannotchangeModal').modal({}); } @@ -1111,13 +1114,17 @@ function OrgViewCtrl($rootScope, $scope, Restangular, $routeParams) { { 'id': 'admin', 'title': 'Admin', 'kind': 'primary' } ]; - $scope.setRole = function(role, teamname) { + $scope.setRole = function(role, teamname) { + var previousRole = $scope.organization.teams[teamname].role; $scope.organization.teams[teamname].role = role; var updateTeam = Restangular.one(getRestUrl('organization', orgname, 'team', teamname)); var data = $scope.organization.teams[teamname]; + updateTeam.customPUT(data).then(function(resp) { - }, function() { + }, function(resp) { + $scope.organization.teams[teamname].role = previousRole; + $scope.roleError = resp.data || ''; $('#cannotChangeTeamModal').modal({}); }); }; diff --git a/static/partials/org-view.html b/static/partials/org-view.html index f26c35c67..c1011d74f 100644 --- a/static/partials/org-view.html +++ b/static/partials/org-view.html @@ -55,7 +55,8 @@