Redo the permissions table to have different sections for users and robot accounts

This commit is contained in:
Joseph Schorr 2015-04-01 14:23:39 -04:00
parent 5cd500257d
commit 5fc8e632d6
3 changed files with 100 additions and 12 deletions

View file

@ -2,6 +2,21 @@
* An element which displays a table of permissions on a repository and allows them to be
* edited.
*/
angular.module('quay').filter('objectFilter', function() {
return function(obj, filterFn) {
if (!obj) { return []; }
var result = [];
angular.forEach(obj, function(value) {
if (filterFn(value)) {
result.push(value);
}
});
return result;
};
});
angular.module('quay').directive('repositoryPermissionsTable', function () {
var directiveDefinitionObject = {
priority: 0,
@ -59,22 +74,50 @@ angular.module('quay').directive('repositoryPermissionsTable', function () {
return Restangular.one(url);
};
$scope.buildEntityForPermission = function(name, permission, kind) {
var key = name + ':' + kind;
$scope.buildEntityForPermission = function(permission, kind) {
var key = permission.name + ':' + kind;
if ($scope.permissionCache[key]) {
return $scope.permissionCache[key];
}
return $scope.permissionCache[key] = {
'kind': kind,
'name': name,
'name': permission.name,
'is_robot': permission.is_robot,
'is_org_member': permission.is_org_member,
'avatar': permission.avatar
};
};
$scope.addPermission = function() {
$scope.hasPermissions = function(teams, users) {
if (teams && teams.value) {
if (Object.keys(teams.value).length > 0) {
return true;
}
}
if (users && users.value) {
if (Object.keys(users.value).length > 0) {
return true;
}
}
return false;
};
$scope.allEntries = function() {
return true;
};
$scope.onlyRobot = function(permission) {
return permission.is_robot == true;
};
$scope.onlyUser = function(permission) {
return !permission.is_robot;
};
$scope.addPermission = function() {
$scope.addPermissionInfo['working'] = true;
$scope.addNewPermission($scope.addPermissionInfo.entity, $scope.addPermissionInfo.role)
};