mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 22:57:40 +08:00
FEATURE: Default Composer Category Site Setting (#18967)
* FEATURE: Default Composer Category Site Setting - Create the default_composer_category site setting - Replace general_category_id logic for auto selecting the composer category - Prevent Uncategorized from being selected if not allowed - Add default_composer_category option to seeded categories - Create a migration to populate the default_composer_category site setting if there is a general_category_id populated - Added some tests * Add missing translation for the new site setting * fix some js tests * Just check that the header value is null
This commit is contained in:
@ -87,7 +87,8 @@ module SeedData
|
||||
text_color: 'FFFFFF',
|
||||
permissions: { everyone: :full },
|
||||
force_permissions: true,
|
||||
sidebar: true
|
||||
sidebar: true,
|
||||
default_composer_category: true
|
||||
}
|
||||
]
|
||||
|
||||
@ -99,7 +100,7 @@ module SeedData
|
||||
end
|
||||
|
||||
def create_category(site_setting_name:, name:, description:, position:, color:, text_color:,
|
||||
permissions:, force_permissions:, force_existence: false, sidebar: false)
|
||||
permissions:, force_permissions:, force_existence: false, sidebar: false, default_composer_category: false)
|
||||
category_id = SiteSetting.get(site_setting_name)
|
||||
|
||||
if should_create_category?(category_id, force_existence)
|
||||
@ -123,6 +124,10 @@ module SeedData
|
||||
sidebar_categories << category.id
|
||||
SiteSetting.set('default_sidebar_categories', sidebar_categories.join('|'))
|
||||
end
|
||||
|
||||
if default_composer_category
|
||||
SiteSetting.set('default_composer_category', category.id)
|
||||
end
|
||||
elsif category = Category.find_by(id: category_id)
|
||||
if description.present? && (category.topic_id.blank? || !Topic.exists?(category.topic_id))
|
||||
category.description = description
|
||||
|
Reference in New Issue
Block a user