A platform for community discussion. Free, open, simple.
FIX: Use serialized subcategories in subcategory-with-featured-topics (#26718)
Daniel Waterworthd2a52c3c3510
diff --git a/app/assets/javascripts/discourse/app/components/subcategories-with-featured-topics.hbs b/app/assets/javascripts/discourse/app/components/subcategories-with-featured-topics.hbsindex c8159b74c7b..9629c4caea5 100644--- a/app/assets/javascripts/discourse/app/components/subcategories-with-featured-topics.hbs+++ b/app/assets/javascripts/discourse/app/components/subcategories-with-featured-topics.hbs@@ -13,7 +13,7 @@</tr></thead><tbody aria-labelledby="categories-only-category">- {{#each category.subcategories as |subCategory|}}+ {{#each category.serializedSubcategories as |subCategory|}}<ParentCategoryRow @category={{subCategory}} @showTopics={{true}} />{{else}}{{! No subcategories... so just show the parent to avoid confusion }}diff --git a/app/assets/javascripts/discourse/app/models/category.js b/app/assets/javascripts/discourse/app/models/category.jsindex 77b65481613..1abe3ec1a50 100644--- a/app/assets/javascripts/discourse/app/models/category.js+++ b/app/assets/javascripts/discourse/app/models/category.js@@ -6,6 +6,7 @@ import { NotificationLevels } from "discourse/lib/notification-levels";import PermissionType from "discourse/models/permission-type";import RestModel from "discourse/models/rest";import Site from "discourse/models/site";+import Topic from "discourse/models/topic";import User from "discourse/models/user";import { getOwnerWithFallback } from "discourse-common/lib/get-owner";import getURL from "discourse-common/lib/get-url";@@ -459,6 +460,11 @@ export default class Category extends RestModel {return this.site.categories.filterBy("parent_category_id", this.id);}+ @computed("subcategory_list")+ get serializedSubcategories() {+ return this.subcategory_list?.map((c) => Category.create(c));+ }+@discourseComputed("required_tag_groups", "minimum_required_tags")minimumRequiredTags() {if (this.required_tag_groups?.length > 0) {@@ -759,7 +765,9 @@ export default class Category extends RestModel {@discourseComputed("topics")featuredTopics(topics) {if (topics && topics.length) {- return topics.slice(0, this.num_featured_topics || 2);+ return topics+ .slice(0, this.num_featured_topics || 2)+ .map((t) => Topic.create(t));}}diff --git a/app/assets/javascripts/discourse/tests/fixtures/discovery-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/discovery-fixtures.jsindex 796875aed70..63cee0d60c7 100644--- a/app/assets/javascripts/discourse/tests/fixtures/discovery-fixtures.js+++ b/app/assets/javascripts/discourse/tests/fixtures/discovery-fixtures.js@@ -1554,6 +1554,27 @@ export default {description_excerpt:"Discussion about features or potential features of Discourse: how they work, why they work, etc.",featured_user_ids: [1917, 4385, 2072, 32, 4263],+ subcategory_list: [+ {+ id: 26,+ name: "spec",+ color: "33B0B0",+ text_color: "FFFFFF",+ slug: "spec",+ topic_count: 20,+ post_count: 278,+ description:+ "My idea here is to have mini specs for features we would like built but have no bandwidth to build",+ description_text:+ "My idea here is to have mini specs for features we would like built but have no bandwidth to build",+ topic_url: "/t/about-the-spec-category/13965",+ read_restricted: false,+ permission: 1,+ parent_category_id: 2,+ notification_level: null,+ background_url: null,+ },+ ],topics: [{id: 11997,