From a828e8b005521abda19f3a464723e3cf2f6a2424 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Mon, 16 May 2016 15:21:04 -0400 Subject: [PATCH 1/2] Implemented team role removal Also threw in the little fa-users icon when it's a permission coming from a team #1919 --- awx/ui/client/src/access/roleList.block.less | 4 ++ .../client/src/access/roleList.directive.js | 17 ++---- .../client/src/access/roleList.partial.html | 13 ++-- awx/ui/client/src/app.js | 59 ++++++++++++------- 4 files changed, 54 insertions(+), 39 deletions(-) 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 9a2e38ccfd..a205a6c8d5 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -509,31 +509,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 to 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 () { From 2c652a7375b27a5ff11ba04bc0e1dfc948acfdee Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Mon, 16 May 2016 16:14:53 -0400 Subject: [PATCH 2/2] Typo --- awx/ui/client/src/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index a205a6c8d5..d153122d72 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -538,7 +538,7 @@ var tower = angular.module('Tower', [ if (accessListEntry.team_id) { Prompt({ hdr: `Team access removal`, - body: `
Please confirm that you would like to remove ${entry.name} access to from the team ${entry.team_name}. This will affect all members of the team.
`, + 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' });