From a66d44d2ffe2fce4e4f8e470544545599e703e04 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Fri, 15 May 2020 14:35:00 -0400 Subject: [PATCH] Enable management job notications for admins --- .../notifications/notification.controller.js | 6 ++++-- .../notifications/notification.route.js | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/management-jobs/notifications/notification.controller.js b/awx/ui/client/src/management-jobs/notifications/notification.controller.js index 62e8dff8a3..cc3b0b74be 100644 --- a/awx/ui/client/src/management-jobs/notifications/notification.controller.js +++ b/awx/ui/client/src/management-jobs/notifications/notification.controller.js @@ -6,10 +6,10 @@ export default [ 'NotificationsList', 'GetBasePath', 'ToggleNotification', 'NotificationsListInit', - '$stateParams', 'Dataset', '$scope', + '$stateParams', 'Dataset', '$scope', 'isAdmin', function( NotificationsList, GetBasePath, ToggleNotification, NotificationsListInit, - $stateParams, Dataset, $scope) { + $stateParams, Dataset, $scope, isAdmin) { var defaultUrl = GetBasePath('system_job_templates'), list = NotificationsList, id = $stateParams.management_id; @@ -19,6 +19,8 @@ export default $scope[`${list.iterator}_dataset`] = Dataset.data; $scope[list.name] = $scope[`${list.iterator}_dataset`].results; + $scope.sufficientRoleForNotifToggle = isAdmin; + NotificationsListInit({ scope: $scope, url: defaultUrl, diff --git a/awx/ui/client/src/management-jobs/notifications/notification.route.js b/awx/ui/client/src/management-jobs/notifications/notification.route.js index a6b1f30d8a..7b6bf64585 100644 --- a/awx/ui/client/src/management-jobs/notifications/notification.route.js +++ b/awx/ui/client/src/management-jobs/notifications/notification.route.js @@ -39,6 +39,19 @@ export default { let path = `${GetBasePath('system_job_templates')}${$stateParams.management_id}`; Rest.setUrl(path); return Rest.get(path).then((res) => res.data); + }], + isAdmin: ['Rest', 'GetBasePath', function(Rest, GetBasePath) { + Rest.setUrl(GetBasePath('me')); + return Rest.get() + .then((res) => { + if (res.data && res.data.results && res.data.count && res.data.results[0] && res.data.results[0].is_superuser) { + return true; + } + return false; + }) + .catch(() => { + return false; + }); }] }, ncyBreadcrumb: {