Finish permissions table support
This commit is contained in:
parent
dc5d40ddc3
commit
32956b6713
3 changed files with 31 additions and 15 deletions
|
@ -22,6 +22,7 @@ angular.module('quay').directive('repositoryPermissionsTable', function () {
|
|||
$scope.permissionResources = {'team': {}, 'user': {}};
|
||||
$scope.permissionCache = {};
|
||||
$scope.permissions = {};
|
||||
$scope.addPermissionInfo = {};
|
||||
|
||||
var loadAllPermissions = function() {
|
||||
if (!$scope.repository) { return; }
|
||||
|
@ -71,13 +72,21 @@ angular.module('quay').directive('repositoryPermissionsTable', function () {
|
|||
};
|
||||
};
|
||||
|
||||
$scope.addPermission = function() {
|
||||
$scope.addPermissionInfo['working'] = true;
|
||||
$scope.addNewPermission($scope.addPermissionInfo.entity, $scope.addPermissionInfo.role)
|
||||
};
|
||||
|
||||
$scope.grantPermission = function(entity, callback) {
|
||||
$scope.addRole(entity.name, 'read', entity.kind, callback);
|
||||
};
|
||||
|
||||
$scope.addNewPermission = function(entity) {
|
||||
$scope.addNewPermission = function(entity, opt_role) {
|
||||
// Don't allow duplicates.
|
||||
if (!entity || !entity.kind || $scope.permissions[entity.kind][entity.name]) { return; }
|
||||
if (!entity || !entity.kind || $scope.permissions[entity.kind][entity.name]) {
|
||||
$scope.addPermissionInfo = {};
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity.is_org_member === false) {
|
||||
$scope.grantPermissionInfo = {
|
||||
|
@ -86,7 +95,7 @@ angular.module('quay').directive('repositoryPermissionsTable', function () {
|
|||
return;
|
||||
}
|
||||
|
||||
$scope.addRole(entity.name, 'read', entity.kind);
|
||||
$scope.addRole(entity.name, opt_role || 'read', entity.kind);
|
||||
};
|
||||
|
||||
$scope.deleteRole = function(entityName, kind) {
|
||||
|
@ -109,11 +118,13 @@ angular.module('quay').directive('repositoryPermissionsTable', function () {
|
|||
|
||||
var errorHandler = ApiService.errorDisplay('Cannot change permission', function() {
|
||||
opt_callback && opt_callback(false);
|
||||
$scope.addPermissionInfo = {};
|
||||
});
|
||||
|
||||
var endpoint = getPermissionEndpoint(entityName, kind);
|
||||
endpoint.customPUT(permission).then(function(result) {
|
||||
$scope.permissions[kind][entityName] = result;
|
||||
$scope.addPermissionInfo = {};
|
||||
opt_callback && opt_callback(true)
|
||||
}, errorHandler);
|
||||
};
|
||||
|
|
Reference in a new issue