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 <gxtan1990@gmail.com>
This commit is contained in:
Vinoth Kannan 2022-04-07 14:37:37 +05:30 committed by GitHub
parent 1898a65a13
commit eb628b0747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View File

@ -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")

View File

@ -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) {