Skip to content

A platform for community discussion. Free, open, simple.

FIX: Show category type tabs even if plugin disabled (#39741)

Martin Brennan3f8b3c29e770
diff --git a/app/services/categories/types/base.rb b/app/services/categories/types/base.rb
index 411b1dd8947..12a08efa8d9 100644
--- a/app/services/categories/types/base.rb
+++ b/app/services/categories/types/base.rb
@@ -294,6 +294,7 @@ module Categories
description: I18n.t("category_types.#{type_id}.description", default: ""),
icon:,
available: available?,
+ visible: visible?,
configuration_schema: resolved_configuration_schema,
}.merge(additional_metadata)
end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index d4468491816..39859aa8653 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -4936,6 +4936,8 @@ en:
predefined_colors: "Predefined color options"
name_placeholder: "One or two words recommended"
category_types: "Category types"
+ unknown_category_type: "Unknown category type"
+ unknown_category_type_description: "The category type '%{categoryType}' is not supported or not enabled on this category."
category_types_no_results: "No other category types found"
color_placeholder: "Any web color"
delete_confirm: "Are you sure you want to delete this category?"
diff --git a/frontend/discourse/admin/routes/new-category/setup.js b/frontend/discourse/admin/routes/new-category/setup.js
index 372b6b892b5..9f6dd4c9ff4 100644
--- a/frontend/discourse/admin/routes/new-category/setup.js
+++ b/frontend/discourse/admin/routes/new-category/setup.js
@@ -22,13 +22,7 @@ export default class NewCategorySetup extends DiscourseRoute {
if (this.categoryTypeChooser.allTypes.length === 1) {
const type = this.categoryTypeChooser.allTypes[0];
- this.categoryTypeChooser.choose(
- type.id,
- type.name,
- type.configuration_schema,
- type.title,
- model.counts[type.id]
- );
+ this.categoryTypeChooser.choose(type, model.counts[type.id]);
this.router.transitionTo("newCategory.tabs", "general");
}
}
diff --git a/frontend/discourse/admin/routes/new-category/tabs.js b/frontend/discourse/admin/routes/new-category/tabs.js
index b02a86ea8c7..e9c33f1178e 100644
--- a/frontend/discourse/admin/routes/new-category/tabs.js
+++ b/frontend/discourse/admin/routes/new-category/tabs.js
@@ -30,7 +30,7 @@ export default class NewCategoryTabs extends DiscourseRoute {
// when creating a new category, so we need to keep the selection in memory.
//
// categoryTypeChooser is reset when leaving the newCategory route anyway.
- const result = this.categoryTypeChooser.currentSelection();
+ const result = this.categoryTypeChooser.currentSelection;
if (result) {
const initialTypes = {};
initialTypes[result.type] = {
@@ -38,6 +38,8 @@ export default class NewCategoryTabs extends DiscourseRoute {
name: result.typeName,
configuration_schema: result.typeSchema,
title: result.typeTitle,
+ visible: result.visible,
+ available: result.available,
};
model.set("categoryTypes", initialTypes);
diff --git a/frontend/discourse/admin/templates/edit-category/tabs-horizontal.gjs b/frontend/discourse/admin/templates/edit-category/tabs-horizontal.gjs
index bbbb3ce7494..46f850529c6 100644
--- a/frontend/discourse/admin/templates/edit-category/tabs-horizontal.gjs
+++ b/frontend/discourse/admin/templates/edit-category/tabs-horizontal.gjs
@@ -20,6 +20,12 @@ export default class EditCategoryTabsHorizontalTemplate extends Component {
});
}
+ get dynamicCategoryTypeTabs() {
+ return Object.values(this.args.controller.model.categoryTypes).filter(
+ (type) => type.id !== "discussion" && type.visible
+ );
+ }
+
get visiblePrimaryTabs() {
return registeredEditCategoryTabs.filter(
(tab) =>
@@ -28,7 +34,10 @@ export default class EditCategoryTabsHorizontalTemplate extends Component {
}
get hasPrimaryTabs() {
- return this.visiblePrimaryTabs.length > 0;
+ return (
+ this.visiblePrimaryTabs.length > 0 ||
+ this.dynamicCategoryTypeTabs.length > 0
+ );
}
<template>
@@ -75,6 +84,15 @@ export default class EditCategoryTabsHorizontalTemplate extends Component {
{{/if}}
{{/if}}
{{/each}}
+ {{#each this.dynamicCategoryTypeTabs as |dynamicTab|}}
+ <EditCategoryTab
+ @panels={{@controller.panels}}
+ @selectedTab={{@controller.selectedTab}}
+ @params={{@controller.parentParams}}
+ @tab={{dynamicTab.id}}
+ @tabTitle={{dynamicTab.name}}
+ />
+ {{/each}}
<EditCategoryTab
@panels={{@controller.panels}}
@selectedTab={{@controller.selectedTab}}
@@ -152,6 +170,15 @@ export default class EditCategoryTabsHorizontalTemplate extends Component {
@tabTitle={{pluginTab.name}}
/>
{{/each}}
+ {{#each this.dynamicCategoryTypeTabs as |dynamicTab|}}
+ <EditCategoryTab
+ @panels={{@controller.panels}}
+ @selectedTab={{@controller.selectedTab}}
+ @params={{@controller.parentParams}}
+ @tab={{dynamicTab.id}}
+ @tabTitle={{dynamicTab.name}}
+ />
+ {{/each}}
{{/if}}
</:tabs>
<:drawer>
diff --git a/frontend/discourse/admin/templates/edit-category/tabs.gjs b/frontend/discourse/admin/templates/edit-category/tabs.gjs
index 42e9d4ddfe3..fffa9b20b9c 100644
--- a/frontend/discourse/admin/templates/edit-category/tabs.gjs
+++ b/frontend/discourse/admin/templates/edit-category/tabs.gjs
@@ -1,3 +1,4 @@
+import Component from "@glimmer/component";
import { concat } from "@ember/helper";
import { trustHTML } from "@ember/template";
import ChangesBanner from "discourse/admin/components/changes-banner";
@@ -16,7 +17,9 @@ import UpsertCategorySettings from "discourse/admin/components/upsert-category/s
import UpsertCategoryTags from "discourse/admin/components/upsert-category/tags";
import EditCategoryTabsHorizontal from "discourse/admin/templates/edit-category/tabs-horizontal";
import EditCategoryTabsVertical from "discourse/admin/templates/edit-category/tabs-vertical";
+import EditCategoryTypeSchemaFields from "discourse/components/edit-category-type-schema-fields";
import Form from "discourse/components/form";
+import { bind } from "discourse/lib/decorators";
import { registeredEditCategoryTabs } from "discourse/lib/edit-category-tabs";
import { or } from "discourse/truth-helpers";
import { i18n } from "discourse-i18n";
@@ -43,150 +46,170 @@ const TAB_COMPONENTS_V2 = {
localizations: EditCategoryLocalizations,
};
-function componentFor(name, useSimplified) {
- name = name.replace("edit-category-", "");
- const components = useSimplified ? TAB_COMPONENTS_V2 : TAB_COMPONENTS;
+const UnknownCategoryType = <template>
+ <div class="edit-category-unknown-category-type">
+ <h3>{{i18n "category.unknown_category_type"}}</h3>
+ <p>{{i18n
+ "category.unknown_category_type_description"
+ categoryType=@categoryType
+ }}</p>
+ </div>
+</template>;
- if (components[name]) {
- return components[name];
- }
+export default class Tabs extends Component {
+ @bind
+ componentFor(name, useSimplified) {
+ name = name.replace("edit-category-", "");
+ const components = useSimplified ? TAB_COMPONENTS_V2 : TAB_COMPONENTS;
- const pluginTab = registeredEditCategoryTabs.find((tab) => tab.id === name);
- if (pluginTab) {
- return pluginTab.component;
- }
+ if (components[name]) {
+ return components[name];
+ }
- throw new Error(`No category-tab component found for tab name: ${name}`);
-}
+ // Shows additional tabs manually registered by plugins
+ const pluginTab = registeredEditCategoryTabs.find((tab) => tab.id === name);
+ if (pluginTab) {
+ return pluginTab.component;
+ }
-export default <template>
- <div class="edit-category {{if @controller.expandedMenu 'expanded-menu'}}">
- {{#if @controller.siteSettings.enable_simplified_category_creation}}
- <EditCategoryTabsHorizontal
- @controller={{@controller}}
- class="edit-category-page-header"
- />
- {{else}}
- <EditCategoryTabsVertical @controller={{@controller}} />
- {{/if}}
+ // Used to show category type specific tabs. Types may be registered by plugins.
+ if (this.args.controller.model.categoryTypes[name]) {
+ return EditCategoryTypeSchemaFields;
+ }
+
+ return UnknownCategoryType;
+ }
+
+ <template>
+ <div class="edit-category {{if @controller.expandedMenu 'expanded-menu'}}">
+ {{#if @controller.siteSettings.enable_simplified_category_creation}}
+ <EditCategoryTabsHorizontal
+ @controller={{@controller}}
+ class="edit-category-page-header"
+ />
+ {{else}}
+ <EditCategoryTabsVertical @controller={{@controller}} />
+ {{/if}}
- <Form
- @data={{@controller.formData}}
- @onDirtyCheck={{@controller.isLeavingForm}}
- @onSubmit={{@controller.saveCategory}}
- @validate={{@controller.validateForm}}
- @onRegisterApi={{@controller.onRegisterFormApi}}
- @onReset={{@controller.onFormReset}}
- as |form transientData|
- >
- <form.Section
- class="edit-category-content edit-category-tab-{{@controller.selectedTab}}"
+ <Form
+ @data={{@controller.formData}}
+ @onDirtyCheck={{@controller.isLeavingForm}}
+ @onSubmit={{@controller.saveCategory}}
+ @validate={{@controller.validateForm}}
+ @onRegisterApi={{@controller.onRegisterFormApi}}
+ @onReset={{@controller.onFormReset}}
+ as |form transientData|
>
- {{#if @controller.siteSettings.enable_simplified_category_creation}}
- {{#let
- (componentFor
- (concat "edit-category-" @controller.selectedTab)
- @controller.siteSettings.enable_simplified_category_creation
- )
- as |Tab|
- }}
- <Tab
- @selectedTab={{@controller.selectedTab}}
- @category={{@controller.model}}
- @registerValidator={{@controller.registerValidator}}
- @registerAfterReset={{@controller.registerAfterReset}}
- @transientData={{transientData}}
- @form={{form}}
- @setSelectedTab={{@controller.setSelectedTab}}
- />
- {{/let}}
- {{else}}
- {{#each @controller.panels as |tabName|}}
+ <form.Section
+ class="edit-category-content edit-category-tab-{{@controller.selectedTab}}"
+ >
+ {{#if @controller.siteSettings.enable_simplified_category_creation}}
{{#let
- (componentFor
- tabName
+ (this.componentFor
+ (concat "edit-category-" @controller.selectedTab)
@controller.siteSettings.enable_simplified_category_creation
)
as |Tab|
}}
<Tab
@selectedTab={{@controller.selectedTab}}
+ @categoryType={{@controller.selectedTab}}
@category={{@controller.model}}
@registerValidator={{@controller.registerValidator}}
@registerAfterReset={{@controller.registerAfterReset}}
@transientData={{transientData}}
@form={{form}}
+ @setSelectedTab={{@controller.setSelectedTab}}
/>
{{/let}}
- {{/each}}
- {{/if}}
- </form.Section>
+ {{else}}
+ {{#each @controller.panels as |tabName|}}
+ {{#let
+ (this.componentFor
+ tabName
+ @controller.siteSettings.enable_simplified_category_creation
+ )
+ as |Tab|
+ }}
+ <Tab
+ @selectedTab={{@controller.selectedTab}}
+ @category={{@controller.model}}
+ @registerValidator={{@controller.registerValidator}}
+ @registerAfterReset={{@controller.registerAfterReset}}
+ @transientData={{transientData}}
+ @form={{form}}
+ />
+ {{/let}}
+ {{/each}}
+ {{/if}}
+ </form.Section>
- {{#if @controller.showDeleteReason}}
- <form.Alert @type="warning" class="edit-category-delete-warning">
- {{trustHTML @controller.model.cannot_delete_reason}}
- </form.Alert>
- {{/if}}
+ {{#if @controller.showDeleteReason}}
+ <form.Alert @type="warning" class="edit-category-delete-warning">
+ {{trustHTML @controller.model.cannot_delete_reason}}
+ </form.Alert>
+ {{/if}}
- {{#if @controller.siteSettings.enable_simplified_category_creation}}
- {{#if (or @controller.model.can_delete @controller.model.id)}}
+ {{#if @controller.siteSettings.enable_simplified_category_creation}}
+ {{#if (or @controller.model.can_delete @controller.model.id)}}
+ <form.Actions class="edit-category-footer">
+ {{#if @controller.model.can_delete}}
+ <form.Button
+ @action={{@controller.deleteCategory}}
+ @icon="trash-can"
+ @label="category.delete"
+ class="btn-danger btn-small"
+ />
+ {{else}}
+ <form.Button
+ @action={{@controller.toggleDeleteTooltip}}
+ @icon="circle-question"
+ @label="category.delete"
+ class="btn-default btn-small"
+ />
+ {{/if}}
+ </form.Actions>
+ {{/if}}
+ {{else}}
<form.Actions class="edit-category-footer">
+ <form.Submit @label={{@controller.saveLabel}} id="save-category" />
+
{{#if @controller.model.can_delete}}
<form.Button
+ @disabled={{@controller.deleteDisabled}}
@action={{@controller.deleteCategory}}
@icon="trash-can"
@label="category.delete"
- class="btn-danger btn-small"
+ class="btn-danger"
/>
- {{else}}
+ {{else if @controller.model.id}}
<form.Button
+ @disabled={{@controller.deleteDisabled}}
@action={{@controller.toggleDeleteTooltip}}
@icon="circle-question"
@label="category.delete"
- class="btn-default btn-small"
+ class="btn-default"
/>
{{/if}}
</form.Actions>
{{/if}}
- {{else}}
- <form.Actions class="edit-category-footer">
- <form.Submit @label={{@controller.saveLabel}} id="save-category" />
-
- {{#if @controller.model.can_delete}}
- <form.Button
- @disabled={{@controller.deleteDisabled}}
- @action={{@controller.deleteCategory}}
- @icon="trash-can"
- @label="category.delete"
- class="btn-danger"
- />
- {{else if @controller.model.id}}
- <form.Button
- @disabled={{@controller.deleteDisabled}}
- @action={{@controller.toggleDeleteTooltip}}
- @icon="circle-question"
- @label="category.delete"
- class="btn-default"
- />
- {{/if}}
- </form.Actions>
- {{/if}}
- </Form>
+ </Form>
- {{#if @controller.siteSettings.enable_simplified_category_creation}}
- {{#if (or @controller.model.isNew @controller.isFormDirty)}}
- <ChangesBanner
- @bannerLabel={{i18n "category.unsaved_changes"}}
- @saveLabel={{if
- @controller.model.id
- (i18n "category.save")
- (i18n "category.create_category")
- }}
- @discardLabel={{i18n "form_kit.reset"}}
- @save={{@controller.formApi.submit}}
- @discard={{@controller.formApi.reset}}
- />
+ {{#if @controller.siteSettings.enable_simplified_category_creation}}
+ {{#if (or @controller.model.isNew @controller.isFormDirty)}}
+ <ChangesBanner
+ @bannerLabel={{i18n "category.unsaved_changes"}}
+ @saveLabel={{if
+ @controller.model.id
+ (i18n "category.save")
+ (i18n "category.create_category")
+ }}
+ @discardLabel={{i18n "form_kit.reset"}}
+ @save={{@controller.formApi.submit}}
+ @discard={{@controller.formApi.reset}}
+ />
+ {{/if}}
{{/if}}
- {{/if}}
- </div>
-</template>
+ </div>
+ </template>
+}
diff --git a/frontend/discourse/app/components/category-type-cards.gjs b/frontend/discourse/app/components/category-type-cards.gjs
index 49546e78f1d..2f9ff5a414c 100644
--- a/frontend/discourse/app/components/category-type-cards.gjs
+++ b/frontend/discourse/app/components/category-type-cards.gjs
@@ -15,13 +15,7 @@ export default class CategoryTypeCards extends Component {
@action
selectType(type) {
- this.categoryTypeChooser.choose(
- type.id,
- type.name,
- type.configuration_schema,
- type.title,
- this.args.counts[type.id]
- );
+ this.categoryTypeChooser.choose(type, this.args.counts[type.id]);
this.router.transitionTo("newCategory.tabs", "general");
}
diff --git a/frontend/discourse/app/services/category-type-chooser.js b/frontend/discourse/app/services/category-type-chooser.js
index b9ff2244568..32df5cd4c25 100644
--- a/frontend/discourse/app/services/category-type-chooser.js
+++ b/frontend/discourse/app/services/category-type-chooser.js
@@ -24,13 +24,21 @@ export default class CategoryTypeChooser extends Service {
this._allTypes = types;
}
- choose(typeId, typeName, typeSchema, typeTitle, count) {
- this._selection = { type: typeId, typeName, typeSchema, typeTitle, count };
- this._setupComplete = true;
+ get currentSelection() {
+ return this._selection;
}
- currentSelection() {
- return this._selection;
+ choose(type, count) {
+ this._selection = {
+ type: type.id,
+ typeName: type.name,
+ typeSchema: type.configuration_schema,
+ typeTitle: type.title,
+ visible: type.visible,
+ available: type.available,
+ count,
+ };
+ this._setupComplete = true;
}
reset() {
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.gjs
deleted file mode 100644
index f3ab7ebf741..00000000000
--- a/plugins/discourse-solved/assets/javascripts/discourse/components/upsert-category-support.gjs
+++ /dev/null
@@ -1,64 +0,0 @@
-import Component from "@glimmer/component";
-import { action } from "@ember/object";
-import { service } from "@ember/service";
-import EditCategoryTypeSchemaFields from "discourse/components/edit-category-type-schema-fields";
-import { popupAjaxError } from "discourse/lib/ajax-error";
-import Category from "discourse/models/category";
-import { i18n } from "discourse-i18n";
-
-export default class UpsertCategorySupport extends Component {
- @service dialog;
- @service toasts;
- @service router;
-
- get isSupportCategory() {
- return this.args.category.isType("support");
- }
-
- @action
- removeSupportCategory() {
- this.dialog.yesNoConfirm({
- message: i18n("solved.category_type_support.confirm_remove_support_type"),
- didConfirm: async () => {
- this.args.category.set(
- "custom_fields.enable_accepted_answers",
- "false"
- );
- this.args.form.set("custom_fields.enable_accepted_answers", "false");
- try {
- await this.args.category.save();
- this.args.category.removeType("support");
- this.toasts.success({
- duration: "short",
- data: {
- message: i18n("saved"),
- },
- });
- this.router.transitionTo(
- "editCategory.tabs",
- Category.slugFor(this.args.category),
- "general"
- );
- } catch (err) {
- this.args.category.set(
- "custom_fields.enable_accepted_answers",
- "true"
- );
- popupAjaxError(err);
- }
- },
- });
- }
-
- <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.js
deleted file mode 100644
index 1c47aeea7a1..00000000000
--- a/plugins/discourse-solved/assets/javascripts/discourse/initializers/solved-category-type-tab.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import { withPluginApi } from "discourse/lib/plugin-api";
-import { i18n } from "discourse-i18n";
-import UpsertCategorySupport from "../components/upsert-category-support";
-
-export default {
- name: "solved-category-type-tab",
-
- initialize(container) {
- const siteSettings = container.lookup("service:site-settings");
- withPluginApi((api) => {
- api.registerEditCategoryTab({
- id: "support",
- name: i18n("solved.category_type_support.title"),
- primary: true,
- component: UpsertCategorySupport,
- condition: ({ category }) => {
- return (
- category.isType("support") &&
- siteSettings.enable_support_category_type_setup
- );
- },
- });
- });
- },
-};
diff --git a/plugins/discourse-solved/config/locales/client.en.yml b/plugins/discourse-solved/config/locales/client.en.yml
index 27d5e1f8126..cafb8176437 100644
--- a/plugins/discourse-solved/config/locales/client.en.yml
+++ b/plugins/discourse-solved/config/locales/client.en.yml
@@ -67,9 +67,6 @@ en:
description: "You will be notified of every new reply in this topic and when the topic is solved. A count of new replies will be shown for this topic."
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."
- remove_support_type: "Remove Support type"
- confirm_remove_support_type: "Are you sure you want to remove the ability to mark posts as solutions in this category? You can re-enable it in the Settings tab later."
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.rb
index 43703a462ba..4668c3c17b8 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
@@ -46,6 +46,14 @@ RSpec.describe "Support Category Type Setup" do
expect(category.custom_fields["empty_box_on_unsolved"]).to eq("true")
end
+ it "is able to click the support tab when creating a new category when solved is disabled" do
+ SiteSetting.solved_enabled = false
+ visit("/new-category/setup")
+ category_type_card.find_type_card("support").click
+ expect(page).to have_content(I18n.t("js.category.create_with_type", typeName: "support"))
+ expect(page).to have_css(".d-nav-submenu__tabs .edit-category-support")
+ end
+
context "when the support category type setup is disabled" do
before { SiteSetting.enable_support_category_type_setup = false }
@@ -154,7 +162,9 @@ RSpec.describe "Support Category Type Setup" do
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"))
+ expect(page).to have_content(
+ I18n.t("js.category.unknown_category_type_description", categoryType: "support"),
+ )
end
end
end
diff --git a/plugins/discourse-topic-voting/assets/javascripts/discourse/components/upsert-category-ideas.gjs b/plugins/discourse-topic-voting/assets/javascripts/discourse/components/upsert-category-ideas.gjs
deleted file mode 100644
index 73ebce60381..00000000000
--- a/plugins/discourse-topic-voting/assets/javascripts/discourse/components/upsert-category-ideas.gjs
+++ /dev/null
@@ -1,60 +0,0 @@
-import Component from "@glimmer/component";
-import { action } from "@ember/object";
-import { service } from "@ember/service";
-import EditCategoryTypeSchemaFields from "discourse/components/edit-category-type-schema-fields";
-import { popupAjaxError } from "discourse/lib/ajax-error";
-import Category from "discourse/models/category";
-import { i18n } from "discourse-i18n";
-
-export default class UpsertCategoryIdeas extends Component {
- @service dialog;
- @service toasts;
- @service router;
-
- get isIdeasCategory() {
- return this.args.category.isType("ideas");
- }
-
- @action
- removeIdeasCategory() {
- this.dialog.yesNoConfirm({
- message: i18n(
- "topic_voting.category_type_ideas.confirm_remove_ideas_type"
- ),
- didConfirm: async () => {
- this.args.category.set("custom_fields.enable_topic_voting", "false");
- this.args.form.set("custom_fields.enable_topic_voting", "false");
- try {
- await this.args.category.save();
- this.args.category.removeType("ideas");
- this.toasts.success({
- duration: "short",
- data: {
- message: i18n("saved"),
- },
- });
- this.router.transitionTo(
- "editCategory.tabs",
- Category.slugFor(this.args.category),
- "general"
- );
- } catch (err) {
- this.args.category.set("custom_fields.enable_topic_voting", "true");
- popupAjaxError(err);
- }
- },
- });
- }
-
- <template>
- {{#if this.isIdeasCategory}}
- <EditCategoryTypeSchemaFields
- @category={{@category}}
- @categoryType="ideas"
- @form={{@form}}
- />
- {{else}}
- {{i18n "topic_voting.category_type_ideas.not_ideas_type"}}
- {{/if}}
- </template>
-}
diff --git a/plugins/discourse-topic-voting/assets/javascripts/discourse/initializers/ideas-category-type-tab.js b/plugins/discourse-topic-voting/assets/javascripts/discourse/initializers/ideas-category-type-tab.js
deleted file mode 100644
index 34145a98f70..00000000000
--- a/plugins/discourse-topic-voting/assets/javascripts/discourse/initializers/ideas-category-type-tab.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import { withPluginApi } from "discourse/lib/plugin-api";
-import { i18n } from "discourse-i18n";
-import UpsertCategoryIdeas from "../components/upsert-category-ideas";
-
-export default {
- name: "ideas-category-type-tab",
-
- initialize(container) {
- const siteSettings = container.lookup("service:site-settings");
- withPluginApi((api) => {
- api.registerEditCategoryTab({
- id: "ideas",
- name: i18n("topic_voting.category_type_ideas.title"),
- primary: true,
- component: UpsertCategoryIdeas,
- condition: ({ category }) => {
- return (
- category.isType("ideas") &&
- siteSettings.enable_ideas_category_type_setup
- );
- },
- });
- });
- },
-};
diff --git a/plugins/discourse-topic-voting/config/locales/client.en.yml b/plugins/discourse-topic-voting/config/locales/client.en.yml
index dd3b7f5c65e..f3094ecb0ed 100755
--- a/plugins/discourse-topic-voting/config/locales/client.en.yml
+++ b/plugins/discourse-topic-voting/config/locales/client.en.yml
@@ -11,9 +11,6 @@ en:
topic_voting:
category_type_ideas:
title: "Ideas"
- not_ideas_type: "Heads up! You've disabled voting in this category. To turn that back on, you'll find the relevant settings in the Settings tab."
- remove_ideas_type: "Remove Ideas type"
- confirm_remove_ideas_type: "Are you sure you want to remove voting from this category? Existing votes will be preserved but members won't be able to cast new votes."
notification_label:
vote_released: "Vote returned"
title: "Topic voting"
diff --git a/plugins/discourse-topic-voting/spec/system/ideas_category_type_setup_spec.rb b/plugins/discourse-topic-voting/spec/system/ideas_category_type_setup_spec.rb
index 10d366304b4..2728eccb18f 100644
--- a/plugins/discourse-topic-voting/spec/system/ideas_category_type_setup_spec.rb
+++ b/plugins/discourse-topic-voting/spec/system/ideas_category_type_setup_spec.rb
@@ -109,7 +109,9 @@ RSpec.describe "Ideas Category Type Setup" do
it "shows the not ideas type message" do
visit("/c/#{category.slug}/edit/ideas")
- expect(page).to have_content(I18n.t("js.topic_voting.category_type_ideas.not_ideas_type"))
+ expect(page).to have_content(
+ I18n.t("js.category.unknown_category_type_description", categoryType: "ideas"),
+ )
end
end
end
diff --git a/spec/requests/api/schemas/json/category_create_response.json b/spec/requests/api/schemas/json/category_create_response.json
index 3d7f27b2498..b670563f08f 100644
--- a/spec/requests/api/schemas/json/category_create_response.json
+++ b/spec/requests/api/schemas/json/category_create_response.json
@@ -380,6 +380,9 @@
"available": {
"type": "boolean"
},
+ "visible": {
+ "type": "boolean"
+ },
"configuration_schema": {
"type": "object"
}
@@ -391,6 +394,7 @@
"description",
"icon",
"available",
+ "visible",
"configuration_schema"
]
}
diff --git a/spec/requests/api/schemas/json/category_update_response.json b/spec/requests/api/schemas/json/category_update_response.json
index 55910535ec1..792e069f23f 100644
--- a/spec/requests/api/schemas/json/category_update_response.json
+++ b/spec/requests/api/schemas/json/category_update_response.json
@@ -383,6 +383,9 @@
"available": {
"type": "boolean"
},
+ "visible": {
+ "type": "boolean"
+ },
"configuration_schema": {
"type": "object"
}
@@ -394,6 +397,7 @@
"description",
"icon",
"available",
+ "visible",
"configuration_schema"
]
}
diff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rb
index 435f16398a9..cb9ff6f2812 100644
--- a/spec/requests/categories_controller_spec.rb
+++ b/spec/requests/categories_controller_spec.rb
@@ -615,6 +615,7 @@ RSpec.describe CategoriesController do
"id" => "discussion",
"name" => I18n.t("category_types.discussion.name"),
"title" => "discussion",
+ "visible" => true,
},
},
)