From 76409145523ac33f3f77bb9e8b7104c01aa35735 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 3 Feb 2020 18:40:02 +0000 Subject: [PATCH] UX: Include muted categories on the category page by default (#8842) * DEV: Add data-notification-level attribute to category UI * Show muted categories on the category page by default This reverts commit ed9c21e42c3e34955013fe34ba8443841bafbedd. * Remove redundant spec - muted categories are now visible by default --- .../templates/components/categories-boxes.hbs | 4 ++-- .../templates/components/categories-only.hbs | 4 ++-- app/models/category_list.rb | 5 ----- spec/models/category_list_spec.rb | 15 --------------- 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/app/assets/javascripts/discourse/templates/components/categories-boxes.hbs b/app/assets/javascripts/discourse/templates/components/categories-boxes.hbs index 72ae9fd3286..cd39c3751f3 100644 --- a/app/assets/javascripts/discourse/templates/components/categories-boxes.hbs +++ b/app/assets/javascripts/discourse/templates/components/categories-boxes.hbs @@ -1,5 +1,5 @@ {{#each categories as |c|}} -
{{#if c.isGrandParent}} {{#each c.subcategories as |subcategory|}} -
+
{{category-title-link tagName="h4" category=subcategory}} {{#if subcategory.subcategories}} diff --git a/app/assets/javascripts/discourse/templates/components/categories-only.hbs b/app/assets/javascripts/discourse/templates/components/categories-only.hbs index e918461082f..d8280b5d73b 100644 --- a/app/assets/javascripts/discourse/templates/components/categories-only.hbs +++ b/app/assets/javascripts/discourse/templates/components/categories-only.hbs @@ -11,7 +11,7 @@ {{#each categories as |c|}} - + {{category-title-link category=c}} {{#if c.description_excerpt}} @@ -22,7 +22,7 @@ {{#if c.isGrandParent}} {{#each c.subcategories as |subcategory|}} - +
{{category-title-link tagName="h4" category=subcategory}} {{#if subcategory.description_excerpt}} diff --git a/app/models/category_list.rb b/app/models/category_list.rb index bc1d6a4980a..c50c81f62bd 100644 --- a/app/models/category_list.rb +++ b/app/models/category_list.rb @@ -20,7 +20,6 @@ class CategoryList find_categories prune_empty - prune_muted find_user_data sort_unpinned trim_results @@ -139,10 +138,6 @@ class CategoryList @categories.delete_if { |c| c.uncategorized? && c.displayable_topics.blank? } end - def prune_muted - @categories.delete_if { |c| c.notification_level == CategoryUser.notification_levels[:muted] } - end - # Attach some data for serialization to each topic def find_user_data if @guardian.current_user && @all_topics.present? diff --git a/spec/models/category_list_spec.rb b/spec/models/category_list_spec.rb index bc6e03963d4..11691b91205 100644 --- a/spec/models/category_list_spec.rb +++ b/spec/models/category_list_spec.rb @@ -53,16 +53,6 @@ describe CategoryList do expect(CategoryList.new(Guardian.new(nil), include_topics: true).categories.find { |x| x.name == private_cat.name }).to eq(nil) end - it "properly hide muted categories" do - cat_muted = Fabricate(:category_with_definition) - CategoryUser.create!(user_id: user.id, - category_id: cat_muted.id, - notification_level: CategoryUser.notification_levels[:muted]) - - # uncategorized + cat_muted for admin - expect(CategoryList.new(Guardian.new admin).categories.count).to eq(2) - expect(CategoryList.new(Guardian.new user).categories.count).to eq(1) - end end context "when mute_all_categories_by_default enabled" do @@ -87,11 +77,6 @@ describe CategoryList do notification_level = CategoryList.new(Guardian.new).categories.find { |c| c.id == category.id }.notification_level expect(notification_level).to eq(CategoryUser.notification_levels[:regular]) end - - it "removes the default muted categories for anonymous" do - SiteSetting.default_categories_muted = category.id.to_s - expect(CategoryList.new(Guardian.new).categories).not_to include(category) - end end context "with a category" do