Add warning banner when Org Admin doesn't have manage auth

This commit is contained in:
Marliana Lara 2018-03-23 17:04:24 -04:00
parent 9637058406
commit 4fab94d2ce
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE
11 changed files with 70 additions and 18 deletions

View File

@ -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;

View File

@ -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>

View File

@ -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;
};
});

View File

@ -33,9 +33,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;
});

View File

@ -6,21 +6,23 @@
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() {
const canEdit = me.get('summary_fields.user_capabilities.edit');
$scope.canAdd = false;
rbacUiControlService.canAdd('teams')
.then(function(params) {
$scope.canAdd = params.canAdd;
$scope.canAdd = params.canAdd && canEdit;
});
// search init
$scope.list = list;

View File

@ -41,6 +41,17 @@ angular.module('Teams', [])
activityStream: true,
activityStreamTarget: 'team'
},
resolve: {
list: {
resolvedModels: ['MeModel', '$q', function(Me, $q) {
const promises = {
me: new Me('get')
};
return $q.all(promises);
}]
}
},
ncyBreadcrumb: {
label: N_('TEAMS')
}

View File

@ -19,7 +19,10 @@ export default ['i18n', function(i18n) {
// the top-most node of generated state tree
stateTree: 'teams',
tabs: true,
messageBar: {
ngShow: '!user_is_system_auditor && !canAdd',
message: i18n._("Contact your System Administrator to grant you the appropriate permissions to add and edit Users and Teams.")
},
fields: {
name: {
label: i18n._('Name'),

View File

@ -30,6 +30,7 @@ export default ['$scope', '$rootScope', '$stateParams', 'UserForm', 'Rest',
init();
function init() {
$scope.canAdd = true;
$scope.isCurrentlyLoggedInUser = (parseInt(id) === $rootScope.current_user.id);
$scope.hidePagination = false;
$scope.hideSmartSearch = false;
@ -68,9 +69,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);

View File

@ -14,26 +14,28 @@ 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() {
const canEdit = me.get('summary_fields.user_capabilities.edit');
$scope.canAdd = false;
rbacUiControlService.canAdd('users')
.then(function(params) {
$scope.canAdd = params.canAdd;
$scope.canAdd = params.canAdd && canEdit;
});
// search init

View File

@ -43,6 +43,17 @@ angular.module('Users', [])
activityStream: true,
activityStreamTarget: 'user'
},
resolve: {
list: {
resolvedModels: ['MeModel', '$q', function(Me, $q) {
const promises= {
me: new Me('get')
};
return $q.all(promises);
}]
}
},
ncyBreadcrumb: {
label: N_('USERS')
}

View File

@ -20,7 +20,10 @@ export default ['i18n', function(i18n) {
stateTree: 'users',
forceListeners: true,
tabs: true,
messageBar: {
ngShow: '!user_is_system_auditor && !canAdd',
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'),