A platform for community discussion. Free, open, simple.
FIX: Hide old bookmark button on post-menu if SiteSetting.enable_bookmarks_with_reminders
Martin Brennan9f4c9bafa17e
diff --git a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 b/app/assets/javascripts/discourse/widgets/post-menu.js.es6index a21c921420b..a9dccb91a2b 100644--- a/app/assets/javascripts/discourse/widgets/post-menu.js.es6+++ b/app/assets/javascripts/discourse/widgets/post-menu.js.es6@@ -332,7 +332,7 @@ registerButton("bookmarkWithReminder", (attrs, state, siteSettings) => {title,titleOptions,className: classNames.join(" "),- icon: "book"+ icon: "bookmark"};});@@ -460,7 +460,16 @@ export default createWidget("post-menu", {const allButtons = [];let visibleButtons = [];- const orderedButtons = this.menuItems();+ // filter menu items based on site settings+ const orderedButtons = this.menuItems().filter(button => {+ if (+ this.siteSettings.enable_bookmarks_with_reminders &&+ button === "bookmark"+ ) {+ return false;+ }+ return true;+ });// If the post is a wiki, make Edit more prominentif (attrs.wiki && attrs.canEdit) {diff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rbindex b148045041d..ade1417dc66 100644--- a/app/serializers/post_serializer.rb+++ b/app/serializers/post_serializer.rb@@ -330,7 +330,7 @@ class PostSerializer < BasicPostSerializerenddef post_bookmark- return nil if !SiteSetting.enable_bookmarks_with_reminders?+ return nil if !SiteSetting.enable_bookmarks_with_reminders? || @topic_view.blank?@post_bookmark ||= @topic_view.user_post_bookmarks.find { |bookmark| bookmark.post_id == object.id }enddiff --git a/spec/serializers/post_serializer_spec.rb b/spec/serializers/post_serializer_spec.rbindex fe30193d30f..a438a06ea9d 100644--- a/spec/serializers/post_serializer_spec.rb+++ b/spec/serializers/post_serializer_spec.rb@@ -227,10 +227,11 @@ describe PostSerializer docontext "post with bookmarks" dolet(:current_user) { Fabricate(:user) }+ let(:topic_view) { TopicView.new(post.topic, current_user) }let(:serialized) dos = serialized_post(current_user)s.post_actions = PostAction.counts_for([post], current_user)[post.id]- s.topic_view = TopicView.new(post.topic, current_user)+ s.topic_view = topic_viewsend@@ -265,10 +266,18 @@ describe PostSerializer doit "returns the reminder_at for the bookmark" doexpect(serialized.as_json[:bookmark_reminder_at]).to eq(bookmark.reminder_at.iso8601)end++ context "if topic_view is blank" do+ let(:topic_view) { nil }++ it "does not return the bookmarked_with_reminder attribute" do+ expect(serialized.as_json.key?(:bookmarked_with_reminder)).to eq(false)+ end+ endendcontext "when the site setting for bookmarks with reminders is disabled" do- it "does not return the bookmarked attribute" do+ it "does not return the bookmarked_with_reminder attribute" doexpect(serialized.as_json.key?(:bookmarked_with_reminder)).to eq(false)end