From 0992e9601cf9dc76c226f26a4b453e6de7572797 Mon Sep 17 00:00:00 2001 From: jumagura Date: Tue, 19 Sep 2023 14:17:06 -0400 Subject: [PATCH] DEV: Make hide category default when custom wizard is selected --- .../custom-wizard-category-settings.hbs | 10 ---------- .../custom-wizard-category-settings.js.es6 | 11 ----------- .../discourse/initializers/custom-wizard-edits.js.es6 | 2 +- config/locales/client.en.yml | 1 - plugin.rb | 3 +-- test/javascripts/fixtures/categories.js.es6 | 5 ----- 6 files changed, 2 insertions(+), 30 deletions(-) diff --git a/assets/javascripts/discourse/connectors/category-custom-settings/custom-wizard-category-settings.hbs b/assets/javascripts/discourse/connectors/category-custom-settings/custom-wizard-category-settings.hbs index f548e93f..2c6a6975 100644 --- a/assets/javascripts/discourse/connectors/category-custom-settings/custom-wizard-category-settings.hbs +++ b/assets/javascripts/discourse/connectors/category-custom-settings/custom-wizard-category-settings.hbs @@ -12,14 +12,4 @@ options=(hash none="admin.wizard.select") }} - -
-
\ No newline at end of file diff --git a/assets/javascripts/discourse/connectors/category-custom-settings/custom-wizard-category-settings.js.es6 b/assets/javascripts/discourse/connectors/category-custom-settings/custom-wizard-category-settings.js.es6 index 552ee193..7004c317 100644 --- a/assets/javascripts/discourse/connectors/category-custom-settings/custom-wizard-category-settings.js.es6 +++ b/assets/javascripts/discourse/connectors/category-custom-settings/custom-wizard-category-settings.js.es6 @@ -13,10 +13,6 @@ export default { "wizardListVal", attrs?.category?.custom_fields?.create_topic_wizard ); - component.set( - "hideFromComposer", - attrs?.category?.custom_fields?.custom_wizard_hide_from_composer - ); }, actions: { @@ -24,12 +20,5 @@ export default { this.set("wizardListVal", wizard); this.set("category.custom_fields.create_topic_wizard", wizard); }, - toggleHideFromComposer() { - this.toggleProperty("hideFromComposer"); - this.set( - "category.custom_fields.custom_wizard_hide_from_composer", - this.hideFromComposer - ); - }, }, }; diff --git a/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 b/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 index 5019ef83..bd3c3d2d 100644 --- a/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 +++ b/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6 @@ -89,7 +89,7 @@ export default { let categories = this._super(options); return categories.filter((category) => { - return !category.custom_fields?.custom_wizard_hide_from_composer; + return !category.custom_fields?.create_topic_wizard; }); }, }); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 1fd9f158..98519335 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -133,7 +133,6 @@ en: custom_wizard: title: "Custom Wizard" create_topic_wizard: "Select a wizard to replace the new topic composer in this category." - hide_from_composer: "Exclude category from composer dropdown" message: wizard: diff --git a/plugin.rb b/plugin.rb index a16d47d1..d5eed12b 100644 --- a/plugin.rb +++ b/plugin.rb @@ -105,7 +105,6 @@ after_initialize do # preloaded category custom fields %w[ create_topic_wizard - custom_wizard_hide_from_composer ].each do |custom_field| Site.preloaded_category_custom_fields << custom_field end @@ -202,7 +201,7 @@ after_initialize do ::InvitesController.prepend InvitesControllerCustomWizard ::UsersController.prepend CustomWizardUsersController ::Guardian.prepend CustomWizardGuardian - + full_path = "#{Rails.root}/plugins/discourse-custom-wizard/assets/stylesheets/wizard/wizard_custom.scss" if Stylesheet::Importer.respond_to?(:plugin_assets) Stylesheet::Importer.plugin_assets['wizard_custom'] = Set[full_path] diff --git a/test/javascripts/fixtures/categories.js.es6 b/test/javascripts/fixtures/categories.js.es6 index 432a1b77..e553f860 100644 --- a/test/javascripts/fixtures/categories.js.es6 +++ b/test/javascripts/fixtures/categories.js.es6 @@ -33,7 +33,6 @@ export default { navigate_to_first_post_after_read: false, custom_fields: { create_topic_wizard: null, - custom_wizard_hide_from_composer: null, }, allowed_tags: [], allowed_tag_groups: [], @@ -78,7 +77,6 @@ export default { navigate_to_first_post_after_read: false, custom_fields: { create_topic_wizard: null, - custom_wizard_hide_from_composer: null, }, allowed_tags: [], allowed_tag_groups: [], @@ -123,7 +121,6 @@ export default { navigate_to_first_post_after_read: false, custom_fields: { create_topic_wizard: null, - custom_wizard_hide_from_composer: null, }, allowed_tags: [], allowed_tag_groups: [], @@ -168,7 +165,6 @@ export default { navigate_to_first_post_after_read: false, custom_fields: { create_topic_wizard: null, - custom_wizard_hide_from_composer: null, }, allowed_tags: [], allowed_tag_groups: [], @@ -210,7 +206,6 @@ export default { navigate_to_first_post_after_read: false, custom_fields: { create_topic_wizard: null, - custom_wizard_hide_from_composer: "t", }, allowed_tags: [], allowed_tag_groups: [],