Add a roles directive and properly recolor the roles

This commit is contained in:
Joseph Schorr 2013-11-05 14:47:46 -05:00
parent 1cd4fa8d9b
commit a79b181496
6 changed files with 105 additions and 20 deletions

View file

@ -436,6 +436,34 @@ quayApp.directive('entitySearch', function () {
});
quayApp.directive('roleGroup', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/role-group.html',
replace: false,
transclude: false,
restrict: 'C',
scope: {
'roles': '=roles',
'currentRole': '=currentRole',
'roleChanged': '&roleChanged'
},
controller: function($scope, $element) {
$scope.setRole = function(role) {
$scope.currentRole = role;
if ($scope.roleChanged) {
if ($scope.changeParams) {
$scope.changeParams();
}
$scope.roleChanged({'role': role});
}
};
}
};
return directiveDefinitionObject;
});
quayApp.directive('namespaceSelector', function () {
var directiveDefinitionObject = {
priority: 0,

View file

@ -536,7 +536,13 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
});
};
$scope.setRole = function(entityName, role, kind) {
$scope.roles = [
{ 'id': 'read', 'title': 'Read', 'kind': 'success' },
{ 'id': 'write', 'title': 'Write', 'kind': 'success' },
{ 'id': 'admin', 'title': 'Admin', 'kind': 'primary' }
];
$scope.setRole = function(role, entityName, kind) {
var permission = $scope.permissions[kind][entityName];
var currentRole = permission.role;
permission.role = role;
@ -544,7 +550,7 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
var permissionPut = Restangular.one(getRestUrl('repository', namespace, name, 'permissions', kind, entityName));
permissionPut.customPUT(permission).then(function() {}, function(result) {
if (result.status == 409) {
permission.role = currentRole;
$scope.permissions[kind][entityName] = currentRole;
$('#onlyadminModal').modal({});
} else {
$('#cannotchangeModal').modal({});
@ -1098,7 +1104,13 @@ function OrgViewCtrl($rootScope, $scope, Restangular, $routeParams) {
});
};
$scope.setRole = function(teamname, role) {
$scope.teamRoles = [
{ 'id': 'member', 'title': 'Member', 'kind': 'default' },
{ 'id': 'creator', 'title': 'Creator', 'kind': 'success' },
{ 'id': 'admin', 'title': 'Admin', 'kind': 'primary' }
];
$scope.setRole = function(role, teamname) {
$scope.organization.teams[teamname].role = role;
var updateTeam = Restangular.one(getRestUrl('organization', orgname, 'team', teamname));
@ -1109,6 +1121,26 @@ function OrgViewCtrl($rootScope, $scope, Restangular, $routeParams) {
});
};
$scope.askDeleteTeam = function(teamname) {
$scope.currentDeleteTeam = teamname;
$('#confirmdeleteModal').modal({});
};
$scope.deleteTeam = function() {
$('#confirmdeleteModal').modal('hide');
if (!$scope.currentDeleteTeam) { return; }
var teamname = $scope.currentDeleteTeam;
var deleteAction = Restangular.one(getRestUrl('organization', orgname, 'team', teamname));
deleteAction.customDELETE().then(function() {
delete $scope.organization.teams[teamname];
$scope.currentDeleteTeam = null;
}, function() {
$('#cannotchangeModal').modal({});
$scope.currentDeleteTeam = null;
});
};
loadOrganization();
}