FEATURE: allows to enable/disable threading in UI (#22307)

Enabling/Disabling threading has been possible through command line until now. This commit introduces two new UIs:

- When creating a channel, it will be available once the category has been selected
- On the settings page of a channel for admins
This commit is contained in:
Joffrey JAFFEUX
2023-06-29 07:19:12 +02:00
committed by GitHub
parent de2febcc0c
commit ea0b8ca38c
16 changed files with 383 additions and 156 deletions

View File

@ -629,6 +629,7 @@ RSpec.describe Chat::Api::ChannelsController do
chatable_id: category.id,
name: "channel name",
description: "My new channel",
threading_enabled: false,
},
}
end
@ -691,6 +692,25 @@ RSpec.describe Chat::Api::ChannelsController do
expect(new_channel.auto_join_users).to eq(true)
end
it "creates a channel sets threading_enabled to false by default" do
post "/chat/api/channels", params: params
expect(response.status).to eq(200)
new_channel = Chat::Channel.find(response.parsed_body.dig("channel", "id"))
expect(new_channel.threading_enabled).to eq(false)
end
it "creates a channel with threading_enabled set to true" do
params[:channel][:threading_enabled] = true
post "/chat/api/channels", params: params
expect(response.status).to eq(200)
new_channel = Chat::Channel.find(response.parsed_body.dig("channel", "id"))
expect(new_channel.threading_enabled).to eq(true)
end
describe "triggers the auto-join process" do
fab!(:chatters_group) { Fabricate(:group) }
fab!(:user) { Fabricate(:user, last_seen_at: 15.minute.ago) }
@ -884,6 +904,18 @@ RSpec.describe Chat::Api::ChannelsController do
expect(response.parsed_body["channel"]).to match_response_schema("category_chat_channel")
end
describe "when updating threading_enabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = true }
it "sets the new value" do
expect {
put "/chat/api/channels/#{channel.id}", params: { channel: { threading_enabled: true } }
}.to change { channel.reload.threading_enabled }.from(false).to(true)
expect(response.parsed_body["channel"]["threading_enabled"]).to eq(true)
end
end
describe "when updating allow_channel_wide_mentions" do
it "sets the new value" do
put "/chat/api/channels/#{channel.id}",