mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 12:57:29 +08:00
UX: Merge settings related to muted tags. (#7656)
This commit is contained in:
parent
0955d9ece9
commit
c1e7a1b292
|
@ -29,6 +29,11 @@ export default Ember.Controller.extend(PreferencesTabController, {
|
|||
return this.get("currentUser.id") === this.get("model.id");
|
||||
},
|
||||
|
||||
@computed("siteSettings.remove_muted_tags_from_latest")
|
||||
hideMutedTags() {
|
||||
return this.siteSettings.remove_muted_tags_from_latest !== "never";
|
||||
},
|
||||
|
||||
canSave: Ember.computed.or("canSee", "currentUser.admin"),
|
||||
|
||||
actions: {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<label>{{d-icon "d-muted"}} {{i18n 'user.muted_categories'}}</label>
|
||||
{{category-selector categories=model.mutedCategories blacklist=selectedCategories}}
|
||||
</div>
|
||||
<div class="instructions">{{i18n 'user.muted_categories_instructions'}}</div>
|
||||
<div class="instructions">{{i18n (if hideMutedTags 'user.muted_categories_instructions' 'user.muted_categories_instructions_dont_hide')}}</div>
|
||||
{{#if canSee}}
|
||||
<div class="controls">
|
||||
<a href="{{unbound model.mutedTopicsPath}}">{{i18n 'user.muted_topics_link'}}</a>
|
||||
|
|
26
app/models/remove_muted_tags_from_latest_site_setting.rb
Normal file
26
app/models/remove_muted_tags_from_latest_site_setting.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_dependency 'enum_site_setting'
|
||||
|
||||
class RemoveMutedTagsFromLatestSiteSetting < EnumSiteSetting
|
||||
|
||||
ALWAYS ||= "always"
|
||||
ONLY_MUTED ||= "only_muted"
|
||||
NEVER ||= "never"
|
||||
|
||||
def self.valid_value?(val)
|
||||
values.any? { |v| v[:value] == val }
|
||||
end
|
||||
|
||||
def self.values
|
||||
@values ||= [
|
||||
{ name: "admin.tags.remove_muted_tags_from_latest.always", value: ALWAYS },
|
||||
{ name: "admin.tags.remove_muted_tags_from_latest.only_muted", value: ONLY_MUTED },
|
||||
{ name: "admin.tags.remove_muted_tags_from_latest.never", value: NEVER }
|
||||
]
|
||||
end
|
||||
|
||||
def self.translate_names?
|
||||
true
|
||||
end
|
||||
end
|
|
@ -844,6 +844,7 @@ en:
|
|||
|
||||
muted_categories: "Muted"
|
||||
muted_categories_instructions: "You will not be notified of anything about new topics in these categories, and they will not appear on the categories or latest pages."
|
||||
muted_categories_instructions_dont_hide: "You will not be notified of anything about new topics in these categories."
|
||||
no_category_access: "As a moderator you have limited category access, save is disabled."
|
||||
delete_account: "Delete My Account"
|
||||
delete_account_confirm: "Are you sure you want to permanently delete your account? This action cannot be undone!"
|
||||
|
@ -3007,6 +3008,12 @@ en:
|
|||
title: "Discourse Admin"
|
||||
moderator: "Moderator"
|
||||
|
||||
tags:
|
||||
remove_muted_tags_from_latest:
|
||||
always: "always"
|
||||
only_muted: "when used alone or with other muted tags"
|
||||
never: "never"
|
||||
|
||||
reports:
|
||||
title: "List of available reports"
|
||||
|
||||
|
|
|
@ -2019,7 +2019,6 @@ en:
|
|||
min_trust_level_to_tag_topics: "Minimum trust level required to tag topics"
|
||||
suppress_overlapping_tags_in_list: "If tags match exact words in topic titles, don't show the tag"
|
||||
remove_muted_tags_from_latest: "Don't show topics tagged only with muted tags in the latest topic list."
|
||||
mute_other_present_tags: "Don't show topics tagged with both muted and unmuted tags in the latest topic list."
|
||||
force_lowercase_tags: "Force all new tags to be entirely lowercase."
|
||||
|
||||
company_name: "Company Name"
|
||||
|
|
|
@ -2059,9 +2059,10 @@ tags:
|
|||
default: false
|
||||
client: true
|
||||
remove_muted_tags_from_latest:
|
||||
default: false
|
||||
mute_other_present_tags:
|
||||
default: true
|
||||
client: true
|
||||
type: enum
|
||||
default: always
|
||||
enum: RemoveMutedTagsFromLatestSiteSetting
|
||||
force_lowercase_tags:
|
||||
default: true
|
||||
client: true
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MergeRemoveMutedTagsFromLatestSiteSettings < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
execute "UPDATE site_settings SET value = 'always', data_type = 7 WHERE name = 'remove_muted_tags_from_latest' AND value = 't'"
|
||||
execute "UPDATE site_settings SET value = 'never', data_type = 7 WHERE name = 'remove_muted_tags_from_latest' AND value = 'f'"
|
||||
execute "DELETE FROM site_settings WHERE name = 'mute_other_present_tags'"
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
|
@ -875,7 +875,7 @@ class TopicQuery
|
|||
list
|
||||
end
|
||||
def remove_muted_tags(list, user, opts = nil)
|
||||
if user.nil? || !SiteSetting.tagging_enabled || !SiteSetting.remove_muted_tags_from_latest
|
||||
if user.nil? || !SiteSetting.tagging_enabled || SiteSetting.remove_muted_tags_from_latest == 'never'
|
||||
return list
|
||||
end
|
||||
|
||||
|
@ -896,7 +896,7 @@ class TopicQuery
|
|||
return list
|
||||
end
|
||||
|
||||
if SiteSetting.mute_other_present_tags
|
||||
if SiteSetting.remove_muted_tags_from_latest == 'always'
|
||||
list = list.where("
|
||||
NOT EXISTS(
|
||||
SELECT 1
|
||||
|
|
|
@ -244,7 +244,7 @@ describe TopicQuery do
|
|||
context 'muted tags' do
|
||||
it 'is removed from new and latest lists' do
|
||||
SiteSetting.tagging_enabled = true
|
||||
SiteSetting.remove_muted_tags_from_latest = true
|
||||
SiteSetting.remove_muted_tags_from_latest = 'always'
|
||||
|
||||
muted_tag, other_tag = Fabricate(:tag), Fabricate(:tag)
|
||||
|
||||
|
@ -263,13 +263,21 @@ describe TopicQuery do
|
|||
topic_ids = topic_query.list_new.topics.map(&:id)
|
||||
expect(topic_ids).to contain_exactly(tagged_topic.id, untagged_topic.id)
|
||||
|
||||
SiteSetting.mute_other_present_tags = false
|
||||
SiteSetting.remove_muted_tags_from_latest = 'only_muted'
|
||||
|
||||
topic_ids = topic_query.list_latest.topics.map(&:id)
|
||||
expect(topic_ids).to contain_exactly(muted_tagged_topic.id, tagged_topic.id, untagged_topic.id)
|
||||
expect(topic_ids).to contain_exactly(tagged_topic.id, muted_tagged_topic.id, untagged_topic.id)
|
||||
|
||||
topic_ids = topic_query.list_new.topics.map(&:id)
|
||||
expect(topic_ids).to contain_exactly(muted_tagged_topic.id, tagged_topic.id, untagged_topic.id)
|
||||
expect(topic_ids).to contain_exactly(tagged_topic.id, muted_tagged_topic.id, untagged_topic.id)
|
||||
|
||||
SiteSetting.remove_muted_tags_from_latest = 'never'
|
||||
|
||||
topic_ids = topic_query.list_latest.topics.map(&:id)
|
||||
expect(topic_ids).to contain_exactly(muted_topic.id, tagged_topic.id, muted_tagged_topic.id, untagged_topic.id)
|
||||
|
||||
topic_ids = topic_query.list_new.topics.map(&:id)
|
||||
expect(topic_ids).to contain_exactly(muted_topic.id, tagged_topic.id, muted_tagged_topic.id, untagged_topic.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user