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:
Joseph Schorr 2013-11-07 23:35:27 -05:00
parent 9f1bf1499d
commit be0fba276f
6 changed files with 46 additions and 23 deletions

View file

@ -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({});
});
};