Bug fixes:
- Report proper errors when trying to change permissions - Turn off the auto-caps of the team names - Fix the is_org_member checks everywhere - Fix resetting of roles if the change was not successful
This commit is contained in:
parent
9f1bf1499d
commit
be0fba276f
6 changed files with 46 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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({});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -55,7 +55,8 @@
|
|||
<h4 class="modal-title">Cannot change team</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
You do not have permission to change properties on teams.
|
||||
<span ng-show="!roleError">You do not have permission to change properties on teams.</span>
|
||||
<span ng-show="roleError">{{ roleError }}</span>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
<td class="{{ 'user entity ' + (permission.is_org_member? '' : 'outside') }}">
|
||||
<i class="fa fa-user"></i>
|
||||
<span>{{name}}</span>
|
||||
<i class="fa fa-exclamation-triangle" ng-show="permission.is_org_member !== undefined && !permission.is_org_member" data-trigger="hover" bs-popover="{'content': 'This user is not a member of the organization'}"></i>
|
||||
<i class="fa fa-exclamation-triangle" ng-show="permission.is_org_member === false" data-trigger="hover" bs-popover="{'content': 'This user is not a member of the organization'}"></i>
|
||||
</td>
|
||||
<td class="user-permissions">
|
||||
<div class="btn-group btn-group-sm">
|
||||
|
@ -263,7 +263,7 @@
|
|||
|
||||
|
||||
<!-- Modal message dialog -->
|
||||
<div class="modal fade" id="onlyadminModal">
|
||||
<div class="modal fade" id="channgechangepermModal">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
|
@ -271,7 +271,8 @@
|
|||
<h4 class="modal-title">Cannot change permissions</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
The selected permissions could not be changed because the user is the only <b>admin</b> on the repo.
|
||||
<span ng-show="!changePermError">You do not have permission to change the permissions on the repository.</span>
|
||||
<span ng-show="changePermError">{{ changePermError }}</span>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
|
|
Reference in a new issue