mirror of
https://github.com/ansible/awx.git
synced 2026-05-15 05:17:36 -02:30
Implemented team role removal
Also threw in the little fa-users icon when it's a permission coming from a team #1919
This commit is contained in:
@@ -26,6 +26,10 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
.fa-users {
|
||||||
|
margin-left: 0.5em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.RoleList-tag--deletable {
|
.RoleList-tag--deletable {
|
||||||
|
|||||||
@@ -11,23 +11,16 @@ export default
|
|||||||
// auditor") which are pulled from two different
|
// auditor") which are pulled from two different
|
||||||
// places in summary fields, and creates a
|
// places in summary fields, and creates a
|
||||||
// concatenated/sorted list
|
// concatenated/sorted list
|
||||||
scope.roles = []
|
scope.access_list = []
|
||||||
.concat(scope.permission.summary_fields
|
.concat(scope.permission.summary_fields
|
||||||
.direct_access.map(function(i) {
|
.direct_access.map(function(i) {
|
||||||
return {
|
i.role.explicit = true;
|
||||||
name: i.role.name,
|
return i.role;
|
||||||
roleId: i.role.id,
|
|
||||||
resourceName: i.role.resource_name,
|
|
||||||
explicit: true
|
|
||||||
};
|
|
||||||
}))
|
}))
|
||||||
.concat(scope.permission.summary_fields
|
.concat(scope.permission.summary_fields
|
||||||
.indirect_access.map(function(i) {
|
.indirect_access.map(function(i) {
|
||||||
return {
|
i.role.explicit = false;
|
||||||
name: i.role.name,
|
return i.role;
|
||||||
roleId: i.role.id,
|
|
||||||
explicit: false
|
|
||||||
};
|
|
||||||
}))
|
}))
|
||||||
.sort(function(a, b) {
|
.sort(function(a, b) {
|
||||||
if (a.name
|
if (a.name
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
<div class="RoleList-tagContainer"
|
<div class="RoleList-tagContainer"
|
||||||
ng-repeat="role in roles">
|
ng-repeat="entry in access_list">
|
||||||
<div class="RoleList-deleteContainer"
|
<div class="RoleList-deleteContainer"
|
||||||
ng-if="role.explicit"
|
ng-if="entry.explicit"
|
||||||
ng-click="deletePermission(permission.id, role.roleId, permission.username, role.name, role.resourceName)">
|
ng-click="deletePermission(permission, entry)">
|
||||||
<i ng-if="role.explicit"
|
<i ng-if="entry.explicit"
|
||||||
class="fa fa-times RoleList-tagDelete"></i>
|
class="fa fa-times RoleList-tagDelete"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="RoleList-tag"
|
<div class="RoleList-tag"
|
||||||
ng-class="{'RoleList-tag--deletable': role.explicit}">
|
ng-class="{'RoleList-tag--deletable': entry.explicit}">
|
||||||
<span class="RoleList-name">{{ role.name }}</span>
|
<span class="RoleList-name">{{ entry.name }}</span>
|
||||||
|
<i ng-show='entry.team_id' class="fa fa-users" ng-attr-title='{{entry.team_name}}'></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -509,31 +509,48 @@ var tower = angular.module('Tower', [
|
|||||||
$compile("<add-permissions class='AddPermissions'></add-permissions>")(scope);
|
$compile("<add-permissions class='AddPermissions'></add-permissions>")(scope);
|
||||||
};
|
};
|
||||||
|
|
||||||
$rootScope.deletePermission = function (user, role, userName,
|
$rootScope.deletePermission = function (user, accessListEntry) {
|
||||||
roleName, resourceName) {
|
let entry = accessListEntry;
|
||||||
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 });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
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({
|
Prompt({
|
||||||
hdr: 'Remove Role from ' + resourceName,
|
hdr: `Team access removal`,
|
||||||
body: '<div class="Prompt-bodyQuery">Confirm the removal of the <span class="Prompt-emphasis">' + roleName + '</span> role associated with ' + userName + '.</div>',
|
body: `<div class="Prompt-bodyQuery">Please confirm that you would like to remove <span class="Prompt-emphasis">${entry.name}</span> access to from the team <span class="Prompt-emphasis">${entry.team_name}</span>. This will affect all members of the team.</div>`,
|
||||||
action: action,
|
action: action,
|
||||||
|
actionText: 'REMOVE TEAM ACCESS'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Prompt({
|
||||||
|
hdr: `User access removal`,
|
||||||
|
body: `<div class="Prompt-bodyQuery">Please confirm that you would like to remove <span class="Prompt-emphasis">${entry.name}</span> access from <span class="Prompt-emphasis">${user.username}</span>.</div>`,
|
||||||
|
action: action,
|
||||||
actionText: 'REMOVE'
|
actionText: 'REMOVE'
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$rootScope.deletePermissionFromUser = function (userId, userName, roleName, roleType, url) {
|
$rootScope.deletePermissionFromUser = function (userId, userName, roleName, roleType, url) {
|
||||||
var action = function () {
|
var action = function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user