mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
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:
@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
CHANNEL_EDITABLE_PARAMS = %i[name description slug]
|
||||
CATEGORY_CHANNEL_EDITABLE_PARAMS = %i[auto_join_users allow_channel_wide_mentions]
|
||||
CATEGORY_CHANNEL_EDITABLE_PARAMS = %i[auto_join_users allow_channel_wide_mentions threading_enabled]
|
||||
|
||||
class Chat::Api::ChannelsController < Chat::ApiController
|
||||
def index
|
||||
@ -36,7 +36,14 @@ class Chat::Api::ChannelsController < Chat::ApiController
|
||||
|
||||
def create
|
||||
channel_params =
|
||||
params.require(:channel).permit(:chatable_id, :name, :slug, :description, :auto_join_users)
|
||||
params.require(:channel).permit(
|
||||
:chatable_id,
|
||||
:name,
|
||||
:slug,
|
||||
:description,
|
||||
:auto_join_users,
|
||||
:threading_enabled,
|
||||
)
|
||||
|
||||
# NOTE: We don't allow creating channels for anything but category chatable types
|
||||
# at the moment. This may change in future, at which point we will need to pass in
|
||||
|
@ -10,6 +10,7 @@ module Chat
|
||||
# description: "This is the best channel",
|
||||
# slug: "super-channel",
|
||||
# category_id: category.id,
|
||||
# threading_enabled: true,
|
||||
# )
|
||||
#
|
||||
class CreateCategoryChannel
|
||||
@ -23,6 +24,7 @@ module Chat
|
||||
# @option params_to_create [String] slug
|
||||
# @option params_to_create [Boolean] auto_join_users
|
||||
# @option params_to_create [Integer] category_id
|
||||
# @option params_to_create [Boolean] threading_enabled
|
||||
# @return [Service::Base::Context]
|
||||
|
||||
policy :can_create_channel
|
||||
@ -42,8 +44,12 @@ module Chat
|
||||
attribute :slug, :string
|
||||
attribute :category_id, :integer
|
||||
attribute :auto_join_users, :boolean, default: false
|
||||
attribute :threading_enabled, :boolean, default: false
|
||||
|
||||
before_validation { self.auto_join_users = auto_join_users.presence || false }
|
||||
before_validation do
|
||||
self.auto_join_users = auto_join_users.presence || false
|
||||
self.threading_enabled = threading_enabled.presence || false
|
||||
end
|
||||
|
||||
validates :category_id, presence: true
|
||||
validates :name, length: { maximum: SiteSetting.max_topic_title_length }
|
||||
@ -70,6 +76,7 @@ module Chat
|
||||
description: contract.description,
|
||||
user_count: 1,
|
||||
auto_join_users: contract.auto_join_users,
|
||||
threading_enabled: contract.threading_enabled,
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
module Chat
|
||||
# Service responsible for updating a chat channel's name, slug, and description.
|
||||
#
|
||||
# For a CategoryChannel, the settings for auto_join_users and allow_channel_wide_mentions
|
||||
# are also editable.
|
||||
# For a CategoryChannel, the settings for auto_join_users, allow_channel_wide_mentions
|
||||
# and threading_enabled are also editable.
|
||||
#
|
||||
# @example
|
||||
# Service::Chat::UpdateChannel.call(
|
||||
@ -13,6 +13,7 @@ module Chat
|
||||
# name: "SuperChannel",
|
||||
# description: "This is the best channel",
|
||||
# slug: "super-channel",
|
||||
# threading_enaled: true,
|
||||
# )
|
||||
#
|
||||
class UpdateChannel
|
||||
@ -43,6 +44,7 @@ module Chat
|
||||
attribute :name, :string
|
||||
attribute :description, :string
|
||||
attribute :slug, :string
|
||||
attribute :threading_enabled, :boolean, default: false
|
||||
attribute :auto_join_users, :boolean, default: false
|
||||
attribute :allow_channel_wide_mentions, :boolean, default: true
|
||||
|
||||
|
Reference in New Issue
Block a user