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