From 83519e7f3ac4fe2e06d1fc521b1f7535ed2a86f6 Mon Sep 17 00:00:00 2001 From: Kris Date: Wed, 10 Mar 2021 21:13:15 -0500 Subject: [PATCH] FEATURE: Always show tag dropdown when tagging is enabled (#12209) --- .../discourse/app/controllers/tag-show.js | 2 +- .../app/templates/components/bread-crumbs.hbs | 32 +++++++++---------- .../discourse/app/templates/tags/show.hbs | 2 +- .../acceptance/tags-intersection-test.js | 2 +- .../select-kit/addon/components/tag-drop.js | 11 +------ .../stylesheets/common/base/tagging.scss | 6 ++++ app/models/tag.rb | 2 +- app/models/topic_tracking_state.rb | 2 +- config/locales/server.en.yml | 1 - config/site_settings.yml | 4 --- spec/models/topic_tracking_state_spec.rb | 8 ----- 11 files changed, 27 insertions(+), 45 deletions(-) diff --git a/app/assets/javascripts/discourse/app/controllers/tag-show.js b/app/assets/javascripts/discourse/app/controllers/tag-show.js index bb2997e20e2..bde05d5718b 100644 --- a/app/assets/javascripts/discourse/app/controllers/tag-show.js +++ b/app/assets/javascripts/discourse/app/controllers/tag-show.js @@ -69,7 +69,7 @@ export default Controller.extend(BulkTopicSelection, FilterModeMixin, { @discourseComputed("category") showTagFilter() { - return this.siteSettings.show_filter_by_tag; + return true; }, loadMoreTopics() { diff --git a/app/assets/javascripts/discourse/app/templates/components/bread-crumbs.hbs b/app/assets/javascripts/discourse/app/templates/components/bread-crumbs.hbs index 8236b9448a7..354e4de4ecb 100644 --- a/app/assets/javascripts/discourse/app/templates/components/bread-crumbs.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/bread-crumbs.hbs @@ -15,23 +15,21 @@ {{/each}} {{#if siteSettings.tagging_enabled}} - {{#if siteSettings.show_filter_by_tag}} - {{#if additionalTags}} - {{tags-intersection-chooser - currentCategory=category - mainTag=tag.id - additionalTags=additionalTags - options=(hash - categoryId=category.id - ) - }} - {{else}} - {{tag-drop - currentCategory=category - noSubcategories=noSubcategories - tagId=tag.id - }} - {{/if}} + {{#if additionalTags}} + {{tags-intersection-chooser + currentCategory=category + mainTag=tag.id + additionalTags=additionalTags + options=(hash + categoryId=category.id + ) + }} + {{else}} + {{tag-drop + currentCategory=category + noSubcategories=noSubcategories + tagId=tag.id + }} {{/if}} {{/if}} diff --git a/app/assets/javascripts/discourse/app/templates/tags/show.hbs b/app/assets/javascripts/discourse/app/templates/tags/show.hbs index b8f396ddba6..54da57e02a7 100644 --- a/app/assets/javascripts/discourse/app/templates/tags/show.hbs +++ b/app/assets/javascripts/discourse/app/templates/tags/show.hbs @@ -1,4 +1,4 @@ -{{#d-section tagName="" pageClass="tags" bodyClass=(concat "tag-" tag.id (if category.slug (concat " category-" category.slug)) "")}} +{{#d-section tagName="" pageClass="tags" bodyClass=(concat "tag-" tag.id (if category.slug (concat " category-" category.slug)) "" (if additionalTags " tags-intersection"))}}
{{discourse-banner user=currentUser banner=site.banner}}
diff --git a/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js b/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js index e2747520a16..fe9be3e3724 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js @@ -36,7 +36,7 @@ acceptance("Tags intersection", function (needs) { assert.ok(exists(".mini-tag-chooser"), "The tag selector appears"); assert.equal( - $(".mini-tag-chooser").text().trim(), + $(".composer-fields .mini-tag-chooser").text().trim(), "first, second", "populates the tags when clicking 'New topic'" ); diff --git a/app/assets/javascripts/select-kit/addon/components/tag-drop.js b/app/assets/javascripts/select-kit/addon/components/tag-drop.js index 13e746d6af6..e28079a9423 100644 --- a/app/assets/javascripts/select-kit/addon/components/tag-drop.js +++ b/app/assets/javascripts/select-kit/addon/components/tag-drop.js @@ -4,7 +4,6 @@ import ComboBoxComponent from "select-kit/components/combo-box"; import DiscourseURL, { getCategoryAndTagUrl } from "discourse/lib/url"; import TagsMixin from "select-kit/mixins/tags"; import { computed } from "@ember/object"; -import { isEmpty } from "@ember/utils"; import { makeArray } from "discourse-common/lib/helpers"; export const NO_TAG_ID = "no-tags"; @@ -13,21 +12,13 @@ export const NONE_TAG_ID = "none"; export default ComboBoxComponent.extend(TagsMixin, { pluginApiIdentifiers: ["tag-drop"], - classNameBindings: ["categoryStyle", "tagClass", "shouldHide:hidden"], + classNameBindings: ["categoryStyle", "tagClass"], classNames: ["tag-drop"], value: readOnly("tagId"), tagName: "li", - showFilterByTag: setting("show_filter_by_tag"), categoryStyle: setting("category_style"), maxTagSearchResults: setting("max_tag_search_results"), sortTagsAlphabetically: setting("tags_sort_alphabetically"), - shouldHide: computed("showFilterByTag", "content.[]", function () { - if (this.showFilterByTag && !isEmpty(this.content)) { - return false; - } - - return true; - }), selectKitOptions: { allowAny: false, diff --git a/app/assets/stylesheets/common/base/tagging.scss b/app/assets/stylesheets/common/base/tagging.scss index 577197ed845..8b27a5f0d5f 100644 --- a/app/assets/stylesheets/common/base/tagging.scss +++ b/app/assets/stylesheets/common/base/tagging.scss @@ -308,3 +308,9 @@ section.tag-info { margin: 0 0.5em 0 0; } } + +body.tags-intersection { + .category-breadcrumb { + margin-right: auto; + } +} diff --git a/app/models/tag.rb b/app/models/tag.rb index 73af70faf1c..5245843e493 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -148,7 +148,7 @@ class Tag < ActiveRecord::Base end def self.include_tags? - SiteSetting.tagging_enabled && SiteSetting.show_filter_by_tag + SiteSetting.tagging_enabled end def full_url diff --git a/app/models/topic_tracking_state.rb b/app/models/topic_tracking_state.rb index 045ad34cece..75c2e9d9745 100644 --- a/app/models/topic_tracking_state.rb +++ b/app/models/topic_tracking_state.rb @@ -240,7 +240,7 @@ class TopicTrackingState end def self.include_tags_in_report? - SiteSetting.tagging_enabled && (@include_tags_in_report || SiteSetting.show_filter_by_tag) + SiteSetting.tagging_enabled && @include_tags_in_report end def self.include_tags_in_report=(v) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index a4502d33cc4..28344bb5df3 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -2249,7 +2249,6 @@ en: max_tags_per_topic: "The maximum tags that can be applied to a topic." max_tag_length: "The maximum amount of characters that can be used in a tag." max_tag_search_results: "When searching for tags, the maximum number of results to show." - show_filter_by_tag: "Show a dropdown to filter a topic list by tag." max_tags_in_filter_list: "Maximum number of tags to show in the filter dropdown. The most used tags will be shown." tags_sort_alphabetically: "Show tags in alphabetical order. Default is to show in order of popularity." tags_listed_by_group: "List tags by tag group on the Tags page." diff --git a/config/site_settings.yml b/config/site_settings.yml index 53c19ee4276..300bb24fdec 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -2379,10 +2379,6 @@ tags: client: true default: 5 min: 1 - show_filter_by_tag: - client: true - default: false - refresh: true max_tags_in_filter_list: client: true default: 30 diff --git a/spec/models/topic_tracking_state_spec.rb b/spec/models/topic_tracking_state_spec.rb index b0c119419af..f87eb2cbff4 100644 --- a/spec/models/topic_tracking_state_spec.rb +++ b/spec/models/topic_tracking_state_spec.rb @@ -636,14 +636,6 @@ describe TopicTrackingState do expect(row.tags).to contain_exactly("apples", "bananas") TopicTrackingState.include_tags_in_report = false - SiteSetting.show_filter_by_tag = true - - report = TopicTrackingState.report(user) - expect(report.length).to eq(1) - row = report[0] - expect(row.tags).to contain_exactly("apples", "bananas") - - SiteSetting.show_filter_by_tag = false report = TopicTrackingState.report(user) expect(report.length).to eq(1)