mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Default to subcategory when parent category does not allow posting (#21228)
added site toggle functionality through site settings added tests to implemented feature Introduced suggested correction renamed find_new_topic method and deleted click_new_topic_button method
This commit is contained in:
committed by
GitHub
parent
616885895a
commit
83d2f9ef78
@@ -6,6 +6,14 @@ import { getOwner } from "discourse-common/lib/get-owner";
|
||||
export default Mixin.create({
|
||||
openComposer(controller) {
|
||||
let categoryId = controller.get("category.id");
|
||||
|
||||
if (
|
||||
!controller.canCreateTopicOnCategory &&
|
||||
this.siteSettings.default_subcategory_on_read_only_category
|
||||
) {
|
||||
categoryId = controller.get("defaultSubcategory.id");
|
||||
}
|
||||
|
||||
if (
|
||||
categoryId &&
|
||||
controller.category.isUncategorizedCategory &&
|
||||
|
||||
@@ -153,14 +153,33 @@ export default (filterArg, params) => {
|
||||
setupController(controller, model) {
|
||||
const topics = this.topics,
|
||||
category = model.category,
|
||||
canCreateTopic = topics.get("can_create_topic"),
|
||||
canCreateTopicOnCategory =
|
||||
canCreateTopic && category.get("permission") === PermissionType.FULL;
|
||||
canCreateTopic = topics.get("can_create_topic");
|
||||
|
||||
let canCreateTopicOnCategory =
|
||||
canCreateTopic && category.get("permission") === PermissionType.FULL;
|
||||
|
||||
let defaultSubcategory;
|
||||
let canCreateTopicOnSubCategory;
|
||||
|
||||
if (
|
||||
!canCreateTopicOnCategory &&
|
||||
this.siteSettings.default_subcategory_on_read_only_category
|
||||
) {
|
||||
defaultSubcategory = category.subcategories.find((subcategory) => {
|
||||
return subcategory.get("permission") === PermissionType.FULL;
|
||||
});
|
||||
|
||||
canCreateTopicOnSubCategory = !!defaultSubcategory;
|
||||
}
|
||||
|
||||
this.controllerFor("navigation/category").setProperties({
|
||||
canCreateTopicOnCategory,
|
||||
cannotCreateTopicOnCategory: !canCreateTopicOnCategory,
|
||||
cannotCreateTopicOnCategory: !(
|
||||
canCreateTopicOnCategory || canCreateTopicOnSubCategory
|
||||
),
|
||||
canCreateTopic,
|
||||
canCreateTopicOnSubCategory,
|
||||
defaultSubcategory,
|
||||
});
|
||||
|
||||
let topicOpts = {
|
||||
@@ -174,6 +193,8 @@ export default (filterArg, params) => {
|
||||
expandAllPinned: true,
|
||||
canCreateTopic,
|
||||
canCreateTopicOnCategory,
|
||||
canCreateTopicOnSubCategory,
|
||||
defaultSubcategory,
|
||||
};
|
||||
|
||||
const p = category.get("params");
|
||||
|
||||
Reference in New Issue
Block a user