mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 00:38:45 -03:30
Merge branch '4272-add-team-user' of https://github.com/mabashian/ansible-tower into mabashian-4272-add-team-user
# Conflicts: # awx/ui/client/src/shared/stateDefinitions.factory.js
This commit is contained in:
@@ -84,7 +84,7 @@ export default ['$rootScope', '$scope', 'GetBasePath', 'Rest', '$q', 'Wait', 'Pr
|
|||||||
.map(function(role) {
|
.map(function(role) {
|
||||||
return {
|
return {
|
||||||
url: url,
|
url: url,
|
||||||
id: role.value
|
id: role.value || role.id
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export default ['templateUrl', '$state',
|
|||||||
usersDataset: '=',
|
usersDataset: '=',
|
||||||
teamsDataset: '=',
|
teamsDataset: '=',
|
||||||
resourceData: '=',
|
resourceData: '=',
|
||||||
|
withoutTeamPermissions: '@'
|
||||||
},
|
},
|
||||||
controller: controller,
|
controller: controller,
|
||||||
templateUrl: templateUrl('access/add-rbac-resource/rbac-resource'),
|
templateUrl: templateUrl('access/add-rbac-resource/rbac-resource'),
|
||||||
|
|||||||
@@ -39,16 +39,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="teams_tab" class="Form-tab"
|
<div id="teams_tab" class="Form-tab"
|
||||||
ng-click="toggleFormTabs('teams')"
|
ng-click="toggleFormTabs('teams')"
|
||||||
ng-class="{'is-selected': teamsSelected }"
|
ng-class="{'is-selected': teamsSelected }">
|
||||||
>
|
|
||||||
Teams
|
Teams
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="AddPermissions-users" class="AddPermissions-list" ng-show="usersSelected">
|
<div id="AddPermissions-users" class="AddPermissions-list" ng-if="usersSelected">
|
||||||
<rbac-multiselect-list view="Users" all-selected="allSelected" dataset="usersDataset"></rbac-multiselect-list>
|
<rbac-multiselect-list view="Users" all-selected="allSelected" dataset="usersDataset"></rbac-multiselect-list>
|
||||||
</div>
|
</div>
|
||||||
<div id="AddPermissions-teams" class="AddPermissions-list" ng-show="teamsSelected">
|
<div id="AddPermissions-teams" class="AddPermissions-list" ng-if="teamsSelected">
|
||||||
<rbac-multiselect-list view="Teams" all-selected="allSelected" dataset="teamsDataset"></rbac-multiselect-list>
|
<rbac-multiselect-list view="Teams" all-selected="allSelected" dataset="teamsDataset"></rbac-multiselect-list>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
/* jshint unused: vars */
|
/* jshint unused: vars */
|
||||||
export default
|
export default
|
||||||
[ 'templateUrl',
|
[ 'templateUrl', 'Wait', 'GetBasePath', 'Rest', '$state', 'ProcessErrors', 'Prompt', '$filter', '$rootScope',
|
||||||
function(templateUrl) {
|
function(templateUrl, Wait, GetBasePath, Rest, $state, ProcessErrors, Prompt, $filter, $rootScope) {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
scope: true,
|
scope: {
|
||||||
|
'deleteTarget': '='
|
||||||
|
},
|
||||||
templateUrl: templateUrl('access/rbac-role-column/roleList'),
|
templateUrl: templateUrl('access/rbac-role-column/roleList'),
|
||||||
link: function(scope, element, attrs) {
|
link: function(scope, element, attrs) {
|
||||||
// given a list of roles (things like "project
|
// given a list of roles (things like "project
|
||||||
@@ -12,12 +14,12 @@ export default
|
|||||||
// places in summary fields, and creates a
|
// places in summary fields, and creates a
|
||||||
// concatenated/sorted list
|
// concatenated/sorted list
|
||||||
scope.access_list = []
|
scope.access_list = []
|
||||||
.concat(scope.permission.summary_fields
|
.concat(scope.deleteTarget.summary_fields
|
||||||
.direct_access.map((i) => {
|
.direct_access.map((i) => {
|
||||||
i.role.explicit = true;
|
i.role.explicit = true;
|
||||||
return i.role;
|
return i.role;
|
||||||
}))
|
}))
|
||||||
.concat(scope.permission.summary_fields
|
.concat(scope.deleteTarget.summary_fields
|
||||||
.indirect_access.map((i) => {
|
.indirect_access.map((i) => {
|
||||||
i.role.explicit = false;
|
i.role.explicit = false;
|
||||||
return i.role;
|
return i.role;
|
||||||
@@ -34,6 +36,51 @@ export default
|
|||||||
return -1;
|
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: `<div class="Prompt-bodyQuery">Please confirm that you would like to remove <span class="Prompt-emphasis">${entry.name}</span> access from the team <span class="Prompt-emphasis">${$filter('sanitize')(entry.team_name)}</span>. 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.</div>`,
|
||||||
|
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'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
ng-repeat="entry in access_list">
|
ng-repeat="entry in access_list">
|
||||||
<div class="RoleList-deleteContainer"
|
<div class="RoleList-deleteContainer"
|
||||||
ng-if="entry.explicit && entry.user_capabilities.unattach"
|
ng-if="entry.explicit && entry.user_capabilities.unattach"
|
||||||
ng-click="deletePermission(permission, entry)">
|
ng-click="deletePermission(deleteTarget, entry)">
|
||||||
<i ng-if="entry.explicit && entry.user_capabilities.unattach"
|
<i ng-if="entry.explicit && entry.user_capabilities.unattach"
|
||||||
class="fa fa-times RoleList-tagDelete"></i>
|
class="fa fa-times RoleList-tagDelete"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -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({
|
$stateExtender.addState({
|
||||||
name: 'userCredentials',
|
name: 'userCredentials',
|
||||||
url: '/users/:user_id/credentials',
|
url: '/users/:user_id/credentials',
|
||||||
@@ -514,58 +499,6 @@ var tower = angular.module('Tower', [
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.addPermission = function(scope) {
|
|
||||||
$compile("<add-permissions class='AddPermissions'></add-permissions>")(scope);
|
|
||||||
};
|
|
||||||
$rootScope.addPermissionWithoutTeamTab = function(scope) {
|
|
||||||
$compile("<add-permissions class='AddPermissions' without-team-permissions='true'></add-permissions>")(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: `<div class="Prompt-bodyQuery">Please confirm that you would like to remove <span class="Prompt-emphasis">${entry.name}</span> access from the team <span class="Prompt-emphasis">${$filter('sanitize')(entry.team_name)}</span>. 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.</div>`,
|
|
||||||
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'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$rootScope.deletePermissionFromUser = function(userId, userName, roleName, roleType, url) {
|
$rootScope.deletePermissionFromUser = function(userId, userName, roleName, roleType, url) {
|
||||||
var action = function() {
|
var action = function() {
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ angular.module('GeneratorHelpers', [systemStatus.name])
|
|||||||
Attr(field, 'columnClass') : "";
|
Attr(field, 'columnClass') : "";
|
||||||
html += `
|
html += `
|
||||||
<td ${classList}>
|
<td ${classList}>
|
||||||
<role-list class=\"RoleList\">
|
<role-list delete-target=\"${list.iterator}\" class=\"RoleList\">
|
||||||
</role-list>
|
</role-list>
|
||||||
</td>
|
</td>
|
||||||
`;
|
`;
|
||||||
@@ -476,7 +476,7 @@ angular.module('GeneratorHelpers', [systemStatus.name])
|
|||||||
Attr(field, 'columnClass') : "";
|
Attr(field, 'columnClass') : "";
|
||||||
html += `
|
html += `
|
||||||
<td ${classList}>
|
<td ${classList}>
|
||||||
<role-list class=\"RoleList\" team-role-list="true">
|
<role-list delete-target=\"${list.iterator}\" class=\"RoleList\" team-role-list="true">
|
||||||
</role-list>
|
</role-list>
|
||||||
</td>
|
</td>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -489,18 +489,18 @@ export default ['$location', '$compile', '$rootScope', 'Attr', 'Icon',
|
|||||||
|
|
||||||
if (options.mode !== 'lookup'){
|
if (options.mode !== 'lookup'){
|
||||||
for (fld in list.fields) {
|
for (fld in list.fields) {
|
||||||
let customClass = list.fields[fld].columnClass || '';
|
let customClass = list.fields[fld].columnClass || '';
|
||||||
html += `<th
|
html += `<th
|
||||||
base-path="${list.basePath || list.name}"
|
base-path="${list.basePath || list.name}"
|
||||||
collection="${list.name}"
|
collection="${list.name}"
|
||||||
dataset="${list.iterator}_dataset"
|
dataset="${list.iterator}_dataset"
|
||||||
column-sort
|
column-sort
|
||||||
column-field="${fld}"
|
column-field="${fld}"
|
||||||
column-iterator="${list.iterator}"
|
column-iterator="${list.iterator}"
|
||||||
column-no-sort="${list.fields[fld].nosort}"
|
column-no-sort="${list.fields[fld].nosort}"
|
||||||
column-label="${list.fields[fld].label}"
|
column-label="${list.fields[fld].label}"
|
||||||
column-custom-class="${customClass}">
|
column-custom-class="${customClass}">
|
||||||
</th>`;
|
</th>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.mode === 'lookup') {
|
if (options.mode === 'lookup') {
|
||||||
|
|||||||
@@ -486,6 +486,44 @@ export default ['$injector', '$stateExtender', '$log', function($injector, $stat
|
|||||||
return state;
|
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: `<add-rbac-resource users-dataset="$resolve.usersDataset" selected="allSelected" resource-data="$resolve.resourceData" without-team-permissions="true"></add-rbac-resource>`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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) {
|
function buildListNodes(field) {
|
||||||
let states = [];
|
let states = [];
|
||||||
if(field.iterator === 'notification'){
|
if(field.iterator === 'notification'){
|
||||||
@@ -497,14 +535,18 @@ export default ['$injector', '$stateExtender', '$log', function($injector, $stat
|
|||||||
if (field.iterator === 'permission' && field.actions && field.actions.add) {
|
if (field.iterator === 'permission' && field.actions && field.actions.add) {
|
||||||
if (form.name === 'user' || form.name === 'team'){
|
if (form.name === 'user' || form.name === 'team'){
|
||||||
states.push(buildRbacUserTeamDirective());
|
states.push(buildRbacUserTeamDirective());
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
states.push(buildRbacResourceDirective());
|
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;
|
return states;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user