mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Merge pull request #2462 from techAPJ/bookmarks-menu-patch
Make bookmarks menu appear all the time
This commit is contained in:
commit
ded274d204
6 changed files with 1 additions and 26 deletions
|
@ -1,8 +1,6 @@
|
||||||
export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
|
export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
|
||||||
showAdminLinks: Em.computed.alias("currentUser.staff"),
|
showAdminLinks: Em.computed.alias("currentUser.staff"),
|
||||||
|
|
||||||
showBookmarksLink: Em.computed.alias("currentUser.hasBookmark"),
|
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
logout: function() {
|
logout: function() {
|
||||||
Discourse.logout();
|
Discourse.logout();
|
||||||
|
|
|
@ -11,7 +11,6 @@ Discourse.User = Discourse.Model.extend({
|
||||||
hasPMs: Em.computed.gt("private_messages_stats.all", 0),
|
hasPMs: Em.computed.gt("private_messages_stats.all", 0),
|
||||||
hasStartedPMs: Em.computed.gt("private_messages_stats.mine", 0),
|
hasStartedPMs: Em.computed.gt("private_messages_stats.mine", 0),
|
||||||
hasUnreadPMs: Em.computed.gt("private_messages_stats.unread", 0),
|
hasUnreadPMs: Em.computed.gt("private_messages_stats.unread", 0),
|
||||||
hasBookmark: Em.computed.gt('bookmarks_count', 0),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The user's stream
|
The user's stream
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
{{#if currentUser.unread_private_messages}}<span class="badge-notification unread-private-messages">{{currentUser.unread_private_messages}}</span>{{/if}}{{i18n user.unread_message_count}}
|
{{#if currentUser.unread_private_messages}}<span class="badge-notification unread-private-messages">{{currentUser.unread_private_messages}}</span>{{/if}}{{i18n user.unread_message_count}}
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
{{#if showBookmarksLink}}
|
<li>{{#link-to 'userActivity.bookmarks' currentUser}}{{i18n user.bookmarks}}{{/link-to}}</li>
|
||||||
<li>{{#link-to 'userActivity.bookmarks' currentUser}}{{i18n user.bookmarks}}{{/link-to}}</li>
|
|
||||||
{{/if}}
|
|
||||||
<li>{{#link-to 'preferences' currentUser}}{{i18n user.preferences}}{{/link-to}}</li>
|
<li>{{#link-to 'preferences' currentUser}}{{i18n user.preferences}}{{/link-to}}</li>
|
||||||
<li><button {{action "logout"}} class='btn btn-danger right logout'><i class='fa fa-sign-out'></i>{{i18n user.log_out}}</button></li>
|
<li><button {{action "logout"}} class='btn btn-danger right logout'><i class='fa fa-sign-out'></i>{{i18n user.log_out}}</button></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -89,10 +89,6 @@ SQL
|
||||||
{ all: all, mine: mine, unread: unread }
|
{ all: all, mine: mine, unread: unread }
|
||||||
end
|
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)
|
def self.stream_item(action_id, guardian)
|
||||||
stream(action_id: action_id, guardian: guardian).first
|
stream(action_id: action_id, guardian: guardian).first
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,6 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||||
:staff?,
|
:staff?,
|
||||||
:reply_count,
|
:reply_count,
|
||||||
:topic_count,
|
:topic_count,
|
||||||
:bookmarks_count,
|
|
||||||
:enable_quoting,
|
:enable_quoting,
|
||||||
:external_links_in_new_tab,
|
:external_links_in_new_tab,
|
||||||
:dynamic_favicon,
|
:dynamic_favicon,
|
||||||
|
@ -38,10 +37,6 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||||
object.user_stat.topic_reply_count
|
object.user_stat.topic_reply_count
|
||||||
end
|
end
|
||||||
|
|
||||||
def bookmarks_count
|
|
||||||
UserAction.bookmarks_stats(object.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
def site_flagged_posts_count
|
def site_flagged_posts_count
|
||||||
PostAction.flagged_posts_count
|
PostAction.flagged_posts_count
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,14 +26,3 @@ test("showAdminLinks", function() {
|
||||||
currentUserStub.set("staff", false);
|
currentUserStub.set("staff", false);
|
||||||
equal(controller.get("showAdminLinks"), false, "is false when current user is not a staff member");
|
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");
|
|
||||||
});
|
|
||||||
|
|
Loading…
Reference in a new issue