From eb628b07471155eeea6f2e952bced31b6cf29b88 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Thu, 7 Apr 2022 14:37:37 +0530 Subject: [PATCH] FIX: hide user notifications tab for moderator users. (#16406) Moderators don't have access to notifications of other users. So we shouldn't display the notifications tab on other user profiles for them. Co-authored-by: Alan Guo Xiang Tan --- .../javascripts/discourse/app/controllers/user.js | 6 +++--- .../discourse/tests/acceptance/user-test.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/app/controllers/user.js b/app/assets/javascripts/discourse/app/controllers/user.js index 1519e04e82a..2efaf9724ce 100644 --- a/app/assets/javascripts/discourse/app/controllers/user.js +++ b/app/assets/javascripts/discourse/app/controllers/user.js @@ -116,9 +116,9 @@ export default Controller.extend(CanCheckEmails, { ); }, - @discourseComputed("viewingSelf", "currentUser.staff") - showNotificationsTab(viewingSelf, staff) { - return viewingSelf || staff; + @discourseComputed("viewingSelf", "currentUser.admin") + showNotificationsTab(viewingSelf, isAdmin) { + return viewingSelf || isAdmin; }, @discourseComputed("model.name") diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-test.js index 1485f8223a0..9d522d3d939 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-test.js @@ -8,6 +8,7 @@ import { exists, query, queryAll, + updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; import { click, currentRouteName, visit } from "@ember/test-helpers"; import { cloneJSON } from "discourse-common/lib/object"; @@ -55,6 +56,20 @@ acceptance("User Routes", function (needs) { "/u/eviltrout/notifications/likes-received?acting_username=aquaman" ) ); + + updateCurrentUser({ moderator: true, admin: false }); + await visit("/u/charlie/summary"); + assert.notOk( + exists(".user-nav > .user-notifications"), + "does not have the notifications tab" + ); + + updateCurrentUser({ moderator: false, admin: true }); + await visit("/u/charlie/summary"); + assert.ok( + exists(".user-nav > .user-notifications"), + "has the notifications tab" + ); }); test("Root URL - Viewing Self", async function (assert) {