UX: change text of public_topic action code in login required sites. (#14764)

The wording "made this topic public" made confusion in login required forums.
This commit is contained in:
Vinoth Kannan 2022-01-11 11:35:16 +05:30 committed by GitHub
parent 2ee9a09c8c
commit 6626089034
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -432,6 +432,11 @@ class PostSerializer < BasicPostSerializer
scope.is_staff? ? object.version : object.public_version
end
def action_code
return "open_topic" if object.action_code == "public_topic" && SiteSetting.login_required?
object.action_code
end
def include_action_code?
object.action_code.present?
end

View File

@ -145,6 +145,7 @@ en:
action_codes:
public_topic: "made this topic public %{when}"
open_topic: "converted this to a topic %{when}"
private_topic: "made this topic a personal message %{when}"
split_topic: "split this topic %{when}"
invited_user: "invited %{who} %{when}"

View File

@ -282,6 +282,16 @@ describe PostSerializer do
end
context "post with small action" do
fab!(:post) { Fabricate(:small_action, action_code: "public_topic") }
it "returns `action_code` based on `login_required` site setting" do
expect(serialized_post_for_user(nil)[:action_code]).to eq("public_topic")
SiteSetting.login_required = true
expect(serialized_post_for_user(nil)[:action_code]).to eq("open_topic")
end
end
def serialized_post(u)
s = PostSerializer.new(post, scope: Guardian.new(u), root: false)
s.add_raw = true