From 1121a2b623cfebeab6dd56baaed87bea3524c300 Mon Sep 17 00:00:00 2001 From: mabashian Date: Tue, 30 Jul 2019 16:18:39 -0400 Subject: [PATCH 1/2] Show notification menu to users with notification_admin team role --- awx/ui/client/lib/components/layout/layout.directive.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/lib/components/layout/layout.directive.js b/awx/ui/client/lib/components/layout/layout.directive.js index df91ea37fb74..7d1f457f57e1 100644 --- a/awx/ui/client/lib/components/layout/layout.directive.js +++ b/awx/ui/client/lib/components/layout/layout.directive.js @@ -61,8 +61,8 @@ 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) + const notifAdminOrgsPath = 'api/v2/organizations/?role_level=notification_admin_role'; + $http.get(notifAdminOrgsPath) .then(({ data }) => { if (data.count > 0) { vm.isNotificationAdmin = true; @@ -73,7 +73,7 @@ function AtLayoutController ($scope, $http, strings, ProcessErrors, $transitions .catch(({ data, status }) => { ProcessErrors(null, data, status, null, { hdr: strings.get('error.HEADER'), - msg: strings.get('error.CALL', { path: usersPath, action: 'GET', status }) + msg: strings.get('error.CALL', { path: notifAdminOrgsPath, action: 'GET', status }) }); }); } From a6c50f6d201e455cdc65f82bad14113807c3aee9 Mon Sep 17 00:00:00 2001 From: mabashian Date: Tue, 30 Jul 2019 16:52:52 -0400 Subject: [PATCH 2/2] Fix unit test endpoint to match notif admin request endpoint --- awx/ui/test/unit/components/layout.unit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/test/unit/components/layout.unit.js b/awx/ui/test/unit/components/layout.unit.js index 164dfddae8d4..e6434ebf820e 100644 --- a/awx/ui/test/unit/components/layout.unit.js +++ b/awx/ui/test/unit/components/layout.unit.js @@ -46,7 +46,7 @@ describe('Components | Layout', () => { $httpBackend.when('GET', /admin_of_organizations/) .respond(mockOrgAdminResponse); - $httpBackend.when('GET', /roles\/\?role_field=notification_admin_role/) + $httpBackend.when('GET', /organizations\/\?role_level=notification_admin_role/) .respond(mockNotificationAdminResponse); });