diff --git a/awx/ui/client/lib/components/layout/layout.directive.js b/awx/ui/client/lib/components/layout/layout.directive.js index c6fddc51e4..71726ac031 100644 --- a/awx/ui/client/lib/components/layout/layout.directive.js +++ b/awx/ui/client/lib/components/layout/layout.directive.js @@ -16,6 +16,7 @@ function AtLayoutController ($scope, $http, strings, ProcessErrors, $transitions if (!vm.isSuperUser) { 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']; diff --git a/awx/ui/client/lib/components/layout/layout.partial.html b/awx/ui/client/lib/components/layout/layout.partial.html index 4acc9fd108..de0f9ce272 100644 --- a/awx/ui/client/lib/components/layout/layout.partial.html +++ b/awx/ui/client/lib/components/layout/layout.partial.html @@ -81,10 +81,10 @@ + system-admin-only="true"> + ng-show="$parent.layoutVm.isSuperUser || $parent.layoutVm.isOrgAdmin || $parent.layoutVm.isNotificationAdmin"> diff --git a/awx/ui/client/src/access/add-rbac-resource/rbac-resource.controller.js b/awx/ui/client/src/access/add-rbac-resource/rbac-resource.controller.js index c0656ebf79..7c1ca5be35 100644 --- a/awx/ui/client/src/access/add-rbac-resource/rbac-resource.controller.js +++ b/awx/ui/client/src/access/add-rbac-resource/rbac-resource.controller.js @@ -88,7 +88,7 @@ export default ['$rootScope', '$scope', 'GetBasePath', 'Rest', '$q', 'Wait', 'Pr }; 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){ diff --git a/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.controller.js b/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.controller.js index 7c1f53cc4c..f8ecec5446 100644 --- a/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.controller.js +++ b/awx/ui/client/src/access/add-rbac-user-team/rbac-user-team.controller.js @@ -94,7 +94,7 @@ function(scope, $state, i18n, CreateSelect2, Rest, $q, Wait, ProcessErrors) { }; 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){ diff --git a/awx/ui/client/src/notifications/add/add.controller.js b/awx/ui/client/src/notifications/add/add.controller.js index f87fea7006..3ada22743e 100644 --- a/awx/ui/client/src/notifications/add/add.controller.js +++ b/awx/ui/client/src/notifications/add/add.controller.js @@ -22,7 +22,7 @@ export default ['Rest', 'Wait', 'NotificationsFormObject', init(); function init() { - Rest.setUrl(GetBasePath('projects')); + Rest.setUrl(GetBasePath('notification_templates')); Rest.options() .then(({data}) => { if (!data.actions.POST) { diff --git a/awx/ui/client/src/notifications/edit/edit.controller.js b/awx/ui/client/src/notifications/edit/edit.controller.js index dfde2038e9..561ab09e58 100644 --- a/awx/ui/client/src/notifications/edit/edit.controller.js +++ b/awx/ui/client/src/notifications/edit/edit.controller.js @@ -275,7 +275,7 @@ export default ['Rest', 'Wait', 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)) .map(i => [i, processValue($scope[i], i, form.fields[i])])); diff --git a/awx/ui/client/src/shared/directives.js b/awx/ui/client/src/shared/directives.js index 400a967584..5b1fc00d25 100644 --- a/awx/ui/client/src/shared/directives.js +++ b/awx/ui/client/src/shared/directives.js @@ -670,6 +670,8 @@ function(ConfigurationUtils, i18n, $rootScope) { query += '&role_level=workflow_admin_role'; } else if ($state.current.name.includes('projects')) { query += '&role_level=project_admin_role'; + } else if ($state.current.name.includes('notifications')) { + query += '&role_level=notification_admin_role'; } else { query += '&role_level=admin_role'; } diff --git a/awx/ui/client/src/shared/stateDefinitions.factory.js b/awx/ui/client/src/shared/stateDefinitions.factory.js index 8972b9c19a..b8f46207db 100644 --- a/awx/ui/client/src/shared/stateDefinitions.factory.js +++ b/awx/ui/client/src/shared/stateDefinitions.factory.js @@ -744,10 +744,20 @@ function($injector, $stateExtender, $log, i18n) { // search will think they need to be set as search tags. var params; if(field.sourceModel === "organization"){ - params = { - page_size: '5', - role_level: 'admin_role' - }; + if (form.name === "notification_template") { + // Users with admin_role role level should also have + // 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"){ params = {