GUACAMOLE-5: Implement management interface for sharing profile permissions.

This commit is contained in:
Michael Jumper
2016-08-04 18:21:32 -07:00
parent 8a8ae8496c
commit e3db19d633
5 changed files with 86 additions and 1 deletions

View File

@@ -633,6 +633,10 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
{
label: "MANAGE_USER.FIELD_HEADER_CREATE_NEW_CONNECTION_GROUPS",
value: PermissionSet.SystemPermissionType.CREATE_CONNECTION_GROUP
},
{
label: "MANAGE_USER.FIELD_HEADER_CREATE_NEW_SHARING_PROFILES",
value: PermissionSet.SystemPermissionType.CREATE_SHARING_PROFILE
}
];
@@ -861,6 +865,45 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
};
/**
* Updates the permissionsAdded and permissionsRemoved permission sets to
* reflect the addition of the given sharing profile permission.
*
* @param {String} identifier
* The identifier of the sharing profile to add READ permission for.
*/
var addSharingProfilePermission = function addSharingProfilePermission(identifier) {
// If permission was previously removed, simply un-remove it
if (PermissionSet.hasSharingProfilePermission(permissionsRemoved, PermissionSet.ObjectPermissionType.READ, identifier))
PermissionSet.removeSharingProfilePermission(permissionsRemoved, PermissionSet.ObjectPermissionType.READ, identifier);
// Otherwise, explicitly add the permission
else
PermissionSet.addSharingProfilePermission(permissionsAdded, PermissionSet.ObjectPermissionType.READ, identifier);
};
/**
* Updates the permissionsAdded and permissionsRemoved permission sets to
* reflect the removal of the given sharing profile permission.
*
* @param {String} identifier
* The identifier of the sharing profile to remove READ permission for.
*/
var removeSharingProfilePermission = function removeSharingProfilePermission(identifier) {
// If permission was previously added, simply un-add it
if (PermissionSet.hasSharingProfilePermission(permissionsAdded, PermissionSet.ObjectPermissionType.READ, identifier))
PermissionSet.removeSharingProfilePermission(permissionsAdded, PermissionSet.ObjectPermissionType.READ, identifier);
// Otherwise, explicitly remove the permission
else
PermissionSet.addSharingProfilePermission(permissionsRemoved, PermissionSet.ObjectPermissionType.READ, identifier);
};
// Expose permission query and modification functions to group list template
$scope.groupListContext = {
@@ -918,6 +961,28 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
else
removeConnectionGroupPermission(identifier);
},
/**
* Notifies the controller that a change has been made to the given
* sharing profile permission for the user being edited. This only
* applies to READ permissions.
*
* @param {String} identifier
* The identifier of the sharing profile affected by the changed
* permission.
*/
sharingProfilePermissionChanged : function sharingProfilePermissionChanged(identifier) {
// Determine current permission setting
var value = $scope.permissionFlags.sharingProfilePermissions.READ[identifier];
// Add/remove permission depending on flag state
if (value)
addSharingProfilePermission(identifier);
else
removeSharingProfilePermission(identifier);
}
};