+
diff --git a/awx/ui/client/src/access/rbac-role-column/roleList.directive.js b/awx/ui/client/src/access/rbac-role-column/roleList.directive.js
index 97682d0bc9..10b589cf7c 100644
--- a/awx/ui/client/src/access/rbac-role-column/roleList.directive.js
+++ b/awx/ui/client/src/access/rbac-role-column/roleList.directive.js
@@ -1,10 +1,12 @@
/* jshint unused: vars */
export default
- [ 'templateUrl',
- function(templateUrl) {
+ [ 'templateUrl', 'Wait', 'GetBasePath', 'Rest', '$state', 'ProcessErrors', 'Prompt', '$filter', '$rootScope',
+ function(templateUrl, Wait, GetBasePath, Rest, $state, ProcessErrors, Prompt, $filter, $rootScope) {
return {
restrict: 'E',
- scope: true,
+ scope: {
+ 'deleteTarget': '='
+ },
templateUrl: templateUrl('access/rbac-role-column/roleList'),
link: function(scope, element, attrs) {
// given a list of roles (things like "project
@@ -12,12 +14,12 @@ export default
// places in summary fields, and creates a
// concatenated/sorted list
scope.access_list = []
- .concat(scope.permission.summary_fields
+ .concat(scope.deleteTarget.summary_fields
.direct_access.map((i) => {
i.role.explicit = true;
return i.role;
}))
- .concat(scope.permission.summary_fields
+ .concat(scope.deleteTarget.summary_fields
.indirect_access.map((i) => {
i.role.explicit = false;
return i.role;
@@ -34,6 +36,51 @@ export default
return -1;
}
});
+
+ scope.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');
+ $state.go('.', null, { reload: true });
+ })
+ .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: `Team access removal`,
+ body: `
Please confirm that you would like to remove ${entry.name} access from the team ${$filter('sanitize')(entry.team_name)}. This will affect all members of the team. If you would like to only remove access for this particular user, please remove them from 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'
+ });
+ }
+ };
}
};
}
diff --git a/awx/ui/client/src/access/rbac-role-column/roleList.partial.html b/awx/ui/client/src/access/rbac-role-column/roleList.partial.html
index 365a20f061..1a25afead0 100644
--- a/awx/ui/client/src/access/rbac-role-column/roleList.partial.html
+++ b/awx/ui/client/src/access/rbac-role-column/roleList.partial.html
@@ -2,7 +2,7 @@
ng-repeat="entry in access_list">
+ ng-click="deletePermission(deleteTarget, entry)">
diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js
index 3d23bdcf8f..b2af552581 100644
--- a/awx/ui/client/src/app.js
+++ b/awx/ui/client/src/app.js
@@ -468,21 +468,6 @@ var tower = angular.module('Tower', [
}
});
-
- $stateExtender.addState({
- name: 'teamUsers',
- url: '/teams/:team_id/users',
- templateUrl: urlPrefix + 'partials/teams.html',
- controller: UsersList,
- resolve: {
- Users: ['UsersList', 'QuerySet', '$stateParams', 'GetBasePath', (list, qs, $stateParams, GetBasePath) => {
- let path = GetBasePath(list.basePath) || GetBasePath(list.name);
- return qs.search(path, $stateParams[`${list.iterator}_search`]);
- }]
- }
- });
-
-
$stateExtender.addState({
name: 'userCredentials',
url: '/users/:user_id/credentials',
@@ -514,58 +499,6 @@ var tower = angular.module('Tower', [
}
});
- $rootScope.addPermission = function(scope) {
- $compile("
")(scope);
- };
- $rootScope.addPermissionWithoutTeamTab = function(scope) {
- $compile("
")(scope);
- };
-
- $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');
- $state.go('.', null, { reload: true });
- })
- .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: `Team access removal`,
- body: `
Please confirm that you would like to remove ${entry.name} access from the team ${$filter('sanitize')(entry.team_name)}. This will affect all members of the team. If you would like to only remove access for this particular user, please remove them from 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() {
$('#prompt-modal').modal('hide');
diff --git a/awx/ui/client/src/shared/generator-helpers.js b/awx/ui/client/src/shared/generator-helpers.js
index 0b350639e2..3d12d2a627 100644
--- a/awx/ui/client/src/shared/generator-helpers.js
+++ b/awx/ui/client/src/shared/generator-helpers.js
@@ -467,7 +467,7 @@ angular.module('GeneratorHelpers', [systemStatus.name])
Attr(field, 'columnClass') : "";
html += `
-
+
|
`;
@@ -476,7 +476,7 @@ angular.module('GeneratorHelpers', [systemStatus.name])
Attr(field, 'columnClass') : "";
html += `
-
+
|
`;
diff --git a/awx/ui/client/src/shared/list-generator/list-generator.factory.js b/awx/ui/client/src/shared/list-generator/list-generator.factory.js
index cac1e129aa..1c4214be44 100644
--- a/awx/ui/client/src/shared/list-generator/list-generator.factory.js
+++ b/awx/ui/client/src/shared/list-generator/list-generator.factory.js
@@ -489,18 +489,18 @@ export default ['$location', '$compile', '$rootScope', 'Attr', 'Icon',
if (options.mode !== 'lookup'){
for (fld in list.fields) {
- let customClass = list.fields[fld].columnClass || '';
- html += `
- | `;
+ let customClass = list.fields[fld].columnClass || '';
+ html += `
+ | `;
}
}
if (options.mode === 'lookup') {
diff --git a/awx/ui/client/src/shared/stateDefinitions.factory.js b/awx/ui/client/src/shared/stateDefinitions.factory.js
index 34a507a40d..0c7117e5de 100644
--- a/awx/ui/client/src/shared/stateDefinitions.factory.js
+++ b/awx/ui/client/src/shared/stateDefinitions.factory.js
@@ -485,6 +485,44 @@ export default ['$injector', '$stateExtender', '$log', function($injector, $stat
// }
return state;
}
+
+ function buildRbacUserDirective() {
+ let states = [];
+
+ states.push($stateExtender.buildDefinition({
+ name: `${formStateDefinition.name}.users.add`,
+ squashSearchUrl: true,
+ url: '/add-user',
+ params: {
+ user_search: {
+ value: { order_by: 'username', page_size: '5' },
+ dynamic: true,
+ }
+ },
+ views: {
+ [`modal@${formStateDefinition.name}`]: {
+ template: `
`
+ }
+ },
+ resolve: {
+ usersDataset: ['addPermissionsUsersList', 'QuerySet', '$stateParams', 'GetBasePath',
+ function(list, qs, $stateParams, GetBasePath) {
+ let path = GetBasePath(list.basePath) || GetBasePath(list.name);
+ return qs.search(path, $stateParams.user_search);
+
+ }
+ ]
+ },
+ onExit: function($state) {
+ if ($state.transition) {
+ $('#add-permissions-modal').modal('hide');
+ $('.modal-backdrop').remove();
+ $('body').removeClass('modal-open');
+ }
+ },
+ }));
+ return states;
+ }
function buildListNodes(field) {
let states = [];
@@ -497,14 +535,18 @@ export default ['$injector', '$stateExtender', '$log', function($injector, $stat
if (field.iterator === 'permission' && field.actions && field.actions.add) {
if (form.name === 'user' || form.name === 'team'){
states.push(buildRbacUserTeamDirective());
-
}
else {
states.push(buildRbacResourceDirective());
}
- states = _.flatten(states);
+ }
+ else if (field.iterator === 'user' && field.actions && field.actions.add) {
+ if(form.name === 'team') {
+ states.push(buildRbacUserDirective());
+ }
}
}
+ states = _.flatten(states);
return states;
}