From 1408200927b5308cef2518bbfcbc35c6fe26b501 Mon Sep 17 00:00:00 2001 From: mabashian Date: Tue, 28 Aug 2018 15:47:28 -0400 Subject: [PATCH] Exposes organization notification list to users with notification admin role --- awx/ui/client/src/notifications/notifications.list.js | 4 +++- .../edit/organizations-edit.controller.js | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/src/notifications/notifications.list.js b/awx/ui/client/src/notifications/notifications.list.js index d0d1afab40..a81482603f 100644 --- a/awx/ui/client/src/notifications/notifications.list.js +++ b/awx/ui/client/src/notifications/notifications.list.js @@ -20,7 +20,7 @@ export default ['i18n', 'templateUrl', function(i18n, templateUrl){ hover: false, emptyListText: i18n.sprintf(i18n._("This list is populated by notification templates added from the %sNotifications%s section"), " ", " "), basePath: 'notification_templates', - ngIf: 'current_user.is_superuser || isOrgAdmin', + ngIf: 'current_user.is_superuser || isOrgAdmin || isNotificationAdmin', fields: { name: { key: true, @@ -40,6 +40,7 @@ export default ['i18n', 'templateUrl', function(i18n, templateUrl){ flag: 'notification_templates_success', type: "toggle", ngClick: "toggleNotification($event, notification.id, \"notification_templates_success\")", + ngDisabled: "!(current_user.is_superuser || isOrgAdmin)", awToolTip: "{{ schedule.play_tip }}", dataTipWatch: "schedule.play_tip", dataPlacement: "right", @@ -51,6 +52,7 @@ export default ['i18n', 'templateUrl', function(i18n, templateUrl){ flag: 'notification_templates_error', type: "toggle", ngClick: "toggleNotification($event, notification.id, \"notification_templates_error\")", + ngDisabled: "!(current_user.is_superuser || isOrgAdmin)", awToolTip: "{{ schedule.play_tip }}", dataTipWatch: "schedule.play_tip", dataPlacement: "right", diff --git a/awx/ui/client/src/organizations/edit/organizations-edit.controller.js b/awx/ui/client/src/organizations/edit/organizations-edit.controller.js index 0ec36af6ec..cd399e759f 100644 --- a/awx/ui/client/src/organizations/edit/organizations-edit.controller.js +++ b/awx/ui/client/src/organizations/edit/organizations-edit.controller.js @@ -5,10 +5,10 @@ *************************************************/ export default ['$scope', '$location', '$stateParams', 'OrgAdminLookup', - 'OrganizationForm', 'Rest', 'ProcessErrors', 'Prompt', + 'OrganizationForm', 'Rest', 'ProcessErrors', 'Prompt', '$rootScope', 'GetBasePath', 'Wait', '$state', 'ToggleNotification', 'CreateSelect2', 'InstanceGroupsService', 'InstanceGroupsData', 'ConfigData', function($scope, $location, $stateParams, OrgAdminLookup, - OrganizationForm, Rest, ProcessErrors, Prompt, + OrganizationForm, Rest, ProcessErrors, Prompt, $rootScope, GetBasePath, Wait, $state, ToggleNotification, CreateSelect2, InstanceGroupsService, InstanceGroupsData, ConfigData) { let form = OrganizationForm(), @@ -26,6 +26,13 @@ export default ['$scope', '$location', '$stateParams', 'OrgAdminLookup', $scope.isOrgAdmin = isOrgAdmin; }); + Rest.setUrl(GetBasePath('users') + $rootScope.current_user.id + '/roles/?role_field=notification_admin_role'); + Rest.get() + .then(({data}) => { + console.log(data); + $scope.isNotificationAdmin = (data.count && data.count > 0); + }); + $scope.$watch('organization_obj.summary_fields.user_capabilities.edit', function(val) { if (val === false) { $scope.canAdd = false;