Skip to content

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

FEATURE: Promote Ideas & Events category types to permanent status (#42080)

Martin Brennanc21f997feb99
diff --git a/.skills/discourse-upcoming-changes-authoring/SKILL.md b/.skills/discourse-upcoming-changes-authoring/SKILL.md
index bffecdd7caa..572029eab11 100644
--- a/.skills/discourse-upcoming-changes-authoring/SKILL.md
+++ b/.skills/discourse-upcoming-changes-authoring/SKILL.md
@@ -188,7 +188,7 @@ Current examples, all of which set `requires_plugin_enabled: false`:
| Change | Why it must work with the plugin off |
|---|---|
-| `enable_events_category_type_setup` (calendar), `enable_support_category_type_setup` (solved), `enable_ideas_category_type_setup` (topic-voting) | Offers a category type whose `enable_plugin` hook turns the plugin on when an admin picks it. Core registers category types *without* the plugin enabled — see `Categories::Types::Base#enable_plugin`. |
+| `enable_support_category_type_setup` (solved) | Offers a category type whose `enable_plugin` hook turns the plugin on when an admin picks it. Core registers category types *without* the plugin enabled — see `Categories::Types::Base#enable_plugin`. |
| `enable_discourse_reactions_by_default` (reactions) | An `upcoming_change_default_override` that flips `discourse_reactions_enabled` from `false` to `true`. Gating it on the plugin being enabled means it can never fire. |
| `enable_discourse_workflows` (workflows) | *Is* the plugin's `enabled_site_setting`. That row is how an admin opts into the plugin at all, so it *must* opt out — otherwise the default gate would gate the change on itself. |
diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb
index c4fc9278e92..32e805b36c8 100644
--- a/app/controllers/categories_controller.rb
+++ b/app/controllers/categories_controller.rb
@@ -137,6 +137,9 @@ class CategoriesController < ApplicationController
Categories::TypeRegistry.counts
end
+ # NOTE: Keep in mind types may not be visible if their visible? method relies
+ # on an upcoming change, and that upcoming change's plugin is not configurable,
+ # as is the case with some discourse hosted sites.
render json: {
types: Categories::TypeRegistry.list(only_visible: true, guardian:),
counts: counts_by_type,
diff --git a/plugins/discourse-calendar/app/services/discourse_calendar/categories/types/events.rb b/plugins/discourse-calendar/app/services/discourse_calendar/categories/types/events.rb
index 0bda32dff32..f65e02a2a0f 100644
--- a/plugins/discourse-calendar/app/services/discourse_calendar/categories/types/events.rb
+++ b/plugins/discourse-calendar/app/services/discourse_calendar/categories/types/events.rb
@@ -7,10 +7,6 @@ module DiscourseCalendar
type_id :events
class << self
- def visible?
- SiteSetting.enable_events_category_type_setup
- end
-
def enable_plugin
SiteSetting.calendar_enabled = true
SiteSetting.discourse_post_event_enabled = true
diff --git a/plugins/discourse-calendar/config/settings.yml b/plugins/discourse-calendar/config/settings.yml
index 5a00f844696..5deb0abea57 100644
--- a/plugins/discourse-calendar/config/settings.yml
+++ b/plugins/discourse-calendar/config/settings.yml
@@ -137,7 +137,7 @@ discourse_calendar:
hidden: true
client: true
upcoming_change:
- status: "stable"
+ status: "permanent"
impact: "feature,staff"
learn_more_url: "https://meta.discourse.org/t/-/401309"
requires_plugin_enabled: false
diff --git a/plugins/discourse-calendar/spec/requests/categories_controller_spec.rb b/plugins/discourse-calendar/spec/requests/categories_controller_spec.rb
index 1f8e8972139..ed87ce90011 100644
--- a/plugins/discourse-calendar/spec/requests/categories_controller_spec.rb
+++ b/plugins/discourse-calendar/spec/requests/categories_controller_spec.rb
@@ -5,7 +5,6 @@ describe CategoriesController do
fab!(:category)
before do
- SiteSetting.enable_events_category_type_setup = true
SiteSetting.calendar_enabled = true
SiteSetting.discourse_post_event_enabled = true
DiscourseCalendar::Categories::Types::Events.configure_category(
diff --git a/plugins/discourse-calendar/spec/services/discourse_calendar/categories/types/events_spec.rb b/plugins/discourse-calendar/spec/services/discourse_calendar/categories/types/events_spec.rb
index f329076791e..3940a4d623d 100644
--- a/plugins/discourse-calendar/spec/services/discourse_calendar/categories/types/events_spec.rb
+++ b/plugins/discourse-calendar/spec/services/discourse_calendar/categories/types/events_spec.rb
@@ -4,18 +4,6 @@ RSpec.describe DiscourseCalendar::Categories::Types::Events do
fab!(:admin)
fab!(:category)
- describe ".visible?" do
- it "returns true when enable_events_category_type_setup is true" do
- SiteSetting.enable_events_category_type_setup = true
- expect(described_class.visible?).to eq(true)
- end
-
- it "returns false when enable_events_category_type_setup is false" do
- SiteSetting.enable_events_category_type_setup = false
- expect(described_class.visible?).to eq(false)
- end
- end
-
describe ".enable_plugin" do
it "enables calendar and post-event site settings" do
SiteSetting.calendar_enabled = false
@@ -182,8 +170,6 @@ RSpec.describe DiscourseCalendar::Categories::Types::Events do
describe "via Categories::Configure" do
it "wires plugin enable, site settings, and category configuration end-to-end" do
- SiteSetting.enable_events_category_type_setup = true
-
result =
Categories::Configure.call(
guardian: admin.guardian,
diff --git a/plugins/discourse-calendar/spec/system/composer/create_event_action_spec.rb b/plugins/discourse-calendar/spec/system/composer/create_event_action_spec.rb
index e5881bc2a67..9226972179e 100644
--- a/plugins/discourse-calendar/spec/system/composer/create_event_action_spec.rb
+++ b/plugins/discourse-calendar/spec/system/composer/create_event_action_spec.rb
@@ -10,7 +10,6 @@ describe "Composer - Create event action" do
before do
SiteSetting.calendar_enabled = true
SiteSetting.discourse_post_event_enabled = true
- SiteSetting.enable_events_category_type_setup = true
DiscourseCalendar::Categories::Types::Events.configure_category(
events_category,
guardian: admin.guardian,
diff --git a/plugins/discourse-calendar/spec/system/events_category_type_setup_spec.rb b/plugins/discourse-calendar/spec/system/events_category_type_setup_spec.rb
index 653527c379b..981da50bb27 100644
--- a/plugins/discourse-calendar/spec/system/events_category_type_setup_spec.rb
+++ b/plugins/discourse-calendar/spec/system/events_category_type_setup_spec.rb
@@ -9,7 +9,6 @@ RSpec.describe "Events Category Type Setup" do
let(:toast) { PageObjects::Components::Toasts.new }
before do
- SiteSetting.enable_events_category_type_setup = true
SiteSetting.calendar_enabled = true
SiteSetting.discourse_post_event_enabled = true
sign_in(admin)
@@ -45,25 +44,6 @@ RSpec.describe "Events Category Type Setup" do
)
end
- context "when the events category type setup is disabled" do
- before { SiteSetting.enable_events_category_type_setup = false }
-
- it "does not show the events category type" do
- visit("/new-category/setup")
- expect(page).to have_no_css(".category-type-cards__card.--category-type-events")
- end
-
- it "does not show the tab for the events category type when editing an existing category" do
- events_category = Fabricate(:category, name: "Events")
- DiscourseCalendar::Categories::Types::Events.configure_category(
- events_category,
- guardian: admin.guardian,
- )
- visit("/c/#{events_category.slug}/edit/events")
- expect(page).to have_no_css(".d-nav-submenu__tabs .edit-category-events")
- end
- end
-
context "when there is an events category already configured" do
fab!(:category)
diff --git a/plugins/discourse-topic-voting/app/services/discourse_topic_voting/categories/types/ideas.rb b/plugins/discourse-topic-voting/app/services/discourse_topic_voting/categories/types/ideas.rb
index 7e1a2c72cf7..82c60ddc871 100644
--- a/plugins/discourse-topic-voting/app/services/discourse_topic_voting/categories/types/ideas.rb
+++ b/plugins/discourse-topic-voting/app/services/discourse_topic_voting/categories/types/ideas.rb
@@ -7,10 +7,6 @@ module DiscourseTopicVoting
type_id :ideas
class << self
- def visible?
- SiteSetting.enable_ideas_category_type_setup
- end
-
def enable_plugin
SiteSetting.topic_voting_enabled = true
end
diff --git a/plugins/discourse-topic-voting/config/settings.yml b/plugins/discourse-topic-voting/config/settings.yml
index b44d524ace4..d34d8806f66 100755
--- a/plugins/discourse-topic-voting/config/settings.yml
+++ b/plugins/discourse-topic-voting/config/settings.yml
@@ -52,7 +52,7 @@ discourse_topic_voting:
hidden: true
client: true
upcoming_change:
- status: "stable"
+ status: "permanent"
impact: "feature,staff"
learn_more_url: "https://meta.discourse.org/t/-/399365"
requires_plugin_enabled: false
diff --git a/plugins/discourse-topic-voting/lib/discourse_topic_voting/categories_controller_extension.rb b/plugins/discourse-topic-voting/lib/discourse_topic_voting/categories_controller_extension.rb
deleted file mode 100644
index bed2dcfbb83..00000000000
--- a/plugins/discourse-topic-voting/lib/discourse_topic_voting/categories_controller_extension.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-module DiscourseTopicVoting
- module CategoriesControllerExtension
- def category_params
- @vote_enabled ||=
- !!ActiveRecord::Type::Boolean.new.cast(params&.[](:custom_fields)&.[](:enable_topic_voting))
-
- category_params = super
-
- # TODO: Remove this whole controller extension when this gets promoted
- # to Permanent
- return category_params if SiteSetting.enable_ideas_category_type_setup
-
- if @vote_enabled && !@category&.discourse_topic_voting_category_setting
- category_params[:discourse_topic_voting_category_setting_attributes] = {}
- elsif !@vote_enabled && @category&.discourse_topic_voting_category_setting
- category_params[:discourse_topic_voting_category_setting_attributes] = {
- id: @category.discourse_topic_voting_category_setting.id,
- _destroy: "1",
- }
- end
-
- category_params
- end
- end
-end
diff --git a/plugins/discourse-topic-voting/plugin.rb b/plugins/discourse-topic-voting/plugin.rb
index 94a3c86eb25..55835c34873 100755
--- a/plugins/discourse-topic-voting/plugin.rb
+++ b/plugins/discourse-topic-voting/plugin.rb
@@ -50,7 +50,6 @@ after_initialize do
reloadable_patch do
register_category_type(DiscourseTopicVoting::Categories::Types::Ideas)
- CategoriesController.prepend(DiscourseTopicVoting::CategoriesControllerExtension)
Category.prepend(DiscourseTopicVoting::CategoryExtension)
ListController.prepend(DiscourseTopicVoting::ListControllerExtension)
Topic.prepend(DiscourseTopicVoting::TopicExtension)
diff --git a/plugins/discourse-topic-voting/spec/requests/categories_controller_spec.rb b/plugins/discourse-topic-voting/spec/requests/categories_controller_spec.rb
index 2661f7a3230..35ef9664af2 100644
--- a/plugins/discourse-topic-voting/spec/requests/categories_controller_spec.rb
+++ b/plugins/discourse-topic-voting/spec/requests/categories_controller_spec.rb
@@ -38,12 +38,7 @@ describe CategoriesController do
end
describe "#update" do
- before do
- Category.reset_voting_cache
- SiteSetting.enable_ideas_category_type_setup = true
- end
-
- after { SiteSetting.enable_ideas_category_type_setup = false }
+ before { Category.reset_voting_cache }
it "can add the ideas type to the category" do
expect(Category.can_vote?(category.id)).to eq(false)
diff --git a/plugins/discourse-topic-voting/spec/services/discourse_topic_voting/categories/types/ideas_spec.rb b/plugins/discourse-topic-voting/spec/services/discourse_topic_voting/categories/types/ideas_spec.rb
index 11f118a54e3..6692c3151a2 100644
--- a/plugins/discourse-topic-voting/spec/services/discourse_topic_voting/categories/types/ideas_spec.rb
+++ b/plugins/discourse-topic-voting/spec/services/discourse_topic_voting/categories/types/ideas_spec.rb
@@ -5,18 +5,6 @@ RSpec.describe DiscourseTopicVoting::Categories::Types::Ideas do
before { SiteSetting.topic_voting_enabled = true }
- describe ".visible?" do
- it "returns true when enable_ideas_category_type_setup is true" do
- SiteSetting.enable_ideas_category_type_setup = true
- expect(described_class.visible?).to eq(true)
- end
-
- it "returns false when enable_ideas_category_type_setup is false" do
- SiteSetting.enable_ideas_category_type_setup = false
- expect(described_class.visible?).to eq(false)
- end
- end
-
describe ".enable_plugin" do
it "enables the topic_voting_enabled site setting" do
SiteSetting.topic_voting_enabled = false
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 ee858e3a0f2..f71c58e28aa 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
@@ -10,10 +10,7 @@ RSpec.describe "Ideas Category Type Setup" do
let(:dialog) { PageObjects::Components::Dialog.new }
let(:toast) { PageObjects::Components::Toasts.new }
- before do
- SiteSetting.enable_ideas_category_type_setup = true
- sign_in(admin)
- end
+ before { sign_in(admin) }
it "works with correct defaults and configures site settings and category setting automatically" do
visit("/new-category/setup")
@@ -82,25 +79,6 @@ RSpec.describe "Ideas Category Type Setup" do
end
end
- context "when the ideas category type setup is disabled" do
- before { SiteSetting.enable_ideas_category_type_setup = false }
-
- it "does not show the ideas category type" do
- visit("/new-category/setup")
- expect(page).to have_no_css(".category-type-cards__card.--category-type-ideas")
- end
-
- it "does not show the tab for the ideas category type when editing an existing category" do
- ideas_category = Fabricate(:category, name: "Ideas")
- DiscourseTopicVoting::Categories::Types::Ideas.configure_category(
- ideas_category,
- guardian: admin.guardian,
- )
- visit("/c/#{ideas_category.slug}/edit/ideas")
- expect(page).to have_no_css(".d-nav-submenu__tabs .edit-category-ideas")
- end
- end
-
context "when there is an ideas category already configured" do
fab!(:category)