mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 19:10:07 -03:30
Merge pull request #1123 from marshmalien/fix/manage_org_auth
Warning banner when Org Admin doesn't have authorization
This commit is contained in:
commit
372b2925d2
@ -97,11 +97,19 @@ input#filePickerText {
|
||||
.Section-messageBar {
|
||||
width: 120%;
|
||||
margin-left: -20px;
|
||||
padding: 10px;
|
||||
padding: 10px 10px 10px 20px;
|
||||
color: @white;
|
||||
background-color: @default-link;
|
||||
}
|
||||
|
||||
.Section-messageBar-text {
|
||||
margin-left: @at-space-2x;
|
||||
}
|
||||
|
||||
.Section-messageBar-warning {
|
||||
color: @at-color-warning;
|
||||
}
|
||||
|
||||
.Section-messageBar--close {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
|
||||
@ -142,10 +142,10 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
||||
.factory('GenerateForm', ['$rootScope', '$compile', 'generateList',
|
||||
'Attr', 'Icon', 'Column',
|
||||
'NavigationLink', 'HelpCollapse', 'Empty', 'SelectIcon',
|
||||
'ActionButton', '$log', 'i18n',
|
||||
'ActionButton', 'MessageBar', '$log', 'i18n',
|
||||
function ($rootScope, $compile, GenerateList,
|
||||
Attr, Icon, Column, NavigationLink, HelpCollapse,
|
||||
Empty, SelectIcon, ActionButton, $log, i18n) {
|
||||
Empty, SelectIcon, ActionButton, MessageBar, $log, i18n) {
|
||||
return {
|
||||
|
||||
setForm: function (form) { this.form = form; },
|
||||
@ -177,6 +177,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
||||
else {
|
||||
return `
|
||||
<div ui-view="preFormView"></div>
|
||||
${MessageBar(this.form)}
|
||||
<div class="Panel">
|
||||
${html}
|
||||
<div ui-view="related"></div>
|
||||
|
||||
@ -766,4 +766,18 @@ angular.module('GeneratorHelpers', [systemStatus.name])
|
||||
return html;
|
||||
|
||||
};
|
||||
})
|
||||
|
||||
.factory('MessageBar', function() {
|
||||
return function(options) {
|
||||
let html = '';
|
||||
if (_.has(options, 'messageBar')) {
|
||||
let { messageBar } = options;
|
||||
html += `<div class="Section-messageBar" ng-show="${messageBar.ngShow}">
|
||||
<i class="Section-messageBar-warning fa fa-warning"></i>
|
||||
<span class="Section-messageBar-text">${messageBar.message}</span>
|
||||
</div>`;
|
||||
}
|
||||
return html;
|
||||
};
|
||||
});
|
||||
|
||||
@ -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');
|
||||
@ -33,9 +36,7 @@ export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest',
|
||||
});
|
||||
|
||||
$scope.$watch('team_obj.summary_fields.user_capabilities.edit', function(val) {
|
||||
if (val === false) {
|
||||
$scope.canAdd = false;
|
||||
}
|
||||
$scope.canAdd = (val === false) ? false : true;
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -6,16 +6,18 @@
|
||||
|
||||
export default ['$scope', 'Rest', 'TeamList', 'Prompt',
|
||||
'ProcessErrors', 'GetBasePath', 'Wait', '$state', '$filter',
|
||||
'rbacUiControlService', 'Dataset', 'i18n',
|
||||
'rbacUiControlService', 'Dataset', 'resolvedModels', 'i18n',
|
||||
function($scope, Rest, TeamList, Prompt, ProcessErrors,
|
||||
GetBasePath, Wait, $state, $filter, rbacUiControlService, Dataset, i18n) {
|
||||
GetBasePath, Wait, $state, $filter, rbacUiControlService, Dataset, models, i18n) {
|
||||
|
||||
const { me } = models;
|
||||
var list = TeamList,
|
||||
defaultUrl = GetBasePath('teams');
|
||||
|
||||
init();
|
||||
|
||||
function init() {
|
||||
$scope.canEdit = me.get('summary_fields.user_capabilities.edit');
|
||||
$scope.canAdd = false;
|
||||
|
||||
rbacUiControlService.canAdd('teams')
|
||||
|
||||
@ -41,6 +41,26 @@ angular.module('Teams', [])
|
||||
activityStream: true,
|
||||
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 = {
|
||||
me: new Me('get')
|
||||
};
|
||||
|
||||
return $q.all(promises);
|
||||
}]
|
||||
}
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
label: N_('TEAMS')
|
||||
}
|
||||
|
||||
@ -19,7 +19,10 @@ export default ['i18n', function(i18n) {
|
||||
// the top-most node of generated state tree
|
||||
stateTree: 'teams',
|
||||
tabs: true,
|
||||
|
||||
messageBar: {
|
||||
ngShow: 'isOrgAdmin && !canEdit',
|
||||
message: i18n._("Contact your System Administrator to grant you the appropriate permissions to add and edit Users and Teams.")
|
||||
},
|
||||
fields: {
|
||||
name: {
|
||||
label: i18n._('Name'),
|
||||
|
||||
@ -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,6 +31,8 @@ export default ['$scope', '$rootScope', '$stateParams', 'UserForm', 'Rest',
|
||||
init();
|
||||
|
||||
function init() {
|
||||
$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;
|
||||
@ -68,9 +71,7 @@ export default ['$scope', '$rootScope', '$stateParams', 'UserForm', 'Rest',
|
||||
});
|
||||
|
||||
$scope.$watch('user_obj.summary_fields.user_capabilities.edit', function(val) {
|
||||
if (val === false) {
|
||||
$scope.canAdd = false;
|
||||
}
|
||||
$scope.canAdd = (val === false) ? false : true;
|
||||
});
|
||||
|
||||
setScopeFields(data);
|
||||
|
||||
@ -14,21 +14,23 @@ const user_type_options = [
|
||||
|
||||
export default ['$scope', '$rootScope', 'Rest', 'UserList', 'Prompt',
|
||||
'ProcessErrors', 'GetBasePath', 'Wait', '$state', '$filter',
|
||||
'rbacUiControlService', 'Dataset', 'i18n',
|
||||
'rbacUiControlService', 'Dataset', 'i18n', 'resolvedModels',
|
||||
function($scope, $rootScope, Rest, UserList, Prompt,
|
||||
ProcessErrors, GetBasePath, Wait, $state, $filter, rbacUiControlService,
|
||||
Dataset, i18n) {
|
||||
Dataset, 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 list = UserList,
|
||||
defaultUrl = GetBasePath('users');
|
||||
defaultUrl = GetBasePath('users');
|
||||
|
||||
init();
|
||||
|
||||
function init() {
|
||||
$scope.canEdit = me.get('summary_fields.user_capabilities.edit');
|
||||
$scope.canAdd = false;
|
||||
|
||||
rbacUiControlService.canAdd('users')
|
||||
|
||||
@ -43,6 +43,26 @@ angular.module('Users', [])
|
||||
activityStream: true,
|
||||
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= {
|
||||
me: new Me('get')
|
||||
};
|
||||
|
||||
return $q.all(promises);
|
||||
}]
|
||||
}
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
label: N_('USERS')
|
||||
}
|
||||
|
||||
@ -20,7 +20,10 @@ export default ['i18n', function(i18n) {
|
||||
stateTree: 'users',
|
||||
forceListeners: true,
|
||||
tabs: true,
|
||||
|
||||
messageBar: {
|
||||
ngShow: 'isOrgAdmin && !canEdit',
|
||||
message: i18n._("Contact your System Administrator to grant you the appropriate permissions to add and edit Users and Teams.")
|
||||
},
|
||||
fields: {
|
||||
first_name: {
|
||||
label: i18n._('First Name'),
|
||||
|
||||
@ -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