From 7e946a718eb6baafe9b2ede4eb26cd77b77f9185 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Mon, 23 Jun 2014 10:21:33 +0530 Subject: [PATCH] Make bookmarks menu appear all the time --- .../discourse/controllers/user-dropdown.js.es6 | 2 -- app/assets/javascripts/discourse/models/user.js | 1 - .../discourse/templates/user_dropdown.js.handlebars | 4 +--- app/models/user_action.rb | 4 ---- app/serializers/current_user_serializer.rb | 5 ----- .../controllers/user_dropdown_controller_test.js | 11 ----------- 6 files changed, 1 insertion(+), 26 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/user-dropdown.js.es6 b/app/assets/javascripts/discourse/controllers/user-dropdown.js.es6 index 203ada0b3ee..3413e61f276 100644 --- a/app/assets/javascripts/discourse/controllers/user-dropdown.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-dropdown.js.es6 @@ -1,8 +1,6 @@ export default Ember.ArrayController.extend(Discourse.HasCurrentUser, { showAdminLinks: Em.computed.alias("currentUser.staff"), - showBookmarksLink: Em.computed.alias("currentUser.hasBookmark"), - actions: { logout: function() { Discourse.logout(); diff --git a/app/assets/javascripts/discourse/models/user.js b/app/assets/javascripts/discourse/models/user.js index 277dc379c6c..cb4398519b9 100644 --- a/app/assets/javascripts/discourse/models/user.js +++ b/app/assets/javascripts/discourse/models/user.js @@ -11,7 +11,6 @@ Discourse.User = Discourse.Model.extend({ hasPMs: Em.computed.gt("private_messages_stats.all", 0), hasStartedPMs: Em.computed.gt("private_messages_stats.mine", 0), hasUnreadPMs: Em.computed.gt("private_messages_stats.unread", 0), - hasBookmark: Em.computed.gt('bookmarks_count', 0), /** The user's stream diff --git a/app/assets/javascripts/discourse/templates/user_dropdown.js.handlebars b/app/assets/javascripts/discourse/templates/user_dropdown.js.handlebars index 569eb9020c5..78dd96210ec 100644 --- a/app/assets/javascripts/discourse/templates/user_dropdown.js.handlebars +++ b/app/assets/javascripts/discourse/templates/user_dropdown.js.handlebars @@ -9,9 +9,7 @@ {{#if currentUser.unread_private_messages}}{{currentUser.unread_private_messages}}{{/if}}{{i18n user.unread_message_count}} {{/link-to}} - {{#if showBookmarksLink}} -
  • {{#link-to 'userActivity.bookmarks' currentUser}}{{i18n user.bookmarks}}{{/link-to}}
  • - {{/if}} +
  • {{#link-to 'userActivity.bookmarks' currentUser}}{{i18n user.bookmarks}}{{/link-to}}
  • {{#link-to 'preferences' currentUser}}{{i18n user.preferences}}{{/link-to}}
  • diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 07a9261f71c..9a3c59a2338 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -89,10 +89,6 @@ SQL { all: all, mine: mine, unread: unread } end - def self.bookmarks_stats(user_id) - UserAction.where(action_type: BOOKMARK, user_id: user_id).count - end - def self.stream_item(action_id, guardian) stream(action_id: action_id, guardian: guardian).first end diff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rb index 1cdb4df6c40..31bb74bed9a 100644 --- a/app/serializers/current_user_serializer.rb +++ b/app/serializers/current_user_serializer.rb @@ -10,7 +10,6 @@ class CurrentUserSerializer < BasicUserSerializer :staff?, :reply_count, :topic_count, - :bookmarks_count, :enable_quoting, :external_links_in_new_tab, :dynamic_favicon, @@ -38,10 +37,6 @@ class CurrentUserSerializer < BasicUserSerializer object.user_stat.topic_reply_count end - def bookmarks_count - UserAction.bookmarks_stats(object.id) - end - def site_flagged_posts_count PostAction.flagged_posts_count end diff --git a/test/javascripts/controllers/user_dropdown_controller_test.js b/test/javascripts/controllers/user_dropdown_controller_test.js index 9a624ed61cd..ab57cebc88b 100644 --- a/test/javascripts/controllers/user_dropdown_controller_test.js +++ b/test/javascripts/controllers/user_dropdown_controller_test.js @@ -26,14 +26,3 @@ test("showAdminLinks", function() { currentUserStub.set("staff", false); equal(controller.get("showAdminLinks"), false, "is false when current user is not a staff member"); }); - -test("showBookmarksLink", function() { - var currentUserStub = Ember.Object.create(); - this.stub(Discourse.User, "current").returns(currentUserStub); - - currentUserStub.set("hasBookmark", true); - equal(controller.get("showBookmarksLink"), true, "is true when current user have bookmarks"); - - currentUserStub.set("hasBookmark", false); - equal(controller.get("showBookmarksLink"), false, "is false when current user does not have bookmarks"); -});