diff --git a/awx/ui/client/src/access/roleList.block.less b/awx/ui/client/src/access/roleList.block.less index 4ee5c146f5..0723c3451d 100644 --- a/awx/ui/client/src/access/roleList.block.less +++ b/awx/ui/client/src/access/roleList.block.less @@ -26,6 +26,10 @@ white-space: nowrap; text-overflow: ellipsis; overflow: hidden; + + .fa-users { + margin-left: 0.5em; + } } .RoleList-tag--deletable { diff --git a/awx/ui/client/src/access/roleList.directive.js b/awx/ui/client/src/access/roleList.directive.js index 376a00f085..ff7c5eb409 100644 --- a/awx/ui/client/src/access/roleList.directive.js +++ b/awx/ui/client/src/access/roleList.directive.js @@ -11,23 +11,16 @@ export default // auditor") which are pulled from two different // places in summary fields, and creates a // concatenated/sorted list - scope.roles = [] + scope.access_list = [] .concat(scope.permission.summary_fields .direct_access.map(function(i) { - return { - name: i.role.name, - roleId: i.role.id, - resourceName: i.role.resource_name, - explicit: true - }; + i.role.explicit = true; + return i.role; })) .concat(scope.permission.summary_fields .indirect_access.map(function(i) { - return { - name: i.role.name, - roleId: i.role.id, - explicit: false - }; + i.role.explicit = false; + return i.role; })) .sort(function(a, b) { if (a.name diff --git a/awx/ui/client/src/access/roleList.partial.html b/awx/ui/client/src/access/roleList.partial.html index 469604496e..f050af8b38 100644 --- a/awx/ui/client/src/access/roleList.partial.html +++ b/awx/ui/client/src/access/roleList.partial.html @@ -1,13 +1,14 @@
+ ng-repeat="entry in access_list">
- +
- {{ role.name }} + ng-class="{'RoleList-tag--deletable': entry.explicit}"> + {{ entry.name }} +
diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 0512604253..bd53e65ed4 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -513,31 +513,48 @@ var tower = angular.module('Tower', [ $compile("")(scope); }; - $rootScope.deletePermission = function (user, role, userName, - roleName, resourceName) { - var action = function () { - $('#prompt-modal').modal('hide'); - Wait('start'); - var url = GetBasePath("users") + user + "/roles/"; - Rest.setUrl(url); - Rest.post({"disassociate": true, "id": role}) - .success(function () { - Wait('stop'); - $rootScope.$broadcast("refreshList", "permission"); - }) - .error(function (data, status) { - ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', - msg: 'Could not disacssociate user from role. Call to ' + url + ' failed. DELETE returned status: ' + status }); - }); - }; + $rootScope.deletePermission = function (user, accessListEntry) { + let entry = accessListEntry; + let action = function () { + $('#prompt-modal').modal('hide'); + Wait('start'); + + let url; + if (entry.team_id) { + url = GetBasePath("teams") + entry.team_id + "/roles/"; + } else { + url = GetBasePath("users") + user.id + "/roles/"; + } + + Rest.setUrl(url); + Rest.post({"disassociate": true, "id": entry.id}) + .success(function () { + Wait('stop'); + $rootScope.$broadcast("refreshList", "permission"); + }) + .error(function (data, status) { + ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', + msg: 'Failed to remove access. Call to ' + url + ' failed. DELETE returned status: ' + status }); + }); + }; + + if (accessListEntry.team_id) { Prompt({ - hdr: 'Remove Role from ' + resourceName, - body: '
Confirm the removal of the ' + roleName + ' role associated with ' + userName + '.
', - action: action, + hdr: `Team access removal`, + body: `
Please confirm that you would like to remove ${entry.name} access from the team ${entry.team_name}. This will affect all members of the team.
`, + action: action, + actionText: 'REMOVE TEAM ACCESS' + }); + } else { + Prompt({ + hdr: `User access removal`, + body: `
Please confirm that you would like to remove ${entry.name} access from ${user.username}.
`, + action: action, actionText: 'REMOVE' }); - }; + } + }; $rootScope.deletePermissionFromUser = function (userId, userName, roleName, roleType, url) { var action = function () {