mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 19:30:39 -03:30
Only show banner if user is an org admin without edit capabilities
This commit is contained in:
parent
4fab94d2ce
commit
5ffe0f40d2
@ -5,17 +5,20 @@
|
||||
*************************************************/
|
||||
|
||||
export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest',
|
||||
'ProcessErrors', 'GetBasePath', 'Wait', '$state', 'OrgAdminLookup',
|
||||
'ProcessErrors', 'GetBasePath', 'Wait', '$state', 'OrgAdminLookup', 'resolvedModels',
|
||||
function($scope, $rootScope, $stateParams, TeamForm, Rest, ProcessErrors,
|
||||
GetBasePath, Wait, $state, OrgAdminLookup) {
|
||||
GetBasePath, Wait, $state, OrgAdminLookup, models) {
|
||||
|
||||
const { me } = models;
|
||||
var form = TeamForm,
|
||||
id = $stateParams.team_id,
|
||||
defaultUrl = GetBasePath('teams') + id;
|
||||
id = $stateParams.team_id,
|
||||
defaultUrl = GetBasePath('teams') + id;
|
||||
|
||||
init();
|
||||
|
||||
function init() {
|
||||
$scope.canEdit = me.get('summary_fields.user_capabilities.edit');
|
||||
$scope.isOrgAdmin = me.get('related.admin_of_organizations.count') > 0;
|
||||
$scope.team_id = id;
|
||||
Rest.setUrl(defaultUrl);
|
||||
Wait('start');
|
||||
|
||||
@ -17,12 +17,12 @@ export default ['$scope', 'Rest', 'TeamList', 'Prompt',
|
||||
init();
|
||||
|
||||
function init() {
|
||||
const canEdit = me.get('summary_fields.user_capabilities.edit');
|
||||
$scope.canEdit = me.get('summary_fields.user_capabilities.edit');
|
||||
$scope.canAdd = false;
|
||||
|
||||
rbacUiControlService.canAdd('teams')
|
||||
.then(function(params) {
|
||||
$scope.canAdd = params.canAdd && canEdit;
|
||||
$scope.canAdd = params.canAdd;
|
||||
});
|
||||
// search init
|
||||
$scope.list = list;
|
||||
|
||||
@ -42,6 +42,15 @@ angular.module('Teams', [])
|
||||
activityStreamTarget: 'team'
|
||||
},
|
||||
resolve: {
|
||||
edit: {
|
||||
resolvedModels: ['MeModel', '$q', function(Me, $q) {
|
||||
const promises = {
|
||||
me: new Me('get').then((me) => me.extend('get', 'admin_of_organizations'))
|
||||
};
|
||||
|
||||
return $q.all(promises);
|
||||
}]
|
||||
},
|
||||
list: {
|
||||
resolvedModels: ['MeModel', '$q', function(Me, $q) {
|
||||
const promises = {
|
||||
|
||||
@ -20,7 +20,7 @@ export default ['i18n', function(i18n) {
|
||||
stateTree: 'teams',
|
||||
tabs: true,
|
||||
messageBar: {
|
||||
ngShow: '!user_is_system_auditor && !canAdd',
|
||||
ngShow: 'isOrgAdmin && !canEdit',
|
||||
message: i18n._("Contact your System Administrator to grant you the appropriate permissions to add and edit Users and Teams.")
|
||||
},
|
||||
fields: {
|
||||
|
||||
@ -43,7 +43,7 @@ export default ['i18n', function(i18n) {
|
||||
awToolTip: i18n._('Create a new team'),
|
||||
actionClass: 'btn List-buttonSubmit',
|
||||
buttonContent: '+ ' + i18n._('ADD'),
|
||||
ngShow: 'canAdd'
|
||||
ngShow: 'canAdd && canEdit'
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -14,14 +14,15 @@ const user_type_options = [
|
||||
|
||||
export default ['$scope', '$rootScope', '$stateParams', 'UserForm', 'Rest',
|
||||
'ProcessErrors', 'GetBasePath', 'Wait', 'CreateSelect2',
|
||||
'$state', 'i18n',
|
||||
'$state', 'i18n', 'resolvedModels',
|
||||
function($scope, $rootScope, $stateParams, UserForm, Rest, ProcessErrors,
|
||||
GetBasePath, Wait, CreateSelect2, $state, i18n) {
|
||||
GetBasePath, Wait, CreateSelect2, $state, i18n, models) {
|
||||
|
||||
for (var i = 0; i < user_type_options.length; i++) {
|
||||
user_type_options[i].label = i18n._(user_type_options[i].label);
|
||||
}
|
||||
|
||||
const { me } = models;
|
||||
var form = UserForm,
|
||||
master = {},
|
||||
id = $stateParams.user_id,
|
||||
@ -30,7 +31,8 @@ export default ['$scope', '$rootScope', '$stateParams', 'UserForm', 'Rest',
|
||||
init();
|
||||
|
||||
function init() {
|
||||
$scope.canAdd = true;
|
||||
$scope.canEdit = me.get('summary_fields.user_capabilities.edit');
|
||||
$scope.isOrgAdmin = me.get('related.admin_of_organizations.count') > 0;
|
||||
$scope.isCurrentlyLoggedInUser = (parseInt(id) === $rootScope.current_user.id);
|
||||
$scope.hidePagination = false;
|
||||
$scope.hideSmartSearch = false;
|
||||
|
||||
@ -30,12 +30,12 @@ export default ['$scope', '$rootScope', 'Rest', 'UserList', 'Prompt',
|
||||
init();
|
||||
|
||||
function init() {
|
||||
const canEdit = me.get('summary_fields.user_capabilities.edit');
|
||||
$scope.canEdit = me.get('summary_fields.user_capabilities.edit');
|
||||
$scope.canAdd = false;
|
||||
|
||||
rbacUiControlService.canAdd('users')
|
||||
.then(function(params) {
|
||||
$scope.canAdd = params.canAdd && canEdit;
|
||||
$scope.canAdd = params.canAdd;
|
||||
});
|
||||
|
||||
// search init
|
||||
|
||||
@ -44,6 +44,15 @@ angular.module('Users', [])
|
||||
activityStreamTarget: 'user'
|
||||
},
|
||||
resolve: {
|
||||
edit: {
|
||||
resolvedModels: ['MeModel', '$q', function(Me, $q) {
|
||||
const promises= {
|
||||
me: new Me('get').then((me) => me.extend('get', 'admin_of_organizations'))
|
||||
};
|
||||
|
||||
return $q.all(promises);
|
||||
}]
|
||||
},
|
||||
list: {
|
||||
resolvedModels: ['MeModel', '$q', function(Me, $q) {
|
||||
const promises= {
|
||||
|
||||
@ -21,7 +21,7 @@ export default ['i18n', function(i18n) {
|
||||
forceListeners: true,
|
||||
tabs: true,
|
||||
messageBar: {
|
||||
ngShow: '!user_is_system_auditor && !canAdd',
|
||||
ngShow: 'isOrgAdmin && !canEdit',
|
||||
message: i18n._("Contact your System Administrator to grant you the appropriate permissions to add and edit Users and Teams.")
|
||||
},
|
||||
fields: {
|
||||
|
||||
@ -48,7 +48,7 @@ export default ['i18n', function(i18n) {
|
||||
awToolTip: i18n._('Create a new user'),
|
||||
actionClass: 'btn List-buttonSubmit',
|
||||
buttonContent: '+ ' + i18n._('ADD'),
|
||||
ngShow: 'canAdd'
|
||||
ngShow: 'canAdd && canEdit'
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user