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:
|
except model.InvalidOrganizationException:
|
||||||
# This repository is not part of an organization
|
# This repository is not part of an organization
|
||||||
pass
|
pass
|
||||||
|
except model.DataModelException as ex:
|
||||||
|
error_resp = jsonify({
|
||||||
|
'message': ex.message,
|
||||||
|
})
|
||||||
|
error_resp.status_code = 400
|
||||||
|
return error_resp
|
||||||
|
|
||||||
|
|
||||||
resp = jsonify(perm_view)
|
resp = jsonify(perm_view)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
@ -1051,7 +1058,15 @@ def change_team_permissions(namespace, repository, teamname):
|
||||||
def delete_user_permissions(namespace, repository, username):
|
def delete_user_permissions(namespace, repository, username):
|
||||||
permission = AdministerRepositoryPermission(namespace, repository)
|
permission = AdministerRepositoryPermission(namespace, repository)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
|
try:
|
||||||
model.delete_user_permission(username, namespace, repository)
|
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)
|
return make_response('Deleted', 204)
|
||||||
|
|
||||||
abort(403) # Permission denied
|
abort(403) # Permission denied
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.organization-header-element .team-name {
|
.organization-header-element .team-name {
|
||||||
text-transform: capitalize;
|
text-transform: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.organization-header-element .header-buttons {
|
.organization-header-element .header-buttons {
|
||||||
|
@ -1590,7 +1590,7 @@ p.editable:hover i {
|
||||||
|
|
||||||
.org-view .team-title {
|
.org-view .team-title {
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
text-transform: capitalize;
|
text-transform: none;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1608,7 +1608,7 @@ p.editable:hover i {
|
||||||
|
|
||||||
.org-admin .team-link {
|
.org-admin .team-link {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
text-transform: capitalize;
|
text-transform: none;
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -582,12 +582,11 @@ quayApp.directive('roleGroup', function () {
|
||||||
},
|
},
|
||||||
controller: function($scope, $element) {
|
controller: function($scope, $element) {
|
||||||
$scope.setRole = function(role) {
|
$scope.setRole = function(role) {
|
||||||
$scope.currentRole = role;
|
if ($scope.currentRole == role) { return; }
|
||||||
if ($scope.roleChanged) {
|
if ($scope.roleChanged) {
|
||||||
if ($scope.changeParams) {
|
|
||||||
$scope.changeParams();
|
|
||||||
}
|
|
||||||
$scope.roleChanged({'role': role});
|
$scope.roleChanged({'role': role});
|
||||||
|
} else {
|
||||||
|
$scope.currentRole = role;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -518,7 +518,7 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
|
||||||
// Don't allow duplicates.
|
// Don't allow duplicates.
|
||||||
if ($scope.permissions[entity.kind][entity.name]) { return; }
|
if ($scope.permissions[entity.kind][entity.name]) { return; }
|
||||||
|
|
||||||
if (!entity.is_org_member) {
|
if (entity.is_org_member === false) {
|
||||||
$scope.currentAddEntity = entity;
|
$scope.currentAddEntity = entity;
|
||||||
$('#confirmaddoutsideModal').modal('show');
|
$('#confirmaddoutsideModal').modal('show');
|
||||||
return;
|
return;
|
||||||
|
@ -535,9 +535,10 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
|
||||||
var permissionDelete = Restangular.one(getRestUrl('repository', namespace, name, 'permissions', kind, entityName));
|
var permissionDelete = Restangular.one(getRestUrl('repository', namespace, name, 'permissions', kind, entityName));
|
||||||
permissionDelete.customDELETE().then(function() {
|
permissionDelete.customDELETE().then(function() {
|
||||||
delete $scope.permissions[kind][entityName];
|
delete $scope.permissions[kind][entityName];
|
||||||
}, function(result) {
|
}, function(resp) {
|
||||||
if (result.status == 409) {
|
if (resp.status == 409) {
|
||||||
$('#onlyadminModal').modal({});
|
$scope.changePermError = resp.data || '';
|
||||||
|
$('#channgechangepermModal').modal({});
|
||||||
} else {
|
} else {
|
||||||
$('#cannotchangeModal').modal({});
|
$('#cannotchangeModal').modal({});
|
||||||
}
|
}
|
||||||
|
@ -570,10 +571,12 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
|
||||||
permission.role = role;
|
permission.role = role;
|
||||||
|
|
||||||
var permissionPut = Restangular.one(getRestUrl('repository', namespace, name, 'permissions', kind, entityName));
|
var permissionPut = Restangular.one(getRestUrl('repository', namespace, name, 'permissions', kind, entityName));
|
||||||
permissionPut.customPUT(permission).then(function() {}, function(result) {
|
permissionPut.customPUT(permission).then(function() {}, function(resp) {
|
||||||
if (result.status == 409) {
|
$scope.permissions[kind][entityName] = {'role': currentRole};
|
||||||
$scope.permissions[kind][entityName] = currentRole;
|
$scope.changePermError = null;
|
||||||
$('#onlyadminModal').modal({});
|
if (resp.status == 409 || resp.data) {
|
||||||
|
$scope.changePermError = resp.data || '';
|
||||||
|
$('#channgechangepermModal').modal({});
|
||||||
} else {
|
} else {
|
||||||
$('#cannotchangeModal').modal({});
|
$('#cannotchangeModal').modal({});
|
||||||
}
|
}
|
||||||
|
@ -1112,12 +1115,16 @@ function OrgViewCtrl($rootScope, $scope, Restangular, $routeParams) {
|
||||||
];
|
];
|
||||||
|
|
||||||
$scope.setRole = function(role, teamname) {
|
$scope.setRole = function(role, teamname) {
|
||||||
|
var previousRole = $scope.organization.teams[teamname].role;
|
||||||
$scope.organization.teams[teamname].role = role;
|
$scope.organization.teams[teamname].role = role;
|
||||||
|
|
||||||
var updateTeam = Restangular.one(getRestUrl('organization', orgname, 'team', teamname));
|
var updateTeam = Restangular.one(getRestUrl('organization', orgname, 'team', teamname));
|
||||||
var data = $scope.organization.teams[teamname];
|
var data = $scope.organization.teams[teamname];
|
||||||
|
|
||||||
updateTeam.customPUT(data).then(function(resp) {
|
updateTeam.customPUT(data).then(function(resp) {
|
||||||
}, function() {
|
}, function(resp) {
|
||||||
|
$scope.organization.teams[teamname].role = previousRole;
|
||||||
|
$scope.roleError = resp.data || '';
|
||||||
$('#cannotChangeTeamModal').modal({});
|
$('#cannotChangeTeamModal').modal({});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,7 +55,8 @@
|
||||||
<h4 class="modal-title">Cannot change team</h4>
|
<h4 class="modal-title">Cannot change team</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<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>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
<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') }}">
|
<td class="{{ 'user entity ' + (permission.is_org_member? '' : 'outside') }}">
|
||||||
<i class="fa fa-user"></i>
|
<i class="fa fa-user"></i>
|
||||||
<span>{{name}}</span>
|
<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>
|
||||||
<td class="user-permissions">
|
<td class="user-permissions">
|
||||||
<div class="btn-group btn-group-sm">
|
<div class="btn-group btn-group-sm">
|
||||||
|
@ -263,7 +263,7 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- Modal message dialog -->
|
<!-- Modal message dialog -->
|
||||||
<div class="modal fade" id="onlyadminModal">
|
<div class="modal fade" id="channgechangepermModal">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
|
@ -271,7 +271,8 @@
|
||||||
<h4 class="modal-title">Cannot change permissions</h4>
|
<h4 class="modal-title">Cannot change permissions</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<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>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
|
|
Reference in a new issue