FIX: category page improvements (#36062)

Follow-up of #36050.

This PR contains clean-up and minor refactor work related to categories
copies and breadcrumb dropdowns:

* hide search input in filters dropdown if list is less than 10 options
* update copies to follow Discourse conventions
* remove unused `shouldDisplayIcon`
* fix spec flakiness by changing check from class name existence to
block visibility

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
This commit is contained in:
Yuriy Kurant
2025-11-18 15:54:28 +08:00
committed by GitHub
co-authored by Martin Brennan
parent 32af7bd19e
commit 46a3d9ca57
8 changed files with 48 additions and 60 deletions
+38 -38
View File
@@ -3742,7 +3742,7 @@ en:
deleted: "The topic has been deleted"
slow_mode_update:
title: "Slow Mode"
title: "Slow mode"
select: "Users may only post in this topic once every:"
description: "To promote thoughtful discussion in fast moving or contentious discussions, users must wait before posting again in this topic."
enable: "Enable"
@@ -4480,24 +4480,24 @@ en:
description: "Require new topics to have tags from tag groups:"
delete: "Delete"
add: "Add required tag group"
placeholder: "select tag group…"
placeholder: "Select tag group…"
topic_featured_link_allowed: "Allow featured links in this category"
delete: "Delete Category"
create: "New Category"
delete: "Delete category"
create: "New category"
create_long: "Create a new category"
save: "Save Category"
slug: "Category Slug"
save: "Save category"
slug: "Category slug"
slug_placeholder: "(Optional) dashed-words for url"
creation_error: There has been an error during the creation of the category.
save_error: There was an error saving the category.
name: "Category Name"
untitled: "Untitled Category"
name: "Category name"
untitled: "Untitled category"
description: "Description"
logo: "Category Logo Image"
logo_dark: "Dark Mode Category Logo Image"
logo: "Category logo image"
logo_dark: "Dark mode category logo image"
logo_description: "Recommended 1:1 aspect ratio with 200px minimum size. If left blank no image will be shown."
background_image: "Category Background Image"
background_image_dark: "Dark Category Background Image"
background_image: "Category background image"
background_image_dark: "Dark category background image"
style: "Styles"
background_color: "Color"
foreground_color: "Text color"
@@ -4519,9 +4519,9 @@ en:
color_placeholder: "Any web color"
delete_confirm: "Are you sure you want to delete this category?"
delete_error: "There was an error deleting the category."
list: "List Categories"
list: "List categories"
no_description: "Please add a description for this category."
change_in_category_topic: "Edit Description"
change_in_category_topic: "Edit description"
already_used: "This color has been used by another category"
security: "Security"
security_add_group: "Add a group"
@@ -4552,23 +4552,23 @@ en:
all_topics_wiki: "Make new topics wikis by default"
allow_unlimited_owner_edits_on_first_post: "Allow unlimited owner edits on first post"
subcategory_list_style: "Subcategory List Style:"
sort_order: "Topic List Sort By:"
default_view: "Default Topic List:"
default_top_period: "Default Top Period:"
default_list_filter: "Default List Filter:"
sort_order: "Topic list sort by:"
default_view: "Default topic list:"
default_top_period: "Default top period:"
default_list_filter: "Default list filter:"
allow_badges_label: "Allow badges to be awarded in this category"
edit_permissions: "Edit Permissions"
edit_permissions: "Edit permissions"
reviewable_by_group: "In addition to staff, content in this category can also be reviewed by:"
review_group_name: "group name"
require_topic_approval: "Require moderator approval of all new topics"
require_reply_approval: "Require moderator approval of all new replies"
this_year: "this year"
position: "Position on the categories page:"
default_position: "Default Position"
default_position: "Default position"
position_disabled: "Categories will be displayed in order of activity. To control the order of categories in lists, enable the <a href='%{url}'>'fixed category positions'</a> setting."
minimum_required_tags: "Minimum number of tags required in a topic:"
default_slow_mode: 'Enable "Slow Mode" for new topics in this category.'
parent: "Parent Category"
default_slow_mode: 'Enable "Slow mode" for new topics in this category.'
parent: "Parent category"
num_auto_bump_daily: "Number of open topics to automatically bump daily:"
auto_bump_cooldown_days: "Minimum days before bumping the same topic again:"
navigate_to_first_post_after_read: "Navigate to first post after topics are read"
@@ -4590,18 +4590,18 @@ en:
title: "Muted"
description: "You will never be notified of anything about new topics in this category, and they will not appear in latest."
search_priority:
label: "Search Priority"
label: "Search priority"
options:
normal: "Normal"
ignore: "Ignore"
very_low: "Very Low"
very_low: "Very low"
low: "Low"
high: "High"
very_high: "Very High"
very_high: "Very high"
sort_options:
default: "default"
likes: "Likes"
op_likes: "Original Post Likes"
op_likes: "Original post likes"
views: "Views"
posts: "Posts"
activity: "Activity"
@@ -4621,8 +4621,8 @@ en:
appearance: "Appearance"
email: "Email"
list_filters:
all: "all topics"
none: "no subcategories"
all: "All topics"
none: "No subcategories"
colors_disabled: "You cant select colors because you have a category style of none."
anonymous_flagging:
@@ -4874,7 +4874,7 @@ en:
title: "Top"
help: "the most active topics in the last year, month, week or day"
all:
title: "All Time"
title: "All time"
yearly:
title: "Yearly"
quarterly:
@@ -4885,7 +4885,7 @@ en:
title: "Weekly"
daily:
title: "Daily"
all_time: "All Time"
all_time: "All time"
this_year: "Year"
this_quarter: "Quarter"
this_month: "Month"
@@ -5176,18 +5176,18 @@ en:
groups:
back_btn: "Back to all tags"
title: "Tag Groups"
title: "Tag groups"
about_heading: "Select a tag group or create a new one"
about_heading_empty: "Create a new tag group to get started"
about_description: "Tag groups help you manage permissions for many tags in one place."
new: "New Group"
new_title: "Create New Group"
edit_title: "Edit Tag Group"
new: "New group"
new_title: "Create new group"
edit_title: "Edit tag group"
tags_label: "Tags in this group"
parent_tag_label: "Parent tag"
parent_tag_description: "Tags from this group can only be used if the parent tag is present."
one_per_topic_label: "Limit one tag per topic from this group"
new_name: "New Tag Group"
new_name: "New tag group"
name_placeholder: "Name"
save: "Save"
delete: "Delete"
@@ -7797,10 +7797,10 @@ en:
second: "Option 2"
third: "Option 3"
edit_category:
toggle_freeform: "form template disabled"
toggle_form_template: "form template enabled"
toggle_freeform: "Form template disabled"
toggle_form_template: "Form template enabled"
select_template: "Select form templates"
select_template_help: "Add/Edit Form Templates"
select_template_help: "Add/Edit form templates"
errors:
multiple_tags_not_allowed: 'You can''t select more tags from the "%{tag_name}". To avoid issues, use Form Template'
+1 -1
View File
@@ -2313,7 +2313,7 @@ en:
allow_all_users_to_flag_illegal_content: "Anonymous users will see information that they have to e-mail administrators to report illegal content. This setting takes precedence over 'flag post allowed groups'."
email_address_to_report_illegal_content: "If left blank the default site admin email will be used."
cooldown_hours_until_reflag: "How much time users will have to wait until they are able to reflag a post"
slow_mode_prevents_editing: "Does 'Slow Mode' prevent editing, after editing_grace_period?"
slow_mode_prevents_editing: "Does 'Slow mode' prevent editing, after 'editing grace period'?"
reply_by_email_enabled: "Activate the feature that permits users to respond to topics directly through email, instead of requiring them to log into the website. See <a href='https://meta.discourse.org/t/set-up-reply-by-email-with-pop3-polling/14003' target='_blank'>the guide on Meta</a> for more information."
reply_by_email_address: "Template for reply by email incoming email address, for example: %%{reply_key}@reply.example.com or replies+%%{reply_key}@example.com"
@@ -169,8 +169,6 @@ export default class BreadCrumbs extends Component {
parentCategory=breadcrumb.parentCategory
subCategory=breadcrumb.isSubcategory
noSubcategories=breadcrumb.noSubcategories
autoFilterable=true
shouldDisplayIcon=false
}}
class={{if
breadcrumb.isSubcategory
@@ -28,7 +28,6 @@ const MORE_COLLECTION = "MORE_COLLECTION";
@classNames("category-drop")
@classNameBindings("noSubcategories:has-selection")
@selectKitOptions({
filterable: true,
none: "category.all",
caretDownIcon: "caret-right",
caretUpIcon: "caret-down",
@@ -43,14 +42,12 @@ const MORE_COLLECTION = "MORE_COLLECTION";
headerComponent: CategoryDropHeader,
parentCategory: false,
allowUncategorized: "allowUncategorized",
shouldDisplayIcon: "shouldDisplayIcon",
})
@pluginApiIdentifiers(["category-drop"])
export default class CategoryDrop extends ComboBoxComponent {
@readOnly("category.id") value;
@readOnly("categoriesWithShortcuts") content;
@readOnly("selectKit.options.parentCategory.displayName") parentCategoryName;
@readOnly("selectKit.options.shouldDisplayIcon") shouldDisplayIcon;
@setting("allow_uncategorized_topics") allowUncategorized;
noCategoriesLabel = i18n("categories.no_subcategories");
@@ -1,4 +1,3 @@
import { reads } from "@ember/object/computed";
import { classNames } from "@ember-decorators/component";
import icon from "discourse/helpers/d-icon";
import discourseComputed from "discourse/lib/decorators";
@@ -7,8 +6,6 @@ import { resolveComponent } from "discourse/select-kit/components/select-kit";
@classNames("category-drop-header")
export default class CategoryDropHeader extends ComboBoxSelectBoxHeaderComponent {
@reads("selectKit.options.shouldDisplayIcon") shouldDisplayIcon;
@discourseComputed("selectedContent.color")
categoryBackgroundColor(categoryColor) {
return categoryColor || "#e9e9e9";
@@ -29,7 +26,6 @@ export default class CategoryDropHeader extends ComboBoxSelectBoxHeaderComponent
@tabindex={{this.tabindex}}
@item={{this.selectedContent}}
@selectKit={{this.selectKit}}
@shouldDisplayIcon={{this.shouldDisplayIcon}}
@shouldDisplayClearableButton={{this.shouldDisplayClearableButton}}
/>
{{/let}}
@@ -4,7 +4,7 @@ en:
sort_options:
votes: "Votes"
topic_voting:
title: "Topic Voting"
title: "Topic voting"
reached_limit: "You are out of votes, remove an existing vote!"
list_votes: "List your votes"
votes_nav_help: "topics with the most votes"
+6 -9
View File
@@ -205,7 +205,7 @@ describe "Category Localizations", type: :system do
expect(category_list.category_box(category)).to have_text("Solicitudes")
category_list.category_box(category).click
category_dropdown = get_category_dropdown("1")
category_dropdown = get_category_dropdown(1)
expect(category_dropdown).to have_selected_name("Solicitudes")
expect(sidebar).to have_section_link("Solicitudes")
@@ -221,16 +221,13 @@ describe "Category Localizations", type: :system do
switcher.expand
switcher.option("[data-menu-option-id='es']").click
category_dropdown = get_category_dropdown("1")
category_dropdown = get_category_dropdown(1)
expect(category_dropdown.component).to have_text(
I18n.t("js.categories.categories_label", locale: "es"),
)
category_dropdown.component.click
expect(category_dropdown.component).to have_css(".is-expanded")
expect(category_dropdown.component.find(".select-kit-body")).to have_css(
".select-kit-collection",
)
expect(category_dropdown).to be_expanded
expect(page.find(".select-kit-collection div[data-name='Solicitudes']")).to have_text(
"Solicitudes",
)
@@ -241,7 +238,7 @@ describe "Category Localizations", type: :system do
it_behaves_like "navigating the site via various category links"
end
describe "logged in users" do
describe "for logged in users" do
shared_examples_for "editing category settings" do
it "shows the original category name in the category edit page" do
sign_in(admin)
@@ -261,7 +258,7 @@ describe "Category Localizations", type: :system do
end
end
describe "lazy loaded categories" do
describe "with lazy loaded categories" do
before do
SiteSetting.lazy_load_categories_groups = "#{Group::AUTO_GROUPS[:everyone]}"
sign_in(admin)
@@ -272,7 +269,7 @@ describe "Category Localizations", type: :system do
it_behaves_like "editing category settings"
end
describe "no lazy loaded categories" do
describe "without lazy loaded categories" do
before do
SiteSetting.lazy_load_categories_groups = ""
sign_in(admin)
@@ -34,8 +34,8 @@ module PageObjects
find(@context + ":not(.is-expanded)")
end
def is_expanded?
has_css?(context + ".is-expanded")
def expanded?
component.has_css?(".select-kit-body", visible: :visible)
end
def is_collapsed?