From 01281b6364d9770f0f8d4df4f7d3f3ed95fd1776 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 31 Dec 2015 15:05:23 +1100 Subject: [PATCH] FIX: hide bookmarks tab on other peoples profile (unless self or admin) FIX: missing download my posts button FIX: moderators had no way of seeing responses and edits etc --- .../discourse/controllers/user-activity.js.es6 | 5 ++++- .../javascripts/discourse/controllers/user.js.es6 | 11 ++++++++--- .../discourse/routes/user-notifications-index.js.es6 | 8 +++++++- .../discourse/routes/user-notifications.js.es6 | 7 ++++++- .../javascripts/discourse/templates/user/activity.hbs | 2 ++ .../discourse/templates/user/notifications.hbs | 2 ++ .../javascripts/discourse/templates/user/user.hbs | 2 +- 7 files changed, 30 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/user-activity.js.es6 b/app/assets/javascripts/discourse/controllers/user-activity.js.es6 index 9e6a6530dfb..8cecec3db10 100644 --- a/app/assets/javascripts/discourse/controllers/user-activity.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-activity.js.es6 @@ -1,6 +1,9 @@ export default Ember.Controller.extend({ userActionType: null, - needs: ["application"], + needs: ["application", "user"], + + viewingSelf: Em.computed.alias("controllers.user.viewingSelf"), + showBookmarks: Em.computed.alias("controllers.user.showBookmarks"), _showFooter: function() { var showFooter; diff --git a/app/assets/javascripts/discourse/controllers/user.js.es6 b/app/assets/javascripts/discourse/controllers/user.js.es6 index 2985920618e..b06b5a9cb33 100644 --- a/app/assets/javascripts/discourse/controllers/user.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user.js.es6 @@ -26,14 +26,19 @@ export default Ember.Controller.extend(CanCheckEmails, { return trustLevel > 2 && !this.siteSettings.tl3_links_no_follow; }, + @computed('viewingSelf', 'currentUser.admin') + showBookmarks(viewingSelf, isAdmin) { + return viewingSelf || isAdmin; + }, + @computed('viewingSelf', 'currentUser.admin') showPrivateMessages(viewingSelf, isAdmin) { return this.siteSettings.enable_private_messages && (viewingSelf || isAdmin); }, - @computed('viewingSelf', 'currentUser.admin') - canSeeNotificationHistory(viewingSelf, isAdmin) { - return viewingSelf || isAdmin; + @computed('viewingSelf', 'currentUser.staff') + showNotificationsTab(viewingSelf, staff) { + return viewingSelf || staff; }, @computed("content.badge_count") diff --git a/app/assets/javascripts/discourse/routes/user-notifications-index.js.es6 b/app/assets/javascripts/discourse/routes/user-notifications-index.js.es6 index d65a3f62548..23b2113edf3 100644 --- a/app/assets/javascripts/discourse/routes/user-notifications-index.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-notifications-index.js.es6 @@ -2,5 +2,11 @@ export default Discourse.Route.extend({ controllerName: 'user-notifications', renderTemplate() { this.render("user/notifications-index"); - } + }, + + afterModel(model){ + if (!model) { + this.transitionTo('userNotifications.responses'); + } + }, }); diff --git a/app/assets/javascripts/discourse/routes/user-notifications.js.es6 b/app/assets/javascripts/discourse/routes/user-notifications.js.es6 index cfb91acdb7d..80c558821d5 100644 --- a/app/assets/javascripts/discourse/routes/user-notifications.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-notifications.js.es6 @@ -14,9 +14,14 @@ export default Discourse.Route.extend(ViewingActionType, { }, model() { - return this.store.find("notification", { username: this.modelFor("user").get("username") }); + const username = this.modelFor("user").get("username"); + + if (this.get("currentUser.username") === username || this.get("currentUser.admin")) { + return this.store.find("notification", { username } ); + } }, + setupController(controller, model) { controller.set("model", model); controller.set("user", this.modelFor("user")); diff --git a/app/assets/javascripts/discourse/templates/user/activity.hbs b/app/assets/javascripts/discourse/templates/user/activity.hbs index 2c3d03ab526..01bc42ee163 100644 --- a/app/assets/javascripts/discourse/templates/user/activity.hbs +++ b/app/assets/javascripts/discourse/templates/user/activity.hbs @@ -21,11 +21,13 @@ {{/link-to}} + {{#if showBookmarks}}
  • {{#link-to 'userActivity.bookmarks'}} {{i18n 'user_action_groups.3'}} {{/link-to}}
  • + {{/if}} {{#if viewingSelf}} diff --git a/app/assets/javascripts/discourse/templates/user/notifications.hbs b/app/assets/javascripts/discourse/templates/user/notifications.hbs index ac8c6353e55..a6b66263d97 100644 --- a/app/assets/javascripts/discourse/templates/user/notifications.hbs +++ b/app/assets/javascripts/discourse/templates/user/notifications.hbs @@ -1,9 +1,11 @@