A platform for community discussion. Free, open, simple.
UX: Degrade gracefully when visiting Support tab for non-support type categories (#38361)
Martin Brennan3f789f2e05b4
diff --git a/plugins/discourse-solved/assets/javascripts/discourse/components/upsert-category-support.gjs b/plugins/discourse-solved/assets/javascripts/discourse/components/upsert-category-support.gjsindex b3bac7da5ae..6762aff8cd5 100644--- a/plugins/discourse-solved/assets/javascripts/discourse/components/upsert-category-support.gjs+++ b/plugins/discourse-solved/assets/javascripts/discourse/components/upsert-category-support.gjs@@ -1,11 +1,21 @@+import Component from "@glimmer/component";import EditCategoryTypeSchemaFields from "discourse/components/edit-category-type-schema-fields";+import { i18n } from "discourse-i18n";-const UpsertCategorySupport = <template>- <EditCategoryTypeSchemaFields- @category={{@category}}- @categoryType="support"- @form={{@form}}- />-</template>;+export default class UpsertCategorySupport extends Component {+ get isSupportCategory() {+ return this.args.category.isType("support");+ }-export default UpsertCategorySupport;+ <template>+ {{#if this.isSupportCategory}}+ <EditCategoryTypeSchemaFields+ @category={{@category}}+ @categoryType="support"+ @form={{@form}}+ />+ {{else}}+ {{i18n "solved.category_type_support.not_support_type"}}+ {{/if}}+ </template>+}diff --git a/plugins/discourse-solved/assets/javascripts/discourse/initializers/solved-category-type-tab.js b/plugins/discourse-solved/assets/javascripts/discourse/initializers/solved-category-type-tab.jsindex 04130e1b107..a300f192ad8 100644--- a/plugins/discourse-solved/assets/javascripts/discourse/initializers/solved-category-type-tab.js+++ b/plugins/discourse-solved/assets/javascripts/discourse/initializers/solved-category-type-tab.js@@ -1,4 +1,5 @@import { withPluginApi } from "discourse/lib/plugin-api";+import { i18n } from "discourse-i18n";import UpsertCategorySupport from "../components/upsert-category-support";export default {@@ -8,7 +9,7 @@ export default {withPluginApi((api) => {api.registerEditCategoryTab({id: "support",- name: "Support",+ name: i18n("solved.category_type_support.title"),primary: true,component: UpsertCategorySupport,condition: ({ category }) => category.isType("support"),diff --git a/plugins/discourse-solved/config/locales/client.en.yml b/plugins/discourse-solved/config/locales/client.en.ymlindex a4cac3f1cc3..14da644ed2d 100644--- a/plugins/discourse-solved/config/locales/client.en.yml+++ b/plugins/discourse-solved/config/locales/client.en.yml@@ -54,6 +54,9 @@ en:description: "Highlight the answer and help others by using the solution button below the correct reply."notification:title: "your post was marked as solution"+ category_type_support:+ title: "Support"+ not_support_type: "Heads up! You've disabled the ability to mark posts as solutions in this category. To turn that back on, you'll find the relevant settings in the Settings tab."topic_statuses:solved:diff --git a/plugins/discourse-solved/spec/system/support_category_type_setup_spec.rb b/plugins/discourse-solved/spec/system/support_category_type_setup_spec.rbindex 2110ae759cd..d9897639b5c 100644--- a/plugins/discourse-solved/spec/system/support_category_type_setup_spec.rb+++ b/plugins/discourse-solved/spec/system/support_category_type_setup_spec.rb@@ -42,4 +42,13 @@ RSpec.describe "Support Category Type Setup", type: :system doexpect(category.custom_fields["enable_accepted_answers"]).to eq("true")expect(category.custom_fields["solved_topics_auto_close_hours"]).to eq("48")end++ context "when visiting the Support tab for a non-support category" do+ fab!(:category)++ it "shows the not support type message" do+ visit("/c/#{category.slug}/edit/support")+ expect(page).to have_content(I18n.t("js.solved.category_type_support.not_support_type"))+ end+ endend