mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 05:29:26 -02:30
Handle notification admin user type in the UI
This commit is contained in:
@@ -16,6 +16,7 @@ function AtLayoutController ($scope, $http, strings, ProcessErrors, $transitions
|
|||||||
|
|
||||||
if (!vm.isSuperUser) {
|
if (!vm.isSuperUser) {
|
||||||
checkOrgAdmin();
|
checkOrgAdmin();
|
||||||
|
checkNotificationAdmin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -54,6 +55,25 @@ function AtLayoutController ($scope, $http, strings, ProcessErrors, $transitions
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkNotificationAdmin () {
|
||||||
|
const usersPath = `/api/v2/users/${vm.currentUserId}/roles/?role_field=notification_admin_role`;
|
||||||
|
$http.get(usersPath)
|
||||||
|
.then(({ data }) => {
|
||||||
|
console.log(data);
|
||||||
|
if (data.count > 0) {
|
||||||
|
vm.isNotificationAdmin = true;
|
||||||
|
} else {
|
||||||
|
vm.isNotificationAdmin = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(({ data, status }) => {
|
||||||
|
ProcessErrors(null, data, status, null, {
|
||||||
|
hdr: strings.get('error.HEADER'),
|
||||||
|
msg: strings.get('error.CALL', { path: usersPath, action: 'GET', status })
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AtLayoutController.$inject = ['$scope', '$http', 'ComponentsStrings', 'ProcessErrors', '$transitions'];
|
AtLayoutController.$inject = ['$scope', '$http', 'ComponentsStrings', 'ProcessErrors', '$transitions'];
|
||||||
|
|||||||
@@ -81,10 +81,10 @@
|
|||||||
<span>
|
<span>
|
||||||
</div>
|
</div>
|
||||||
<at-side-nav-item icon-class="fa-list-alt" route="credentialTypes" name="CREDENTIAL_TYPES"
|
<at-side-nav-item icon-class="fa-list-alt" route="credentialTypes" name="CREDENTIAL_TYPES"
|
||||||
system-admin-only="true">
|
system-admin-only="true">
|
||||||
</at-side-nav-item>
|
</at-side-nav-item>
|
||||||
<at-side-nav-item icon-class="fa-bell" route="notifications" name="NOTIFICATIONS"
|
<at-side-nav-item icon-class="fa-bell" route="notifications" name="NOTIFICATIONS"
|
||||||
system-admin-only="true">
|
ng-show="$parent.layoutVm.isSuperUser || $parent.layoutVm.isOrgAdmin || $parent.layoutVm.isNotificationAdmin">
|
||||||
</at-side-nav-item>
|
</at-side-nav-item>
|
||||||
<at-side-nav-item icon-class="fa-briefcase" route="managementJobsList" name="MANAGEMENT_JOBS"
|
<at-side-nav-item icon-class="fa-briefcase" route="managementJobsList" name="MANAGEMENT_JOBS"
|
||||||
system-admin-only="true">
|
system-admin-only="true">
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ export default ['$rootScope', '$scope', 'GetBasePath', 'Rest', '$q', 'Wait', 'Pr
|
|||||||
};
|
};
|
||||||
|
|
||||||
scope.hasSelectedRows = function(){
|
scope.hasSelectedRows = function(){
|
||||||
return _.any(scope.allSelected, (type) => Object.keys(type).length > 0);
|
return _.some(scope.allSelected, (type) => Object.keys(type).length > 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.selectTab = function(selected){
|
scope.selectTab = function(selected){
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ function(scope, $state, i18n, CreateSelect2, Rest, $q, Wait, ProcessErrors) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
scope.showSection2Container = function(){
|
scope.showSection2Container = function(){
|
||||||
return _.any(scope.allSelected, (type) => Object.keys(type).length > 0);
|
return _.some(scope.allSelected, (type) => Object.keys(type).length > 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.showSection2Tab = function(tab){
|
scope.showSection2Tab = function(tab){
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
Rest.setUrl(GetBasePath('projects'));
|
Rest.setUrl(GetBasePath('notification_templates'));
|
||||||
Rest.options()
|
Rest.options()
|
||||||
.then(({data}) => {
|
.then(({data}) => {
|
||||||
if (!data.actions.POST) {
|
if (!data.actions.POST) {
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ export default ['Rest', 'Wait',
|
|||||||
return $scope[i];
|
return $scope[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
params.notification_configuration = _.object(Object.keys(form.fields)
|
params.notification_configuration = _.fromPairs(Object.keys(form.fields)
|
||||||
.filter(i => (form.fields[i].ngShow && form.fields[i].ngShow.indexOf(v) > -1))
|
.filter(i => (form.fields[i].ngShow && form.fields[i].ngShow.indexOf(v) > -1))
|
||||||
.map(i => [i, processValue($scope[i], i, form.fields[i])]));
|
.map(i => [i, processValue($scope[i], i, form.fields[i])]));
|
||||||
|
|
||||||
|
|||||||
@@ -670,6 +670,8 @@ function(ConfigurationUtils, i18n, $rootScope) {
|
|||||||
query += '&role_level=workflow_admin_role';
|
query += '&role_level=workflow_admin_role';
|
||||||
} else if ($state.current.name.includes('projects')) {
|
} else if ($state.current.name.includes('projects')) {
|
||||||
query += '&role_level=project_admin_role';
|
query += '&role_level=project_admin_role';
|
||||||
|
} else if ($state.current.name.includes('notifications')) {
|
||||||
|
query += '&role_level=notification_admin_role';
|
||||||
} else {
|
} else {
|
||||||
query += '&role_level=admin_role';
|
query += '&role_level=admin_role';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -744,10 +744,20 @@ function($injector, $stateExtender, $log, i18n) {
|
|||||||
// search will think they need to be set as search tags.
|
// search will think they need to be set as search tags.
|
||||||
var params;
|
var params;
|
||||||
if(field.sourceModel === "organization"){
|
if(field.sourceModel === "organization"){
|
||||||
params = {
|
if (form.name === "notification_template") {
|
||||||
page_size: '5',
|
// Users with admin_role role level should also have
|
||||||
role_level: 'admin_role'
|
// notification_admin_role so this should handle regular admin
|
||||||
};
|
// users as well as notification admin users
|
||||||
|
params = {
|
||||||
|
page_size: '5',
|
||||||
|
role_level: 'notification_admin_role'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
params = {
|
||||||
|
page_size: '5',
|
||||||
|
role_level: 'admin_role'
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(field.sourceModel === "inventory_script"){
|
else if(field.sourceModel === "inventory_script"){
|
||||||
params = {
|
params = {
|
||||||
|
|||||||
Reference in New Issue
Block a user